Remove GPU read-back logic in SkSpecialImage
All image filters are now implemented entirely on the GPU, so we never
need to read back the contents of a texture-backed special image.
Bug: skia:10202
Change-Id: I9e814d4bccde1e638f7bfc27b140e010ddcbcdb9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298138
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 1144b35..d19f355 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -78,11 +78,13 @@
}
//--------------
- // Test getROPixels - this should always succeed regardless of backing store
- SkBitmap bitmap;
- REPORTER_ASSERT(reporter, img->getROPixels(&bitmap));
- REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width());
- REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height());
+ // Test getROPixels - this only works for raster-backed special images
+ if (!img->isTextureBacked()) {
+ SkBitmap bitmap;
+ REPORTER_ASSERT(reporter, img->getROPixels(&bitmap));
+ REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width());
+ REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height());
+ }
//--------------
// Test that draw restricts itself to the subset
@@ -286,41 +288,3 @@
test_image(subSImg2, reporter, context, true);
}
}
-
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_ReadbackAndCachingSubsets_Gpu, reporter, ctxInfo) {
- GrContext* context = ctxInfo.grContext();
- SkImageInfo ii = SkImageInfo::Make(50, 50, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii);
-
- // Fill out our surface:
- // Green | Blue
- // Red | Green
- {
- surface->getCanvas()->clear(SK_ColorGREEN);
- SkPaint p;
- p.setColor(SK_ColorRED);
- surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 25, 25, 25), p);
- p.setColor(SK_ColorBLUE);
- surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 0, 25, 25), p);
- }
-
- auto image = surface->makeImageSnapshot();
- auto redImg = SkSpecialImage::MakeFromImage(context, SkIRect::MakeXYWH(10, 30, 10, 10), image);
- auto blueImg = SkSpecialImage::MakeFromImage(context, SkIRect::MakeXYWH(30, 10, 10, 10), image);
-
- // This isn't necessary, but if it ever becomes false, then the cache collision bug that we're
- // checking below is irrelevant.
- REPORTER_ASSERT(reporter, redImg->uniqueID() == blueImg->uniqueID());
-
- SkBitmap redBM, blueBM;
- SkAssertResult(redImg->getROPixels(&redBM));
- SkAssertResult(blueImg->getROPixels(&blueBM));
-
- // Each image should read from the correct sub-rect. Past bugs (skbug.com/8448) have included:
- // - Always reading back from (0, 0), producing green
- // - Incorrectly hitting the cache on the 2nd read-back, causing blueBM to be red
- REPORTER_ASSERT(reporter, redBM.getColor(0, 0) == SK_ColorRED,
- "0x%08x != 0x%08x", redBM.getColor(0, 0), SK_ColorRED);
- REPORTER_ASSERT(reporter, blueBM.getColor(0, 0) == SK_ColorBLUE,
- "0x%08x != 0x%08x", blueBM.getColor(0, 0), SK_ColorBLUE);
-}