aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-03 14:52:08 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-03 14:52:08 +0000
commit6ea165dd8fcd31e0fa56f43de4eadd022151c2aa (patch)
treecf73d1189426c138507ab8b7c42fe5cae2971fc5 /gm
parent66ca2fba44fe04f3382a3e22096fe73b60ce19d7 (diff)
Another fix for drawing bitmaps through an SkGPipe that share pixelrefs.
In addition to checking the offset, also check to ensure that the width and height match, so that a subset which includes the upper left corner will be handled properly as well. Review URL: https://codereview.appspot.com/6352066 git-svn-id: http://skia.googlecode.com/svn/trunk@4448 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r--gm/extractbitmap.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/gm/extractbitmap.cpp b/gm/extractbitmap.cpp
index 67657968ae..050d7e7834 100644
--- a/gm/extractbitmap.cpp
+++ b/gm/extractbitmap.cpp
@@ -45,13 +45,33 @@ protected:
create_bitmap(&bitmap);
int x = bitmap.width() / 2;
int y = bitmap.height() / 2;
- SkBitmap subset;
- bitmap.extractSubset(&subset, SkIRect::MakeXYWH(x, y, x, y));
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
canvas->drawBitmap(bitmap, 0, 0);
- canvas->drawBitmap(subset, 0, 0);
+
+ {
+ // Do some subset drawing. This will test that an SkGPipe properly
+ // handles the case where bitmaps share a pixelref
+ // Draw the bottom right fourth of the bitmap over the top left
+ SkBitmap subset;
+ bitmap.extractSubset(&subset, SkIRect::MakeXYWH(x, y, x, y));
+ canvas->drawBitmap(subset, 0, 0);
+ // Draw the top left corner over the bottom right
+ bitmap.extractSubset(&subset, SkIRect::MakeWH(x, y));
+ canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y));
+ // Draw a subset which has the same height and pixelref offset but a
+ // different width
+ bitmap.extractSubset(&subset, SkIRect::MakeWH(x, bitmap.height()));
+ SkAutoCanvasRestore autoRestore(canvas, true);
+ canvas->translate(0, SkIntToScalar(bitmap.height() + 20));
+ canvas->drawBitmap(subset, 0, 0);
+ // Now draw a subet which has the same width and pixelref offset but
+ // a different height
+ bitmap.extractSubset(&subset, SkIRect::MakeWH(bitmap.height(), y));
+ canvas->translate(0, SkIntToScalar(bitmap.height() + 20));
+ canvas->drawBitmap(subset, 0, 0);
+ }
/*
// Now do the same but with a device bitmap as source image
SkRefPtr<SkDevice> primaryDevice(canvas->getDevice());