aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-07-12 18:11:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-12 18:11:17 -0700
commit634b43008025d039f3f2f1f6c01e8044ffbb901f (patch)
tree377c7d7deda5bb20bdf4573580c9270b6f1db78e /tests
parente504dbc092ec09c056ba3aa72693962a06d3aa4c (diff)
Add a function to convert a texture backed SkImage to raster.
Diffstat (limited to 'tests')
-rw-r--r--tests/ImageTest.cpp27
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);