2011-07-28 14:26:00 +00: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 15:38:48 +00:00
|
|
|
#ifndef skiagm_DEFINED
|
|
|
|
#define skiagm_DEFINED
|
|
|
|
|
2011-07-25 16:27:59 +00:00
|
|
|
#include "SkBitmap.h"
|
2009-06-20 02:38:16 +00:00
|
|
|
#include "SkCanvas.h"
|
2011-07-25 16:27:59 +00:00
|
|
|
#include "SkDevice.h"
|
2009-06-20 02:38:16 +00:00
|
|
|
#include "SkPaint.h"
|
2009-06-10 15:38:48 +00:00
|
|
|
#include "SkRefCnt.h"
|
2009-06-20 02:38:16 +00:00
|
|
|
#include "SkSize.h"
|
2009-06-10 15:38:48 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTRegistry.h"
|
|
|
|
|
|
|
|
namespace skiagm {
|
2009-06-20 02:38:16 +00:00
|
|
|
|
2009-06-21 00:49:18 +00:00
|
|
|
static inline SkISize make_isize(int w, int h) {
|
2009-06-20 02:38:16 +00:00
|
|
|
SkISize sz;
|
|
|
|
sz.set(w, h);
|
|
|
|
return sz;
|
|
|
|
}
|
2009-06-10 15:38:48 +00:00
|
|
|
|
|
|
|
class GM {
|
|
|
|
public:
|
|
|
|
GM();
|
|
|
|
virtual ~GM();
|
|
|
|
|
|
|
|
void draw(SkCanvas*);
|
2009-06-20 02:38:16 +00:00
|
|
|
SkISize getISize() { return this->onISize(); }
|
2009-06-21 00:49:18 +00:00
|
|
|
const char* shortName() {
|
|
|
|
if (fShortName.size() == 0) {
|
|
|
|
fShortName = this->onShortName();
|
|
|
|
}
|
|
|
|
return fShortName.c_str();
|
|
|
|
}
|
2009-06-10 15:38:48 +00:00
|
|
|
|
|
|
|
protected:
|
2009-06-21 00:49:18 +00:00
|
|
|
virtual void onDraw(SkCanvas*) = 0;
|
|
|
|
virtual SkISize onISize() = 0;
|
|
|
|
virtual SkString onShortName() = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkString fShortName;
|
2009-06-10 15:38:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef SkTRegistry<GM*, void*> GMRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|