2011-07-28 18:26:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2009-06-10 19:38:48 +04:00
|
|
|
#ifndef skiagm_DEFINED
|
|
|
|
#define skiagm_DEFINED
|
|
|
|
|
2011-07-25 20:27:59 +04:00
|
|
|
#include "SkBitmap.h"
|
2009-06-20 06:38:16 +04:00
|
|
|
#include "SkCanvas.h"
|
2011-07-25 20:27:59 +04:00
|
|
|
#include "SkDevice.h"
|
2009-06-20 06:38:16 +04:00
|
|
|
#include "SkPaint.h"
|
2009-06-10 19:38:48 +04:00
|
|
|
#include "SkRefCnt.h"
|
2009-06-20 06:38:16 +04:00
|
|
|
#include "SkSize.h"
|
2009-06-10 19:38:48 +04:00
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTRegistry.h"
|
|
|
|
|
|
|
|
namespace skiagm {
|
2009-06-20 06:38:16 +04:00
|
|
|
|
2009-06-21 04:49:18 +04:00
|
|
|
static inline SkISize make_isize(int w, int h) {
|
2009-06-20 06:38:16 +04:00
|
|
|
SkISize sz;
|
|
|
|
sz.set(w, h);
|
|
|
|
return sz;
|
|
|
|
}
|
2009-06-10 19:38:48 +04:00
|
|
|
|
|
|
|
class GM {
|
|
|
|
public:
|
|
|
|
GM();
|
|
|
|
virtual ~GM();
|
|
|
|
|
2011-09-19 23:08:33 +04:00
|
|
|
enum Flags {
|
|
|
|
kSkipPDF_Flag = 1 << 0,
|
|
|
|
kSkipPicture_Flag = 1 << 1
|
|
|
|
};
|
|
|
|
|
2011-10-31 18:18:20 +04:00
|
|
|
void draw(SkCanvas*);
|
|
|
|
void drawBackground(SkCanvas*);
|
|
|
|
void drawContent(SkCanvas*);
|
|
|
|
|
2009-06-20 06:38:16 +04:00
|
|
|
SkISize getISize() { return this->onISize(); }
|
2011-10-31 18:18:20 +04:00
|
|
|
const char* shortName();
|
2009-06-10 19:38:48 +04:00
|
|
|
|
2011-09-19 23:08:33 +04:00
|
|
|
uint32_t getFlags() const {
|
|
|
|
return this->onGetFlags();
|
|
|
|
}
|
2011-10-31 18:18:20 +04:00
|
|
|
|
2011-12-06 20:15:42 +04:00
|
|
|
SkColor getBGColor() const { return fBGColor; }
|
2011-10-31 18:18:20 +04:00
|
|
|
void setBGColor(SkColor);
|
2011-08-29 21:41:02 +04:00
|
|
|
|
2009-06-10 19:38:48 +04:00
|
|
|
protected:
|
2009-06-21 04:49:18 +04:00
|
|
|
virtual void onDraw(SkCanvas*) = 0;
|
2011-10-31 18:18:20 +04:00
|
|
|
virtual void onDrawBackground(SkCanvas*);
|
2009-06-21 04:49:18 +04:00
|
|
|
virtual SkISize onISize() = 0;
|
|
|
|
virtual SkString onShortName() = 0;
|
2011-09-19 23:08:33 +04:00
|
|
|
virtual uint32_t onGetFlags() const { return 0; }
|
2009-06-21 04:49:18 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fShortName;
|
2011-10-31 18:18:20 +04:00
|
|
|
SkColor fBGColor;
|
2009-06-10 19:38:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef SkTRegistry<GM*, void*> GMRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|