Revert[2] SkDraw and all Blitters to use pixmap instead of bitmapi
This reverts commit b3f0ec9f9967da2f80f0d842cb7fd53617b48de3.
BUG=skia:
Review URL: https://codereview.chromium.org/1168303006
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index a3ac216..4803b68 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -7,6 +7,7 @@
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkDevice.h"
#include "SkImageEncoder.h"
#include "SkRRect.h"
#include "SkSurface.h"
@@ -350,6 +351,63 @@
}
}
+// For compatibility with clients that still call accessBitmap(), we need to ensure that we bump
+// the bitmap's genID when we draw to it, else they won't know it has new values. When they are
+// exclusively using surface/image, and we can hide accessBitmap from device, we can remove this
+// test.
+static void test_accessPixels(skiatest::Reporter* reporter, GrContextFactory* factory) {
+ static const struct {
+ SurfaceType fType;
+ bool fPeekShouldSucceed;
+ } gRec[] = {
+ { kRaster_SurfaceType, true },
+ { kRasterDirect_SurfaceType, true },
+#if SK_SUPPORT_GPU
+ { kGpu_SurfaceType, false },
+ { kGpuScratch_SurfaceType, false },
+#endif
+ };
+
+ int cnt;
+#if SK_SUPPORT_GPU
+ cnt = GrContextFactory::kGLContextTypeCnt;
+#else
+ cnt = 1;
+#endif
+
+ for (int i= 0; i < cnt; ++i) {
+ GrContext* context = NULL;
+#if SK_SUPPORT_GPU
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+ if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ continue;
+ }
+ context = factory->get(glCtxType);
+
+ if (NULL == context) {
+ continue;
+ }
+#endif
+ for (size_t j = 0; j < SK_ARRAY_COUNT(gRec); ++j) {
+ SkImageInfo info, requestInfo;
+
+ SkAutoTUnref<SkSurface> surface(createSurface(gRec[j].fType, context,
+ &requestInfo));
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->clear(0);
+
+ SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compatibility_testing();
+ SkBitmap bm = device->accessBitmap(false);
+ uint32_t genID0 = bm.getGenerationID();
+ // Now we draw something, which needs to "dirty" the genID (sorta like copy-on-write)
+ canvas->drawColor(SK_ColorBLUE);
+ // Now check that we get a different genID
+ uint32_t genID1 = bm.getGenerationID();
+ REPORTER_ASSERT(reporter, genID0 != genID1);
+ }
+ }
+}
+
static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType surfaceType,
GrContext* context) {
// Verify that the right canvas commands trigger a copy on write
@@ -587,6 +645,8 @@
test_imagepeek(reporter, factory);
test_canvaspeek(reporter, factory);
+ test_accessPixels(reporter, factory);
+
#if SK_SUPPORT_GPU
TestGetTexture(reporter, kRaster_SurfaceType, NULL);
if (factory) {