diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-10 11:50:26 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-10 11:50:26 +0000 |
commit | 4bbec456d9454ff09668d99aa4eecb7257751748 (patch) | |
tree | 1c4c51cbbf96d2777206396450015d4ea06cdfe0 | |
parent | d6ce0db1647a74cdb7d5d93758ce595931644ee8 (diff) |
cache decoded bitmap in global for now
git-svn-id: http://skia.googlecode.com/svn/trunk@5457 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/techtalk1.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gm/techtalk1.cpp b/gm/techtalk1.cpp index 812bffe574..3a6af49081 100644 --- a/gm/techtalk1.cpp +++ b/gm/techtalk1.cpp @@ -253,20 +253,24 @@ static void draw_oval(SkCanvas* canvas, bool showGL, int flags) { } #include "SkImageDecoder.h" + static void draw_image(SkCanvas* canvas, bool showGL, int flags) { SkPaint paint; paint.setAntiAlias(true); paint.setFilterBitmap(true); setFade(&paint, showGL); - SkBitmap bm; - SkImageDecoder::DecodeFile("/skimages/startrek.png", &bm); - SkRect r = SkRect::MakeWH(bm.width(), bm.height()); + static SkBitmap* gBM; + if (NULL == gBM) { + gBM = new SkBitmap; + SkImageDecoder::DecodeFile("/skimages/startrek.png", gBM); + } + SkRect r = SkRect::MakeWH(gBM->width(), gBM->height()); canvas->save(); canvas->translate(30, 30); canvas->scale(0.8f, 0.8f); - canvas->drawBitmap(bm, 0, 0, &paint); + canvas->drawBitmap(*gBM, 0, 0, &paint); if (showGL) { show_mesh(canvas, r); } @@ -274,7 +278,7 @@ static void draw_image(SkCanvas* canvas, bool showGL, int flags) { canvas->translate(210, 290); canvas->rotate(-35); - canvas->drawBitmap(bm, 0, 0, &paint); + canvas->drawBitmap(*gBM, 0, 0, &paint); if (showGL) { show_mesh(canvas, r); } |