writepixels needs to bump genID

TBR=

Author: reed@google.com

Review URL: https://codereview.chromium.org/352573005
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index ec98b7e..2fb5c95 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -753,6 +753,9 @@
     // 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 1a52793..70b91f2 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 @@
     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[] = {