Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: gm/gm.h

Issue 148283017: Make GMs aware of what tool they're being run in. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: w to this->getMode() Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/convexpolyclip.cpp ('k') | gm/gm.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef skiagm_DEFINED 8 #ifndef skiagm_DEFINED
9 #define skiagm_DEFINED 9 #define skiagm_DEFINED
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 kSkip565_Flag = 1 << 5, 46 kSkip565_Flag = 1 << 5,
47 kSkipScaledReplay_Flag = 1 << 6, 47 kSkipScaledReplay_Flag = 1 << 6,
48 kSkipGPU_Flag = 1 << 7, 48 kSkipGPU_Flag = 1 << 7,
49 kSkipPDFRasterization_Flag = 1 << 8, 49 kSkipPDFRasterization_Flag = 1 << 8,
50 50
51 kGPUOnly_Flag = 1 << 9, 51 kGPUOnly_Flag = 1 << 9,
52 52
53 kAsBench_Flag = 1 << 10, // Run the GM as a benchmark in the bench tool 53 kAsBench_Flag = 1 << 10, // Run the GM as a benchmark in the bench tool
54 }; 54 };
55 55
56 enum Mode {
57 kGM_Mode,
58 kSample_Mode,
59 kBench_Mode,
60 };
61
62 void setMode(Mode mode) { fMode = mode; }
63 Mode getMode() const { return fMode; }
64
56 void draw(SkCanvas*); 65 void draw(SkCanvas*);
57 void drawBackground(SkCanvas*); 66 void drawBackground(SkCanvas*);
58 void drawContent(SkCanvas*); 67 void drawContent(SkCanvas*);
59 68
60 SkISize getISize() { return this->onISize(); } 69 SkISize getISize() { return this->onISize(); }
61 const char* shortName(); 70 const char* shortName();
62 71
63 uint32_t getFlags() const { 72 uint32_t getFlags() const {
64 return this->onGetFlags(); 73 return this->onGetFlags();
65 } 74 }
(...skipping 28 matching lines...) Expand all
94 103
95 static SkString& GetResourcePath() { 104 static SkString& GetResourcePath() {
96 return gResourcePath; 105 return gResourcePath;
97 } 106 }
98 107
99 bool isCanvasDeferred() const { return fCanvasIsDeferred; } 108 bool isCanvasDeferred() const { return fCanvasIsDeferred; }
100 void setCanvasIsDeferred(bool isDeferred) { 109 void setCanvasIsDeferred(bool isDeferred) {
101 fCanvasIsDeferred = isDeferred; 110 fCanvasIsDeferred = isDeferred;
102 } 111 }
103 112
104 const SkMatrix& getStarterMatrix() { return fStarterMatrix; } 113 const SkMatrix& getStarterMatrix() { return fStarterMatrix; }
105 void setStarterMatrix(const SkMatrix& matrix) { 114 void setStarterMatrix(const SkMatrix& matrix) {
106 fStarterMatrix = matrix; 115 fStarterMatrix = matrix;
107 } 116 }
108 117
109 protected: 118 protected:
110 static SkString gResourcePath; 119 static SkString gResourcePath;
111 120
112 virtual void onOnceBeforeDraw() {} 121 virtual void onOnceBeforeDraw() {}
113 virtual void onDraw(SkCanvas*) = 0; 122 virtual void onDraw(SkCanvas*) = 0;
114 virtual void onDrawBackground(SkCanvas*); 123 virtual void onDrawBackground(SkCanvas*);
115 virtual SkISize onISize() = 0; 124 virtual SkISize onISize() = 0;
116 virtual SkString onShortName() = 0; 125 virtual SkString onShortName() = 0;
117 virtual uint32_t onGetFlags() const { return 0; } 126 virtual uint32_t onGetFlags() const { return 0; }
118 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); } 127 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); }
119 128
120 private: 129 private:
130 Mode fMode;
121 SkString fShortName; 131 SkString fShortName;
122 SkColor fBGColor; 132 SkColor fBGColor;
123 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp 133 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp
124 bool fHaveCalledOnceBeforeDraw; 134 bool fHaveCalledOnceBeforeDraw;
125 SkMatrix fStarterMatrix; 135 SkMatrix fStarterMatrix;
126 }; 136 };
127 137
128 typedef SkTRegistry<GM*(*)(void*)> GMRegistry; 138 typedef SkTRegistry<GM*(*)(void*)> GMRegistry;
129 } 139 }
130 140
131 #endif 141 #endif
OLDNEW
« no previous file with comments | « gm/convexpolyclip.cpp ('k') | gm/gm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698