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 #define DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, NAME_STR) \ | 37 |
38 static void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS); \ | 38 // Disable tail calls in Simple GM functions to make sure they appear on any sta
ck trace. |
39 DEF_GM(return new skiagm::SimpleGM(NAME_STR, SK_MACRO_CONCAT(NAME, _GM), \ | 39 #if defined(__clang__) |
40 SkISize::Make(W, H), BGCOLOR);) \ | 40 #define DISABLE_TAIL_CALLS __attribute__((optnone)) |
| 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);)
\ |
41 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS) | 51 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS) |
42 | 52 |
43 namespace skiagm { | 53 namespace skiagm { |
44 | 54 |
45 class GM { | 55 class GM { |
46 public: | 56 public: |
47 GM(); | 57 GM(); |
48 virtual ~GM(); | 58 virtual ~GM(); |
49 | 59 |
50 enum Mode { | 60 enum Mode { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 SkISize onISize() override; | 153 SkISize onISize() override; |
144 SkString onShortName() override; | 154 SkString onShortName() override; |
145 private: | 155 private: |
146 SkString fName; | 156 SkString fName; |
147 void (*fDrawProc)(SkCanvas*); | 157 void (*fDrawProc)(SkCanvas*); |
148 SkISize fSize; | 158 SkISize fSize; |
149 }; | 159 }; |
150 } | 160 } |
151 | 161 |
152 #endif | 162 #endif |
OLD | NEW |