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"
|
|
|
|
#include "SkSize.h"
|
2009-06-10 15:38:48 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTRegistry.h"
|
|
|
|
|
2012-10-30 20:26:58 +00:00
|
|
|
#define DEF_GM(code) \
|
|
|
|
static skiagm::GM* SK_MACRO_APPEND_LINE(F_)(void* p) { code; } \
|
|
|
|
static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
|
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
namespace skiagm {
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2012-03-20 17:40:58 +00:00
|
|
|
static inline SkISize make_isize(int w, int h) {
|
|
|
|
SkISize sz;
|
|
|
|
sz.set(w, h);
|
|
|
|
return sz;
|
|
|
|
}
|
2009-06-10 15:38:48 +00:00
|
|
|
|
|
|
|
class GM {
|
|
|
|
public:
|
|
|
|
GM();
|
|
|
|
virtual ~GM();
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2011-09-19 19:08:33 +00:00
|
|
|
enum Flags {
|
|
|
|
kSkipPDF_Flag = 1 << 0,
|
2012-06-04 17:17:36 +00:00
|
|
|
kSkipPicture_Flag = 1 << 1,
|
2012-08-15 16:32:19 +00:00
|
|
|
kSkipPipe_Flag = 1 << 2,
|
|
|
|
kSkipTiled_Flag = 1 << 3,
|
2012-10-10 15:17:24 +00:00
|
|
|
kSkip565_Flag = 1 << 4,
|
2011-09-19 19:08:33 +00:00
|
|
|
};
|
|
|
|
|
2011-10-31 14:18:20 +00:00
|
|
|
void draw(SkCanvas*);
|
|
|
|
void drawBackground(SkCanvas*);
|
|
|
|
void drawContent(SkCanvas*);
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2012-03-20 17:40:58 +00:00
|
|
|
SkISize getISize() { return this->onISize(); }
|
2011-10-31 14:18:20 +00:00
|
|
|
const char* shortName();
|
2009-06-10 15:38:48 +00:00
|
|
|
|
2011-09-19 19:08:33 +00:00
|
|
|
uint32_t getFlags() const {
|
|
|
|
return this->onGetFlags();
|
|
|
|
}
|
2012-03-21 17:34:30 +00:00
|
|
|
|
|
|
|
// TODO(vandebo) Instead of exposing this, we should run all the GMs
|
|
|
|
// with and without an initial transform.
|
|
|
|
// Most GMs will return the identity matrix, but some PDFs tests
|
|
|
|
// require setting the initial transform.
|
|
|
|
SkMatrix getInitialTransform() const {
|
|
|
|
return this->onGetInitialTransform();
|
|
|
|
}
|
|
|
|
|
2011-12-06 16:15:42 +00:00
|
|
|
SkColor getBGColor() const { return fBGColor; }
|
2011-10-31 14:18:20 +00:00
|
|
|
void setBGColor(SkColor);
|
2011-08-29 17:41:02 +00:00
|
|
|
|
2012-01-03 17:20:38 +00:00
|
|
|
// helper: fill a rect in the specified color based on the
|
|
|
|
// GM's getISize bounds.
|
|
|
|
void drawSizeBounds(SkCanvas*, SkColor);
|
|
|
|
|
2012-08-23 18:14:13 +00:00
|
|
|
static void SetResourcePath(const char* resourcePath) {
|
|
|
|
gResourcePath = resourcePath;
|
2012-03-20 17:40:58 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 13:41:45 +00:00
|
|
|
bool isCanvasDeferred() const { return fCanvasIsDeferred; }
|
|
|
|
void setCanvasIsDeferred(bool isDeferred) {
|
|
|
|
fCanvasIsDeferred = isDeferred;
|
|
|
|
}
|
|
|
|
|
2012-03-20 17:40:58 +00:00
|
|
|
protected:
|
|
|
|
static SkString gResourcePath;
|
|
|
|
|
2012-11-27 15:15:58 +00:00
|
|
|
virtual void onOnceBeforeDraw() {}
|
2012-03-20 17:40:58 +00:00
|
|
|
virtual void onDraw(SkCanvas*) = 0;
|
|
|
|
virtual void onDrawBackground(SkCanvas*);
|
|
|
|
virtual SkISize onISize() = 0;
|
2009-06-21 00:49:18 +00:00
|
|
|
virtual SkString onShortName() = 0;
|
2011-09-19 19:08:33 +00:00
|
|
|
virtual uint32_t onGetFlags() const { return 0; }
|
2012-03-21 17:34:30 +00:00
|
|
|
virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); }
|
|
|
|
|
2009-06-21 00:49:18 +00:00
|
|
|
private:
|
|
|
|
SkString fShortName;
|
2011-10-31 14:18:20 +00:00
|
|
|
SkColor fBGColor;
|
2012-11-16 13:41:45 +00:00
|
|
|
bool fCanvasIsDeferred; // work-around problem in srcmode.cpp
|
2012-11-27 15:15:58 +00:00
|
|
|
bool fHaveCalledOnceBeforeDraw;
|
2009-06-10 15:38:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef SkTRegistry<GM*, void*> GMRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|