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

Unified Diff: tests/SpecialImageTest.cpp

Issue 1816223002: Update SkSpecialImage to be able to create tight SkImages and SkSurfaces (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rm ' ' Created 4 years, 9 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
« no previous file with comments | « src/core/SkSpecialImage.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SpecialImageTest.cpp
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 3240fbd3a72fee36054f4f43a7358738e0133c51..432adc832735ff8eb1246bf8c104d508f94a063e 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -12,6 +12,7 @@
#include "SkPixmap.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
+#include "SkSurface.h"
#include "Test.h"
#include "TestingSpecialImageAccess.h"
@@ -59,10 +60,12 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
//--------------
+ // Test that peekTexture reports the correct backing type
REPORTER_ASSERT(reporter, peekTextureSucceeds ==
!!TestingSpecialImageAccess::PeekTexture(img.get()));
//--------------
+ // Test that peekPixels reports the correct backing type
SkPixmap pixmap;
REPORTER_ASSERT(reporter, peekPixelsSucceeds ==
!!TestingSpecialImageAccess::PeekPixels(img.get(), &pixmap));
@@ -72,6 +75,7 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
}
//--------------
+ // Test that draw restricts itself to the subset
SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType);
sk_sp<SkSpecialSurface> surf(img->makeSurface(info));
@@ -94,6 +98,32 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
kSmallerSize+kPad-1));
REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad,
kSmallerSize+kPad));
+
+ //--------------
+ // Test that makeTightSubset & makeTightSurface return appropriately sized objects
+ // of the correct backing type
+ SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height());
+ {
+ sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset));
+
+ REPORTER_ASSERT(reporter, tightImg->width() == subset.width());
+ REPORTER_ASSERT(reporter, tightImg->height() == subset.height());
+ REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture());
+ SkPixmap tmpPixmap;
+ REPORTER_ASSERT(reporter, peekPixelsSucceeds == !!tightImg->peekPixels(&tmpPixmap));
+ }
+ {
+ SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(),
+ kPremul_SkAlphaType);
+ sk_sp<SkSurface> tightSurf(img->makeTightSurface(info));
+
+ REPORTER_ASSERT(reporter, tightSurf->width() == subset.width());
+ REPORTER_ASSERT(reporter, tightSurf->height() == subset.height());
+ REPORTER_ASSERT(reporter, peekTextureSucceeds ==
+ !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_BackendHandleAccess));
+ SkPixmap tmpPixmap;
+ REPORTER_ASSERT(reporter, peekPixelsSucceeds == !!tightSurf->peekPixels(&tmpPixmap));
+ }
}
DEF_TEST(SpecialImage_Raster, reporter) {
« no previous file with comments | « src/core/SkSpecialImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698