OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef skiagm_DEFINED | 8 #ifndef skiagm_DEFINED |
9 #define skiagm_DEFINED | 9 #define skiagm_DEFINED |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // rendering calls or make use of the onOnceBeforeDraw() virtual; it | 27 // rendering calls or make use of the onOnceBeforeDraw() virtual; it |
28 // consists of: | 28 // consists of: |
29 // * A single void(*)(SkCanvas*) function. | 29 // * A single void(*)(SkCanvas*) function. |
30 // * A name. | 30 // * A name. |
31 // * Prefered width and height. | 31 // * Prefered width and height. |
32 // * Optionally, a background color (default is white). | 32 // * Optionally, a background color (default is white). |
33 #define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \ | 33 #define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \ |
34 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, SK_ColorWHITE, SkString(#NAME)) | 34 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, SK_ColorWHITE, SkString(#NAME)) |
35 #define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)\ | 35 #define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)\ |
36 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, SkString(#NAME)) | 36 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, SkString(#NAME)) |
37 | 37 #define DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, NAME_STR) \ |
38 // Disable tail calls in Simple GM functions to make sure they appear on any sta
ck trace. | 38 static void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS); \ |
39 #if defined(__clang__) | 39 DEF_GM(return new skiagm::SimpleGM(NAME_STR, SK_MACRO_CONCAT(NAME, _GM), \ |
40 #define DISABLE_TAIL_CALLS __attribute__((optnone)) | 40 SkISize::Make(W, H), BGCOLOR);) \ |
41 #elif defined(__GNUC__) | |
42 #define DISABLE_TAIL_CALLS __attribute__((optimize("-O1"))) | |
43 #else | |
44 #define DISABLE_TAIL_CALLS /*TODO: MSVC*/ | |
45 #endif | |
46 | |
47 #define DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, NAME_STR)
\ | |
48 static void DISABLE_TAIL_CALLS SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS)
; \ | |
49 DEF_GM(return new skiagm::SimpleGM(NAME_STR, SK_MACRO_CONCAT(NAME, _GM),
\ | |
50 SkISize::Make(W, H), BGCOLOR);)
\ | |
51 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS) | 41 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS) |
52 | 42 |
53 namespace skiagm { | 43 namespace skiagm { |
54 | 44 |
55 class GM { | 45 class GM { |
56 public: | 46 public: |
57 GM(); | 47 GM(); |
58 virtual ~GM(); | 48 virtual ~GM(); |
59 | 49 |
60 enum Mode { | 50 enum Mode { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 SkISize onISize() override; | 143 SkISize onISize() override; |
154 SkString onShortName() override; | 144 SkString onShortName() override; |
155 private: | 145 private: |
156 SkString fName; | 146 SkString fName; |
157 void (*fDrawProc)(SkCanvas*); | 147 void (*fDrawProc)(SkCanvas*); |
158 SkISize fSize; | 148 SkISize fSize; |
159 }; | 149 }; |
160 } | 150 } |
161 | 151 |
162 #endif | 152 #endif |
OLD | NEW |