| Index: tests/SpecialImageTest.cpp
|
| diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
|
| index 7511e6297123a82b6d78ccfadf3ba4f670e5072c..db7d2c94b7095dddf7d8d3c31040954de740da3d 100644
|
| --- a/tests/SpecialImageTest.cpp
|
| +++ b/tests/SpecialImageTest.cpp
|
| @@ -172,6 +172,84 @@ DEF_TEST(SpecialImage_Pixmap, reporter) {
|
|
|
|
|
| #if SK_SUPPORT_GPU
|
| +
|
| +static void test_texture_backed(skiatest::Reporter* reporter,
|
| + SkSpecialImage* orig,
|
| + 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
|
| + SkAutoTUnref<SkSpecialImage> rasterImage(SkSpecialImage::NewFromRaster(
|
| + nullptr,
|
| + SkIRect::MakeWH(kFullSize,
|
| + kFullSize),
|
| + bm));
|
| +
|
| + {
|
| + SkAutoTUnref<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(nullptr,
|
| + context));
|
| + test_texture_backed(reporter, rasterImage, fromRaster);
|
| + }
|
| +
|
| + {
|
| + SkAutoTUnref<SkSpecialImage> subRasterImage(rasterImage->extractSubset(subset));
|
| +
|
| + SkAutoTUnref<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;
|
| + }
|
| +
|
| + SkAutoTUnref<SkSpecialImage> gpuImage(SkSpecialImage::NewFromGpu(
|
| + nullptr,
|
| + SkIRect::MakeWH(kFullSize,
|
| + kFullSize),
|
| + kNeedNewImageUniqueID_SpecialImage,
|
| + texture));
|
| +
|
| + {
|
| + SkAutoTUnref<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(nullptr, context));
|
| + test_texture_backed(reporter, gpuImage, fromGPU);
|
| + }
|
| +
|
| + {
|
| + SkAutoTUnref<SkSpecialImage> subGPUImage(gpuImage->extractSubset(subset));
|
| +
|
| + SkAutoTUnref<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();
|
|
|
| @@ -181,7 +259,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;
|
|
|