add init() method, so we don't draw in our constructor (makes debugging harder)
git-svn-id: http://skia.googlecode.com/svn/trunk@3368 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleMipMap.cpp b/samplecode/SampleMipMap.cpp
index de5aac5..a7e3166 100644
--- a/samplecode/SampleMipMap.cpp
+++ b/samplecode/SampleMipMap.cpp
@@ -40,8 +40,18 @@
enum {
N = 64
};
+ bool fOnce;
public:
MipMapView() {
+ fOnce = false;
+ }
+
+ void init() {
+ if (fOnce) {
+ return;
+ }
+ fOnce = true;
+
fBitmap = createBitmap(N);
fWidth = N;
@@ -87,6 +97,7 @@
}
virtual void onDrawContent(SkCanvas* canvas) {
+ this->init();
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
canvas->scale(1.00000001f, 0.9999999f);
diff --git a/samplecode/SamplePageFlip.cpp b/samplecode/SamplePageFlip.cpp
index b2d96f0..99670bd 100644
--- a/samplecode/SamplePageFlip.cpp
+++ b/samplecode/SamplePageFlip.cpp
@@ -90,6 +90,7 @@
};
class PageFlipView : public SampleView {
+ bool fOnce;
public:
enum { N = SK_ARRAY_COUNT(gConfigs) };
@@ -99,25 +100,37 @@
PageFlipView() {
gDone = false;
+ fOnce = false;
+ this->setBGColor(0xFFDDDDDD);
+ }
+
+ void init() {
+ if (fOnce) {
+ return;
+ }
+ fOnce = true;
+
for (int i = 0; i < N; i++) {
int status;
pthread_attr_t attr;
status = pthread_attr_init(&attr);
SkASSERT(0 == status);
-
+
fBitmaps[i].setConfig(gConfigs[i], WIDTH, HEIGHT);
SkFlipPixelRef* pr = new SkFlipPixelRef(gConfigs[i], WIDTH, HEIGHT);
fBitmaps[i].setPixelRef(pr)->unref();
fBitmaps[i].eraseColor(0);
-
+
status = pthread_create(&fThreads[i], &attr, draw_proc, &fBitmaps[i]);
SkASSERT(0 == status);
}
- this->setBGColor(0xFFDDDDDD);
}
virtual ~PageFlipView() {
+ if (!fOnce) {
+ return;
+ }
gDone = true;
for (int i = 0; i < N; i++) {
void* ret;
@@ -137,6 +150,7 @@
}
virtual void onDrawContent(SkCanvas* canvas) {
+ this->init();
SkScalar x = SkIntToScalar(10);
SkScalar y = SkIntToScalar(10);
for (int i = 0; i < N; i++) {
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index d39cee0..9b72afb 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -724,8 +724,18 @@
class SlideView : public SampleView {
int fIndex;
+ bool fOnce;
public:
SlideView() {
+ fOnce = false;
+ }
+
+ void init() {
+ if (fOnce) {
+ return;
+ }
+ fOnce = true;
+
fIndex = 0;
SkBitmap bm;
@@ -757,10 +767,12 @@
}
virtual void onDrawContent(SkCanvas* canvas) {
+ this->init();
gProc[fIndex](canvas);
}
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
+ this->init();
fIndex = (fIndex + 1) % SK_ARRAY_COUNT(gProc);
this->inval(NULL);
return NULL;
diff --git a/samplecode/SampleXfermodes.cpp b/samplecode/SampleXfermodes.cpp
index ffea954..4ad967e 100644
--- a/samplecode/SampleXfermodes.cpp
+++ b/samplecode/SampleXfermodes.cpp
@@ -134,7 +134,18 @@
public:
const static int W = 64;
const static int H = 64;
+ bool fOnce;
+
XfermodesView() {
+ fOnce = false;
+ }
+
+ void init() {
+ if (fOnce) {
+ return;
+ }
+ fOnce = true;
+
const int W = 64;
const int H = 64;
@@ -156,6 +167,8 @@
}
virtual void onDrawContent(SkCanvas* canvas) {
+ this->init();
+
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
const struct {