aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-28 21:14:21 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-28 21:14:21 +0000
commit7312a183270db1dc4e23412465a41af47c45b95c (patch)
treef9ceb54e2dcab68f4ed9b5f795ed2729c3ee57c5 /gm
parentade32668eb641dde914f9199b3209d9818828035 (diff)
Remove a workaround in gm/xfermodes.cpp
We were performing a deep copy of the pixels in a SkBitmap to work around a bug where drawing an SkBitmap whose pixel memory was set with setPixels to an SkPicture did not preserve the pixel memory. Since the workaround was written, we have fixed the bug in two ways: 1. If setPixels is called with a pointer, we wrap the pixels in an SkPixelRef. 2. Picture recording now makes a deep copy of mutable bitmaps. Also switch to using onOnceBeforeDraw, an existing feature on GM that performs the purpose of the init function. BUG=http://code.google.com/p/skia/issues/detail?id=224 Review URL: https://codereview.appspot.com/7220054 git-svn-id: http://skia.googlecode.com/svn/trunk@7433 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r--gm/xfermodes.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index 8934bc7323..0e47de29ad 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -43,10 +43,11 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
}
}
+static uint16_t gData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF };
+
class XfermodesGM : public GM {
SkBitmap fBG;
SkBitmap fSrcB, fDstB;
- bool fOnce;
void draw_mode(SkCanvas* canvas, SkXfermode* mode, int alpha,
SkScalar x, SkScalar y) {
@@ -58,25 +59,18 @@ class XfermodesGM : public GM {
canvas->drawBitmap(fDstB, x, y, &p);
}
- void init() {
- if (!fOnce) {
- // Do all this work in a temporary so we get a deep copy
- uint16_t localData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF };
- SkBitmap scratchBitmap;
- scratchBitmap.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4);
- scratchBitmap.setPixels(localData);
- scratchBitmap.setIsOpaque(true);
- scratchBitmap.copyTo(&fBG, SkBitmap::kARGB_4444_Config);
-
- make_bitmaps(W, H, &fSrcB, &fDstB);
- fOnce = true;
- }
+ virtual void onOnceBeforeDraw() SK_OVERRIDE {
+ fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4);
+ fBG.setPixels(gData);
+ fBG.setIsOpaque(true);
+
+ make_bitmaps(W, H, &fSrcB, &fDstB);
}
public:
const static int W = 64;
const static int H = 64;
- XfermodesGM() : fOnce(false) {}
+ XfermodesGM() {}
protected:
virtual SkString onShortName() {
@@ -88,8 +82,6 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
- this->init();
-
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
const struct {