cache decoded bitmap in global for now
git-svn-id: http://skia.googlecode.com/svn/trunk@5457 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/techtalk1.cpp b/gm/techtalk1.cpp
index 812bffe..3a6af49 100644
--- a/gm/techtalk1.cpp
+++ b/gm/techtalk1.cpp
@@ -253,20 +253,24 @@
}
#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 @@
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);
}