aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/colormatrix.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-22 14:09:28 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-22 14:09:28 +0000
commit9afc656df6e81a17ab591b607a92755a5a2e06cc (patch)
tree571a9cfee5b6013cf6cf25dfad4a9fb042c67c8d /gm/colormatrix.cpp
parentec1a7fa3041944f7c951971f826d82ec05d31b60 (diff)
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
Diffstat (limited to 'gm/colormatrix.cpp')
-rw-r--r--gm/colormatrix.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/gm/colormatrix.cpp b/gm/colormatrix.cpp
index 0a4acfd84f..3cc9c028dc 100644
--- a/gm/colormatrix.cpp
+++ b/gm/colormatrix.cpp
@@ -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;