Chromium Code Reviews

Unified Diff: tests/SurfaceTest.cpp

Issue 1168303006: Revert[2] SkDraw and all Blitters to use pixmap instead of bitmapi (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: respond to #7 comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « tests/DeviceLooperTest.cpp ('k') | tests/TextureCompressionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SurfaceTest.cpp
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index a3ac216786c262882f2d59be04f7a23385779f16..9a3487864bf4b2a17aa41471e2bb5652acba861f 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,60 @@ static void test_canvaspeek(skiatest::Reporter* reporter,
}
}
+// 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;
robertphillips 2015/06/09 19:02:44 fPeekShouldSucceed doesn't seem to be used ?
+ 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);
+
+ SkBitmap bm = canvas->getDevice_just_for_deprecated_compatibility_testing()->accessBitmap(false);
+ uint32_t genID0 = bm.getGenerationID();
+ canvas->drawColor(SK_ColorBLUE);
robertphillips 2015/06/09 19:06:15 // Thus draw call causes a call to ... ?
reed1 2015/06/09 19:11:12 Done.
+ 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 +642,8 @@ DEF_GPUTEST(Surface, reporter, factory) {
test_imagepeek(reporter, factory);
test_canvaspeek(reporter, factory);
+ test_accessPixels(reporter, factory);
+
#if SK_SUPPORT_GPU
TestGetTexture(reporter, kRaster_SurfaceType, NULL);
if (factory) {
« no previous file with comments | « tests/DeviceLooperTest.cpp ('k') | tests/TextureCompressionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine