aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-11-07 10:37:00 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-07 15:59:38 +0000
commit63bc48d09323a62c8c67237fc66ad6ec7105e973 (patch)
tree465e2fafce0cdf0763de0aa28f3e42e283cf2deb /gm
parent14efcbf3497e6a280cc141e6dec179b4ad4565af (diff)
Add MakeCrossContextFromPixmap
This operates just like MakeCrossContextFromEncoded, but starting from raster data. This version is defensive (always uses copies if a raster image needs to be made). Bug: skia: Change-Id: Ibc2b9a235c89a41fbbfd022d943f15ac212d0677 Reviewed-on: https://skia-review.googlesource.com/68205 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/crosscontextimage.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/gm/crosscontextimage.cpp b/gm/crosscontextimage.cpp
index cf973dbe61..ff56a280d9 100644
--- a/gm/crosscontextimage.cpp
+++ b/gm/crosscontextimage.cpp
@@ -12,7 +12,7 @@
#include "GrContext.h"
#include "SkImage.h"
-DEF_SIMPLE_GM(cross_context_image, canvas, 512 + 512 + 30, 512 + 128 + 30) {
+DEF_SIMPLE_GM(cross_context_image, canvas, 512 * 3 + 60, 512 + 128 + 30) {
GrContext* context = canvas->getGrContext();
if (!context) {
skiagm::GM::DrawGpuOnlyMessage(canvas);
@@ -25,15 +25,26 @@ DEF_SIMPLE_GM(cross_context_image, canvas, 512 + 512 + 30, 512 + 128 + 30) {
canvas->drawImage(encodedImage, 10, 10);
sk_sp<SkImage> crossContextImage = SkImage::MakeCrossContextFromEncoded(
- context, encodedData, false, canvas->imageInfo().colorSpace());
+ context, encodedData, false, canvas->imageInfo().colorSpace());
canvas->drawImage(crossContextImage, 512 + 30, 10);
+ SkBitmap bmp;
+ SkPixmap pixmap;
+ SkAssertResult(encodedImage->asLegacyBitmap(&bmp, SkImage::kRO_LegacyBitmapMode) &&
+ bmp.peekPixels(&pixmap));
+
+ sk_sp<SkImage> crossContextRaster = SkImage::MakeCrossContextFromPixmap(
+ context, pixmap, false, canvas->imageInfo().colorSpace());
+ canvas->drawImage(crossContextRaster, 512 + 512 + 60, 10);
+
SkIRect subset = SkIRect::MakeXYWH(256 - 64, 256 - 64, 128, 128);
sk_sp<SkImage> encodedSubset = encodedImage->makeSubset(subset);
sk_sp<SkImage> crossContextSubset = crossContextImage->makeSubset(subset);
+ sk_sp<SkImage> crossContextRasterSubset = crossContextRaster->makeSubset(subset);
canvas->drawImage(encodedSubset, 10, 512 + 30);
canvas->drawImage(crossContextSubset, 512 + 30, 512 + 30);
+ canvas->drawImage(crossContextRasterSubset, 512 + 512 + 60, 512 + 30);
}
#endif