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
This commit is contained in:
reed@google.com 2012-03-12 21:13:48 +00:00
parent 0a0726542e
commit 7b1859034f
4 changed files with 53 additions and 3 deletions

View File

@ -40,8 +40,18 @@ class MipMapView : public SampleView {
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 @@ protected:
}
virtual void onDrawContent(SkCanvas* canvas) {
this->init();
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
canvas->scale(1.00000001f, 0.9999999f);

View File

@ -90,6 +90,7 @@ static const SkBitmap::Config gConfigs[] = {
};
class PageFlipView : public SampleView {
bool fOnce;
public:
enum { N = SK_ARRAY_COUNT(gConfigs) };
@ -99,25 +100,37 @@ public:
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 @@ protected:
}
virtual void onDrawContent(SkCanvas* canvas) {
this->init();
SkScalar x = SkIntToScalar(10);
SkScalar y = SkIntToScalar(10);
for (int i = 0; i < N; i++) {

View File

@ -724,8 +724,18 @@ static const SlideProc gProc[] = {
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 @@ protected:
}
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;

View File

@ -134,7 +134,18 @@ class XfermodesView : public SampleView {
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 @@ protected:
}
virtual void onDrawContent(SkCanvas* canvas) {
this->init();
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
const struct {