defer creating offscreen until our first draw (so our constructor runs fast)
git-svn-id: http://skia.googlecode.com/svn/trunk@2898 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
20f7b61fd6
commit
5213c04216
@ -38,11 +38,12 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
|
||||
c.drawRect(r, p);
|
||||
}
|
||||
|
||||
static uint16_t gBG[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF };
|
||||
static const uint16_t gBG[] = { 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) {
|
||||
@ -54,20 +55,25 @@ 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,
|
||||
// especially of gBG.
|
||||
SkBitmap scratchBitmap;
|
||||
scratchBitmap.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4);
|
||||
scratchBitmap.setPixels(gBG);
|
||||
scratchBitmap.setIsOpaque(true);
|
||||
scratchBitmap.copyTo(&fBG, SkBitmap::kARGB_4444_Config);
|
||||
|
||||
make_bitmaps(W, H, &fSrcB, &fDstB);
|
||||
fOnce = true;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
const static int W = 64;
|
||||
const static int H = 64;
|
||||
XfermodesGM() {
|
||||
// Do all this work in a temporary so we get a deep copy,
|
||||
// especially of gBG.
|
||||
SkBitmap scratchBitmap;
|
||||
scratchBitmap.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4);
|
||||
scratchBitmap.setPixels(gBG);
|
||||
scratchBitmap.setIsOpaque(true);
|
||||
scratchBitmap.copyTo(&fBG, SkBitmap::kARGB_4444_Config);
|
||||
|
||||
make_bitmaps(W, H, &fSrcB, &fDstB);
|
||||
}
|
||||
XfermodesGM() : fOnce(false) {}
|
||||
|
||||
protected:
|
||||
virtual SkString onShortName() {
|
||||
@ -79,6 +85,8 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
this->init();
|
||||
|
||||
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
||||
|
||||
const struct {
|
||||
|
Loading…
Reference in New Issue
Block a user