OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 SkRect underlineRect = SkRect::MakeLTRB(iBox.centerX() - iBox.width() * acce
ntSize * 3, | 62 SkRect underlineRect = SkRect::MakeLTRB(iBox.centerX() - iBox.width() * acce
ntSize * 3, |
63 underlineY, | 63 underlineY, |
64 iBox.centerX(), | 64 iBox.centerX(), |
65 underlineY + accentSize / 10); | 65 underlineY + accentSize / 10); |
66 const SkPoint pts1[] = { SkPoint::Make(underlineRect.x(), 0), | 66 const SkPoint pts1[] = { SkPoint::Make(underlineRect.x(), 0), |
67 SkPoint::Make(iBox.centerX(), 0) }; | 67 SkPoint::Make(iBox.centerX(), 0) }; |
68 const SkScalar pos1[] = { 0, 0.75f }; | 68 const SkScalar pos1[] = { 0, 0.75f }; |
69 const SkColor colors1[] = { SK_ColorTRANSPARENT, SK_ColorBLACK }; | 69 const SkColor colors1[] = { SK_ColorTRANSPARENT, SK_ColorBLACK }; |
70 SkASSERT(SK_ARRAY_COUNT(pos1) == SK_ARRAY_COUNT(colors1)); | 70 SkASSERT(SK_ARRAY_COUNT(pos1) == SK_ARRAY_COUNT(colors1)); |
71 paint.setShader(SkGradientShader::MakeLinear(pts1, colors1, pos1, SK_ARRAY_C
OUNT(pos1), | 71 SkAutoTUnref<SkShader> gradient1(SkGradientShader::CreateLinear(pts1, colors
1, pos1, |
72 SkShader::kClamp_TileMode)); | 72 SK_ARRAY_COU
NT(pos1), |
| 73 SkShader::kC
lamp_TileMode)); |
| 74 paint.setShader(gradient1.get()); |
73 canvas->drawRect(underlineRect, paint); | 75 canvas->drawRect(underlineRect, paint); |
74 | 76 |
75 const SkPoint pts2[] = { SkPoint::Make(iBox.x() - iBox.width() * kGradientPa
d, 0), | 77 const SkPoint pts2[] = { SkPoint::Make(iBox.x() - iBox.width() * kGradientPa
d, 0), |
76 SkPoint::Make(iBox.right() + iBox.width() * kGradie
ntPad, 0) }; | 78 SkPoint::Make(iBox.right() + iBox.width() * kGradie
ntPad, 0) }; |
77 const SkScalar pos2[] = { 0, .01f, 1.0f/3, 1.0f/3, 2.0f/3, 2.0f/3, .99f, 1 }
; | 79 const SkScalar pos2[] = { 0, .01f, 1.0f/3, 1.0f/3, 2.0f/3, 2.0f/3, .99f, 1 }
; |
78 const SkColor colors2[] = { | 80 const SkColor colors2[] = { |
79 SK_ColorBLACK, | 81 SK_ColorBLACK, |
80 0xffca5139, | 82 0xffca5139, |
81 0xffca5139, | 83 0xffca5139, |
82 0xff8dbd53, | 84 0xff8dbd53, |
83 0xff8dbd53, | 85 0xff8dbd53, |
84 0xff5460a5, | 86 0xff5460a5, |
85 0xff5460a5, | 87 0xff5460a5, |
86 SK_ColorBLACK | 88 SK_ColorBLACK |
87 }; | 89 }; |
88 SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2)); | 90 SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2)); |
89 paint.setShader(SkGradientShader::MakeLinear(pts2, colors2, pos2, SK_ARRAY_C
OUNT(pos2), | 91 SkAutoTUnref<SkShader> gradient2(SkGradientShader::CreateLinear(pts2, colors
2, pos2, |
90 SkShader::kClamp_TileMode)); | 92 SK_ARRAY_COU
NT(pos2), |
| 93 SkShader::kC
lamp_TileMode)); |
| 94 paint.setShader(gradient2.get()); |
91 canvas->drawText(kSkiaStr, textLen, 0, 0, paint); | 95 canvas->drawText(kSkiaStr, textLen, 0, 0, paint); |
92 } | 96 } |
93 | 97 |
94 // This GM exercises SkPictureImageGenerator features | 98 // This GM exercises SkPictureImageGenerator features |
95 // (in particular its matrix vs. bounds semantics). | 99 // (in particular its matrix vs. bounds semantics). |
96 class PictureGeneratorGM : public skiagm::GM { | 100 class PictureGeneratorGM : public skiagm::GM { |
97 protected: | 101 protected: |
98 SkString onShortName() override { | 102 SkString onShortName() override { |
99 return SkString("pictureimagegenerator"); | 103 return SkString("pictureimagegenerator"); |
100 } | 104 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 private: | 177 private: |
174 SkAutoTUnref<SkPicture> fPicture; | 178 SkAutoTUnref<SkPicture> fPicture; |
175 | 179 |
176 const SkScalar kPictureWidth = 200; | 180 const SkScalar kPictureWidth = 200; |
177 const SkScalar kPictureHeight = 100; | 181 const SkScalar kPictureHeight = 100; |
178 | 182 |
179 typedef skiagm::GM INHERITED; | 183 typedef skiagm::GM INHERITED; |
180 }; | 184 }; |
181 | 185 |
182 DEF_GM(return new PictureGeneratorGM;) | 186 DEF_GM(return new PictureGeneratorGM;) |
OLD | NEW |