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

Unified Diff: tests/SpecialImageTest.cpp

Issue 1813813002: Add SkSpecialImage::makeTextureImage entry point & update filterInput (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix possible nullptr dereference 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 233ce2cee18338a4e2fcc6157028ffb1de5ee640..3240fbd3a72fee36054f4f43a7358738e0133c51 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -174,6 +174,81 @@ DEF_TEST(SpecialImage_Pixmap, reporter) {
#if SK_SUPPORT_GPU
+
+static void test_texture_backed(skiatest::Reporter* reporter,
+ const sk_sp<SkSpecialImage>& orig,
+ const sk_sp<SkSpecialImage>& gpuBacked) {
+ REPORTER_ASSERT(reporter, gpuBacked);
+ REPORTER_ASSERT(reporter, gpuBacked->peekTexture());
+ REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID());
+ REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().width() &&
+ gpuBacked->subset().height() == orig->subset().height());
+}
+
+// Test out the SkSpecialImage::makeTextureImage entry point
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, context) {
+ SkBitmap bm = create_bm();
+
+ const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
+
+ {
+ // raster
+ sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster(
+ nullptr,
+ SkIRect::MakeWH(kFullSize,
+ kFullSize),
+ bm));
+
+ {
+ sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(nullptr, context));
+ test_texture_backed(reporter, rasterImage, fromRaster);
+ }
+
+ {
+ sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset));
+
+ sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(nullptr, context));
+ test_texture_backed(reporter, subRasterImage, fromSubRaster);
+ }
+ }
+
+ {
+ // gpu
+ GrSurfaceDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fWidth = kFullSize;
+ desc.fHeight = kFullSize;
+
+ SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc,
+ SkBudgeted::kNo,
+ bm.getPixels(),
+ 0));
+ if (!texture) {
+ return;
+ }
+
+ sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu(
+ nullptr,
+ SkIRect::MakeWH(kFullSize,
+ kFullSize),
+ kNeedNewImageUniqueID_SpecialImage,
+ texture));
+
+ {
+ sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(nullptr, context));
+ test_texture_backed(reporter, gpuImage, fromGPU);
+ }
+
+ {
+ sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset));
+
+ sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(nullptr, context));
+ test_texture_backed(reporter, subGPUImage, fromSubGPU);
+ }
+ }
+}
+
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, context) {
SkBitmap bm = create_bm();
@@ -183,7 +258,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, context) {
desc.fWidth = kFullSize;
desc.fHeight = kFullSize;
- SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc, SkBudgeted::kNo,
+ SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc,
+ SkBudgeted::kNo,
bm.getPixels(), 0));
if (!texture) {
return;
« 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