aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-06-27 17:47:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-27 17:47:49 -0700
commit4af35f348b2e2f6c428819118eb7a2f2fff53a74 (patch)
tree80659a403f7c38a2c947ab993e503bb11c985657
parentd4fa4835048ae70ae0b881bcdbc766c982ebca13 (diff)
writepixels needs to bump genID
TBR= Author: reed@google.com Review URL: https://codereview.chromium.org/352573005
-rw-r--r--src/core/SkCanvas.cpp3
-rw-r--r--tests/WritePixelsTest.cpp18
2 files changed, 21 insertions, 0 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index ec98b7e3e6..2fb5c95124 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -753,6 +753,9 @@ bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size
// here x,y are either 0 or negative
pixels = ((const char*)pixels - y * rowBytes - x * info.bytesPerPixel());
+ // Tell our owning surface to bump its generation ID
+ this->predrawNotify();
+
// The device can assert that the requested area is always contained in its bounds
return device->writePixels(info, pixels, rowBytes, target.x(), target.y());
}
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 1a527937de..70b91f227f 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -10,6 +10,7 @@
#include "SkColorPriv.h"
#include "SkMathPriv.h"
#include "SkRegion.h"
+#include "SkSurface.h"
#include "Test.h"
#include "sk_tool_utils.h"
@@ -351,7 +352,24 @@ static bool setupBitmap(SkBitmap* bm, SkColorType ct, SkAlphaType at, int w, int
return true;
}
+static void call_writepixels(SkCanvas* canvas) {
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
+ SkPMColor pixel = 0;
+ canvas->writePixels(info, &pixel, sizeof(SkPMColor), 0, 0);
+}
+
+static void test_surface_genid(skiatest::Reporter* reporter) {
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ uint32_t genID1 = surface->generationID();
+ call_writepixels(surface->getCanvas());
+ uint32_t genID2 = surface->generationID();
+ REPORTER_ASSERT(reporter, genID1 != genID2);
+}
+
DEF_GPUTEST(WritePixels, reporter, factory) {
+ test_surface_genid(reporter);
+
SkCanvas canvas;
const SkIRect testRects[] = {