Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: gm/pictureimagegenerator.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/perspshaders.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 SkAutoTUnref<SkShader> gradient1(SkGradientShader::CreateLinear(pts1, colors 1, pos1, 71 paint.setShader(SkGradientShader::MakeLinear(pts1, colors1, pos1, SK_ARRAY_C OUNT(pos1),
72 SK_ARRAY_COU NT(pos1), 72 SkShader::kClamp_TileMode));
73 SkShader::kC lamp_TileMode));
74 paint.setShader(gradient1.get());
75 canvas->drawRect(underlineRect, paint); 73 canvas->drawRect(underlineRect, paint);
76 74
77 const SkPoint pts2[] = { SkPoint::Make(iBox.x() - iBox.width() * kGradientPa d, 0), 75 const SkPoint pts2[] = { SkPoint::Make(iBox.x() - iBox.width() * kGradientPa d, 0),
78 SkPoint::Make(iBox.right() + iBox.width() * kGradie ntPad, 0) }; 76 SkPoint::Make(iBox.right() + iBox.width() * kGradie ntPad, 0) };
79 const SkScalar pos2[] = { 0, .01f, 1.0f/3, 1.0f/3, 2.0f/3, 2.0f/3, .99f, 1 } ; 77 const SkScalar pos2[] = { 0, .01f, 1.0f/3, 1.0f/3, 2.0f/3, 2.0f/3, .99f, 1 } ;
80 const SkColor colors2[] = { 78 const SkColor colors2[] = {
81 SK_ColorBLACK, 79 SK_ColorBLACK,
82 0xffca5139, 80 0xffca5139,
83 0xffca5139, 81 0xffca5139,
84 0xff8dbd53, 82 0xff8dbd53,
85 0xff8dbd53, 83 0xff8dbd53,
86 0xff5460a5, 84 0xff5460a5,
87 0xff5460a5, 85 0xff5460a5,
88 SK_ColorBLACK 86 SK_ColorBLACK
89 }; 87 };
90 SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2)); 88 SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2));
91 SkAutoTUnref<SkShader> gradient2(SkGradientShader::CreateLinear(pts2, colors 2, pos2, 89 paint.setShader(SkGradientShader::MakeLinear(pts2, colors2, pos2, SK_ARRAY_C OUNT(pos2),
92 SK_ARRAY_COU NT(pos2), 90 SkShader::kClamp_TileMode));
93 SkShader::kC lamp_TileMode));
94 paint.setShader(gradient2.get());
95 canvas->drawText(kSkiaStr, textLen, 0, 0, paint); 91 canvas->drawText(kSkiaStr, textLen, 0, 0, paint);
96 } 92 }
97 93
98 // This GM exercises SkPictureImageGenerator features 94 // This GM exercises SkPictureImageGenerator features
99 // (in particular its matrix vs. bounds semantics). 95 // (in particular its matrix vs. bounds semantics).
100 class PictureGeneratorGM : public skiagm::GM { 96 class PictureGeneratorGM : public skiagm::GM {
101 protected: 97 protected:
102 SkString onShortName() override { 98 SkString onShortName() override {
103 return SkString("pictureimagegenerator"); 99 return SkString("pictureimagegenerator");
104 } 100 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 private: 173 private:
178 SkAutoTUnref<SkPicture> fPicture; 174 SkAutoTUnref<SkPicture> fPicture;
179 175
180 const SkScalar kPictureWidth = 200; 176 const SkScalar kPictureWidth = 200;
181 const SkScalar kPictureHeight = 100; 177 const SkScalar kPictureHeight = 100;
182 178
183 typedef skiagm::GM INHERITED; 179 typedef skiagm::GM INHERITED;
184 }; 180 };
185 181
186 DEF_GM(return new PictureGeneratorGM;) 182 DEF_GM(return new PictureGeneratorGM;)
OLDNEW
« no previous file with comments | « gm/perspshaders.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698