| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 | 12 |
| 13 static SkShader* make_shader(SkScalar w, SkScalar h) { | 13 static SkShader* make_shader(SkScalar w, SkScalar h) { |
| 14 const SkColor colors[] = { | 14 const SkColor colors[] = { |
| 15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, | 15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, |
| 16 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, | 16 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, |
| 17 }; | 17 }; |
| 18 const SkPoint pts[] = { { w/4, 0 }, { 3*w/4, h } }; | 18 const SkPoint pts[] = { { w/4, 0 }, { 3*w/4, h } }; |
| 19 | 19 |
| 20 return SkGradientShader::CreateLinear(pts, colors, NULL, | 20 return SkGradientShader::CreateLinear(pts, colors, nullptr, |
| 21 SK_ARRAY_COUNT(colors), | 21 SK_ARRAY_COUNT(colors), |
| 22 SkShader::kMirror_TileMode); | 22 SkShader::kMirror_TileMode); |
| 23 } | 23 } |
| 24 | 24 |
| 25 class VerticesGM : public skiagm::GM { | 25 class VerticesGM : public skiagm::GM { |
| 26 SkPoint fPts[9]; | 26 SkPoint fPts[9]; |
| 27 SkPoint fTexs[9]; | 27 SkPoint fTexs[9]; |
| 28 SkColor fColors[9]; | 28 SkColor fColors[9]; |
| 29 SkShader* fShader; | 29 SkShader* fShader; |
| 30 unsigned fAlpha; | 30 unsigned fAlpha; |
| 31 | 31 |
| 32 public: | 32 public: |
| 33 VerticesGM(unsigned alpha) : fShader(NULL), fAlpha(alpha) { | 33 VerticesGM(unsigned alpha) : fShader(nullptr), fAlpha(alpha) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual ~VerticesGM() { | 36 virtual ~VerticesGM() { |
| 37 SkSafeUnref(fShader); | 37 SkSafeUnref(fShader); |
| 38 } | 38 } |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 | 41 |
| 42 void onOnceBeforeDraw() override { | 42 void onOnceBeforeDraw() override { |
| 43 const SkScalar X = 150; | 43 const SkScalar X = 150; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // start with the center of a 3x3 grid | 78 // start with the center of a 3x3 grid |
| 79 static const uint16_t fan[] = { | 79 static const uint16_t fan[] = { |
| 80 4, | 80 4, |
| 81 0, 1, 2, 5, 8, 7, 6, 3, 0 | 81 0, 1, 2, 5, 8, 7, 6, 3, 0 |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 const struct { | 84 const struct { |
| 85 const SkColor* fColors; | 85 const SkColor* fColors; |
| 86 const SkPoint* fTexs; | 86 const SkPoint* fTexs; |
| 87 } rec[] = { | 87 } rec[] = { |
| 88 { fColors, NULL }, | 88 { fColors, nullptr }, |
| 89 { NULL, fTexs }, | 89 { nullptr, fTexs }, |
| 90 { fColors, fTexs }, | 90 { fColors, fTexs }, |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 const SkXfermode::Mode modes[] = { | 93 const SkXfermode::Mode modes[] = { |
| 94 SkXfermode::kSrc_Mode, | 94 SkXfermode::kSrc_Mode, |
| 95 SkXfermode::kDst_Mode, | 95 SkXfermode::kDst_Mode, |
| 96 SkXfermode::kModulate_Mode, | 96 SkXfermode::kModulate_Mode, |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 SkPaint paint; | 99 SkPaint paint; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 typedef skiagm::GM INHERITED; | 121 typedef skiagm::GM INHERITED; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 ////////////////////////////////////////////////////////////////////////////////
///// | 124 ////////////////////////////////////////////////////////////////////////////////
///// |
| 125 | 125 |
| 126 DEF_GM(return new VerticesGM(0xFF);) | 126 DEF_GM(return new VerticesGM(0xFF);) |
| 127 DEF_GM(return new VerticesGM(0x80);) | 127 DEF_GM(return new VerticesGM(0x80);) |
| OLD | NEW |