diff options
author | bsalomon <bsalomon@google.com> | 2016-07-12 18:11:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-12 18:11:17 -0700 |
commit | 634b43008025d039f3f2f1f6c01e8044ffbb901f (patch) | |
tree | 377c7d7deda5bb20bdf4573580c9270b6f1db78e /tests | |
parent | e504dbc092ec09c056ba3aa72693962a06d3aa4c (diff) |
Add a function to convert a texture backed SkImage to raster.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2147493004
Review-Url: https://codereview.chromium.org/2147493004
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 4d43e46eb1..0f760a6c73 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -475,6 +475,33 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_newTextureImage, reporter, contextInf } } +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contextInfo) { + GrContext* context = contextInfo.grContext(); + + std::function<sk_sp<SkImage>()> imageFactories[] = { + create_image, + create_codec_image, + create_data_image, + create_picture_image, + [context] { return create_gpu_image(context); }, + }; + for (auto factory : imageFactories) { + sk_sp<SkImage> image = factory(); + if (!image->isTextureBacked()) { + REPORTER_ASSERT(reporter, image->makeNonTextureImage().get() == image.get()); + if (!(image = image->makeTextureImage(context))) { + continue; + } + } + auto rasterImage = image->makeNonTextureImage(); + if (!rasterImage) { + ERRORF(reporter, "makeNonTextureImage failed for texture-backed image."); + } + REPORTER_ASSERT(reporter, !rasterImage->isTextureBacked()); + assert_equal(reporter, image.get(), nullptr, rasterImage.get()); + } +} + DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, contextInfo) { auto context = contextInfo.grContext(); auto image = create_gpu_image(context); |