| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 11 #include "SkXfermode.h" | 11 #include "SkXfermode.h" |
| 12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
| 13 | 13 |
| 14 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
| 15 #include "GrContext.h" | 15 #include "GrContext.h" |
| 16 #include "SkGpuDevice.h" | 16 #include "SkGpuDevice.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace skiagm { | 19 namespace skiagm { |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * This tests drawing device-covering rects with solid colors and bitmap shaders
over a | 22 * This tests drawing device-covering rects with solid colors and bitmap shaders
over a |
| 23 * checkerboard background using different xfermodes. | 23 * checkerboard background using different xfermodes. |
| 24 */ | 24 */ |
| 25 class Xfermodes3GM : public GM { | 25 class Xfermodes3GM : public GM { |
| 26 public: | 26 public: |
| 27 Xfermodes3GM() {} | 27 Xfermodes3GM() {} |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 SkString onShortName() SK_OVERRIDE { | 30 SkString onShortName() override { |
| 31 return SkString("xfermodes3"); | 31 return SkString("xfermodes3"); |
| 32 } | 32 } |
| 33 | 33 |
| 34 SkISize onISize() SK_OVERRIDE { | 34 SkISize onISize() override { |
| 35 return SkISize::Make(630, 1215); | 35 return SkISize::Make(630, 1215); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void onDrawBackground(SkCanvas* canvas) SK_OVERRIDE { | 38 void onDrawBackground(SkCanvas* canvas) override { |
| 39 SkPaint bgPaint; | 39 SkPaint bgPaint; |
| 40 bgPaint.setColor(0xFF70D0E0); | 40 bgPaint.setColor(0xFF70D0E0); |
| 41 canvas->drawPaint(bgPaint); | 41 canvas->drawPaint(bgPaint); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 44 void onDraw(SkCanvas* canvas) override { |
| 45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); | 45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); |
| 46 | 46 |
| 47 SkPaint labelP; | 47 SkPaint labelP; |
| 48 labelP.setAntiAlias(true); | 48 labelP.setAntiAlias(true); |
| 49 sk_tool_utils::set_portable_typeface(&labelP); | 49 sk_tool_utils::set_portable_typeface(&labelP); |
| 50 | 50 |
| 51 static const SkColor kSolidColors[] = { | 51 static const SkColor kSolidColors[] = { |
| 52 SK_ColorTRANSPARENT, | 52 SK_ColorTRANSPARENT, |
| 53 SK_ColorBLUE, | 53 SK_ColorBLUE, |
| 54 0x80808000 | 54 0x80808000 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 | 173 |
| 174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); | 174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); |
| 175 SkPaint borderPaint; | 175 SkPaint borderPaint; |
| 176 borderPaint.setStyle(SkPaint::kStroke_Style); | 176 borderPaint.setStyle(SkPaint::kStroke_Style); |
| 177 canvas->drawRect(r, borderPaint); | 177 canvas->drawRect(r, borderPaint); |
| 178 | 178 |
| 179 canvas->restore(); | 179 canvas->restore(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void onOnceBeforeDraw() SK_OVERRIDE { | 182 void onOnceBeforeDraw() override { |
| 183 static const uint32_t kCheckData[] = { | 183 static const uint32_t kCheckData[] = { |
| 184 SkPackARGB32(0xFF, 0x40, 0x40, 0x40), | 184 SkPackARGB32(0xFF, 0x40, 0x40, 0x40), |
| 185 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 185 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), |
| 186 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 186 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), |
| 187 SkPackARGB32(0xFF, 0x40, 0x40, 0x40) | 187 SkPackARGB32(0xFF, 0x40, 0x40, 0x40) |
| 188 }; | 188 }; |
| 189 SkBitmap bg; | 189 SkBitmap bg; |
| 190 bg.allocN32Pixels(2, 2, true); | 190 bg.allocN32Pixels(2, 2, true); |
| 191 SkAutoLockPixels bgAlp(bg); | 191 SkAutoLockPixels bgAlp(bg); |
| 192 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); | 192 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 SkAutoTUnref<SkShader> fBmpShader; | 233 SkAutoTUnref<SkShader> fBmpShader; |
| 234 | 234 |
| 235 typedef GM INHERITED; | 235 typedef GM INHERITED; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 ////////////////////////////////////////////////////////////////////////////// | 238 ////////////////////////////////////////////////////////////////////////////// |
| 239 | 239 |
| 240 DEF_GM(return new Xfermodes3GM;) | 240 DEF_GM(return new Xfermodes3GM;) |
| 241 | 241 |
| 242 } | 242 } |
| OLD | NEW |