2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
16 #include "SkTRegistry.h"
17 #include "sk_tool_utils.h"
20 #include "GrContext.h"
23 #define DEF_GM(code) \
24 static skiagm::GM* SK_MACRO_APPEND_LINE(F_)(void*) { code; } \
25 static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
35 kSkipPDF_Flag = 1 << 0,
36 kSkipPicture_Flag = 1 << 1,
37 kSkipPipe_Flag = 1 << 2,
38 kSkipPipeCrossProcess_Flag = 1 << 3,
39 kSkipTiled_Flag = 1 << 4,
40 kSkip565_Flag = 1 << 5,
41 kSkipScaledReplay_Flag = 1 << 6,
42 kSkipGPU_Flag = 1 << 7,
43 kSkipPDFRasterization_Flag = 1 << 8,
45 kGPUOnly_Flag = 1 << 9,
47 kAsBench_Flag = 1 << 10, // Run the GM as a benchmark in the bench tool
49 kNoBBH_Flag = 1 << 11, // May draw wrong using a bounding-box hierarchy
58 void setMode(Mode mode) { fMode = mode; }
59 Mode getMode() const { return fMode; }
62 void drawBackground(SkCanvas*);
63 void drawContent(SkCanvas*);
65 SkISize getISize() { return this->onISize(); }
66 const char* getName();
68 uint32_t getFlags() const {
69 return this->onGetFlags();
73 return SkIntToScalar(this->getISize().width());
76 return SkIntToScalar(this->getISize().height());
79 // TODO(vandebo) Instead of exposing this, we should run all the GMs
80 // with and without an initial transform.
81 // Most GMs will return the identity matrix, but some PDFs tests
82 // require setting the initial transform.
83 SkMatrix getInitialTransform() const {
84 SkMatrix matrix = fStarterMatrix;
85 matrix.preConcat(this->onGetInitialTransform());
89 SkColor getBGColor() const { return fBGColor; }
90 void setBGColor(SkColor);
92 // helper: fill a rect in the specified color based on the
93 // GM's getISize bounds.
94 void drawSizeBounds(SkCanvas*, SkColor);
96 bool isCanvasDeferred() const { return fCanvasIsDeferred; }
97 void setCanvasIsDeferred(bool isDeferred) {
98 fCanvasIsDeferred = isDeferred;
101 const SkMatrix& getStarterMatrix() { return fStarterMatrix; }
102 void setStarterMatrix(const SkMatrix& matrix) {
103 fStarterMatrix = matrix;
107 virtual void onOnceBeforeDraw() {}
108 virtual void onDraw(SkCanvas*) = 0;
109 virtual void onDrawBackground(SkCanvas*);
110 virtual SkISize onISize() = 0;
111 virtual SkString onShortName() = 0;
112 virtual uint32_t onGetFlags() const { return 0; }
113 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); }
119 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp
120 bool fHaveCalledOnceBeforeDraw;
121 SkMatrix fStarterMatrix;
124 typedef SkTRegistry<GM*(*)(void*)> GMRegistry;