Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: tests/SpecialImageTest.cpp

Issue 1861643003: Upgrade SkSpecialImage to have getTextureRef & getROPixels entry points (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Really fix no-GPU build Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/SpecialImageTest.cpp
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index f16f5ff84c26c5d7eba653d0fe4e6d051a901c29..62766c159719adf7e36bff8ce05b31c219b63430 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -51,7 +51,7 @@ static SkBitmap create_bm() {
// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
- bool peekPixelsSucceeds, bool peekTextureSucceeds,
+ GrContext* context, bool peekTextureSucceeds,
int offset, int size) {
const SkIRect subset = TestingSpecialImageAccess::Subset(img.get());
REPORTER_ASSERT(reporter, offset == subset.left());
@@ -64,15 +64,21 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, peekTextureSucceeds ==
!!TestingSpecialImageAccess::PeekTexture(img.get()));
+#if SK_SUPPORT_GPU
//--------------
- // Test that peekPixels reports the correct backing type
- SkPixmap pixmap;
- REPORTER_ASSERT(reporter, peekPixelsSucceeds ==
- !!TestingSpecialImageAccess::PeekPixels(img.get(), &pixmap));
- if (peekPixelsSucceeds) {
- REPORTER_ASSERT(reporter, size == pixmap.width());
- REPORTER_ASSERT(reporter, size == pixmap.height());
+ // Test getTextureAsRef - as long as there is a context this should succeed
+ if (context) {
+ sk_sp<GrTexture> texture(img->asTextureRef(context));
+ REPORTER_ASSERT(reporter, texture);
}
+#endif
+
+ //--------------
+ // Test getROPixels - this should always succeed regardless of backing store
+ SkBitmap bitmap;
+ REPORTER_ASSERT(reporter, img->getROPixels(&bitmap));
+ REPORTER_ASSERT(reporter, size == bitmap.width());
+ REPORTER_ASSERT(reporter, size == bitmap.height());
//--------------
// Test that draw restricts itself to the subset
@@ -110,7 +116,7 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, tightImg->height() == subset.height());
REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture());
SkPixmap tmpPixmap;
- REPORTER_ASSERT(reporter, peekPixelsSucceeds == !!tightImg->peekPixels(&tmpPixmap));
+ REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(&tmpPixmap));
}
{
SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(),
@@ -122,7 +128,7 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, peekTextureSucceeds ==
!!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_BackendHandleAccess));
SkPixmap tmpPixmap;
- REPORTER_ASSERT(reporter, peekPixelsSucceeds == !!tightSurf->peekPixels(&tmpPixmap));
+ REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels(&tmpPixmap));
}
}
@@ -138,12 +144,12 @@ DEF_TEST(SpecialImage_Raster, reporter) {
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(nullptr, subset, bm));
- test_image(subSImg1, reporter, true, false, kPad, kFullSize);
+ test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
}
{
sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
- test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
+ test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
}
}
@@ -162,12 +168,12 @@ DEF_TEST(SpecialImage_Image, reporter) {
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(nullptr, subset,
fullImage));
- test_image(subSImg1, reporter, true, false, kPad, kFullSize);
+ test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
}
{
sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
- test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
+ test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
}
}
@@ -185,7 +191,7 @@ DEF_TEST(SpecialImage_Pixmap, reporter) {
{
sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(nullptr, subset, pixmap,
nullptr, nullptr));
- test_image(img, reporter, true, false, kPad, kFullSize);
+ test_image(img, reporter, nullptr, false, kPad, kFullSize);
}
}
@@ -297,12 +303,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
nullptr, subset,
kNeedNewImageUniqueID_SpecialImage,
texture));
- test_image(subSImg1, reporter, false, true, kPad, kFullSize);
+ test_image(subSImg1, reporter, context, true, kPad, kFullSize);
}
{
sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
- test_image(subSImg2, reporter, false, true, kPad, kFullSize);
+ test_image(subSImg2, reporter, context, true, kPad, kFullSize);
}
}

Powered by Google App Engine
This is Rietveld 408576698