delay any drawing until first call to onDraw (eases debugging)
git-svn-id: http://skia.googlecode.com/svn/trunk@3461 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
ec1a7fa304
commit
9afc656df6
@ -45,10 +45,19 @@ static void make_bitmap(int quarterWidth, int quarterHeight, SkBitmap *bitmap) {
|
||||
}
|
||||
|
||||
class BitmapScrollGM : public GM {
|
||||
public:
|
||||
BitmapScrollGM() {
|
||||
bool fInited;
|
||||
void init() {
|
||||
if (fInited) {
|
||||
return;
|
||||
}
|
||||
fInited = true;
|
||||
// Create the original bitmap.
|
||||
make_bitmap(quarterWidth, quarterHeight, &origBitmap);
|
||||
}
|
||||
|
||||
public:
|
||||
BitmapScrollGM() {
|
||||
fInited = false;
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
@ -62,6 +71,7 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
this->init();
|
||||
SkIRect scrollCenterRegion = SkIRect::MakeXYWH(
|
||||
quarterWidth, quarterHeight, quarterWidth*2+1, quarterHeight*2+1);
|
||||
int x = quarterWidth;
|
||||
|
@ -11,13 +11,35 @@
|
||||
#define WIDTH 500
|
||||
#define HEIGHT 500
|
||||
|
||||
class SkOnce {
|
||||
public:
|
||||
SkOnce() : fOnce(false) {};
|
||||
|
||||
bool once() const {
|
||||
if (fOnce) {
|
||||
return false;
|
||||
}
|
||||
fOnce = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable bool fOnce;
|
||||
};
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
class ColorMatrixGM : public GM {
|
||||
SkOnce fOnce;
|
||||
void init() {
|
||||
if (fOnce.once()) {
|
||||
fBitmap = createBitmap(64, 64);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
ColorMatrixGM() {
|
||||
this->setBGColor(0xFF808080);
|
||||
fBitmap = createBitmap(64, 64);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -45,6 +67,7 @@ protected:
|
||||
return bm;
|
||||
}
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
this->init();
|
||||
|
||||
SkPaint paint;
|
||||
SkColorMatrix matrix;
|
||||
|
Loading…
Reference in New Issue
Block a user