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

Side by Side Diff: gm/gm.h

Issue 23567032: Have GMs read the GrContext via a setter/getter rather than a global. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: initialize fGr to NULL Created 7 years, 3 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/bleed.cpp ('k') | gm/gm.cpp » ('j') | gm/gmmain.cpp » ('J')
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
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkBitmapDevice.h" 12 #include "SkBitmapDevice.h"
13 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkSize.h" 15 #include "SkSize.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 #include "SkTRegistry.h" 17 #include "SkTRegistry.h"
18 18
19 #if SK_SUPPORT_GPU
20 #include "GrContext.h"
21 #endif
22
19 #define DEF_GM(code) \ 23 #define DEF_GM(code) \
20 static skiagm::GM* SK_MACRO_APPEND_LINE(F_)(void*) { code; } \ 24 static skiagm::GM* SK_MACRO_APPEND_LINE(F_)(void*) { code; } \
21 static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_ )); 25 static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_ ));
22 26
23 namespace skiagm { 27 namespace skiagm {
24 28
25 static inline SkISize make_isize(int w, int h) { 29 static inline SkISize make_isize(int w, int h) {
26 SkISize sz; 30 SkISize sz;
27 sz.set(w, h); 31 sz.set(w, h);
28 return sz; 32 return sz;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 90
87 static SkString& GetResourcePath() { 91 static SkString& GetResourcePath() {
88 return gResourcePath; 92 return gResourcePath;
89 } 93 }
90 94
91 bool isCanvasDeferred() const { return fCanvasIsDeferred; } 95 bool isCanvasDeferred() const { return fCanvasIsDeferred; }
92 void setCanvasIsDeferred(bool isDeferred) { 96 void setCanvasIsDeferred(bool isDeferred) {
93 fCanvasIsDeferred = isDeferred; 97 fCanvasIsDeferred = isDeferred;
94 } 98 }
95 99
100 #if SK_SUPPORT_GPU
101 void setGr(GrContext* gr) { fGr = gr; }
102 GrContext* getGr() const { return fGr; }
103 #endif
104
96 protected: 105 protected:
97 static SkString gResourcePath; 106 static SkString gResourcePath;
98 107
99 virtual void onOnceBeforeDraw() {} 108 virtual void onOnceBeforeDraw() {}
100 virtual void onDraw(SkCanvas*) = 0; 109 virtual void onDraw(SkCanvas*) = 0;
101 virtual void onDrawBackground(SkCanvas*); 110 virtual void onDrawBackground(SkCanvas*);
102 virtual SkISize onISize() = 0; 111 virtual SkISize onISize() = 0;
103 virtual SkString onShortName() = 0; 112 virtual SkString onShortName() = 0;
104 virtual uint32_t onGetFlags() const { return 0; } 113 virtual uint32_t onGetFlags() const { return 0; }
105 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); } 114 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); }
106 115
107 private: 116 private:
108 SkString fShortName; 117 SkString fShortName;
109 SkColor fBGColor; 118 SkColor fBGColor;
110 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp 119 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp
111 bool fHaveCalledOnceBeforeDraw; 120 bool fHaveCalledOnceBeforeDraw;
121 #if SK_SUPPORT_GPU
122 GrContext* fGr; // Unowned.
123 #endif
112 }; 124 };
113 125
114 typedef SkTRegistry<GM*(*)(void*)> GMRegistry; 126 typedef SkTRegistry<GM*(*)(void*)> GMRegistry;
115 } 127 }
116 128
117 #endif 129 #endif
OLDNEW
« no previous file with comments | « gm/bleed.cpp ('k') | gm/gm.cpp » ('j') | gm/gmmain.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698