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

Side by Side Diff: gm/shadertext2.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/shadertext.cpp ('k') | gm/shadertext3.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 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 #include "gm.h" 7 #include "gm.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 11
12 static void makebm(SkBitmap* bm, int w, int h) { 12 static void makebm(SkBitmap* bm, int w, int h) {
13 bm->allocN32Pixels(w, h); 13 bm->allocN32Pixels(w, h);
14 bm->eraseColor(SK_ColorTRANSPARENT); 14 bm->eraseColor(SK_ColorTRANSPARENT);
15 15
16 SkCanvas canvas(*bm); 16 SkCanvas canvas(*bm);
17 SkScalar s = SkIntToScalar(SkMin32(w, h)); 17 SkScalar s = SkIntToScalar(SkMin32(w, h));
18 static const SkPoint kPts0[] = { { 0, 0 }, { s, s } }; 18 static const SkPoint kPts0[] = { { 0, 0 }, { s, s } };
19 static const SkPoint kPts1[] = { { s, 0 }, { 0, s } }; 19 static const SkPoint kPts1[] = { { s, 0 }, { 0, s } };
20 static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; 20 static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
21 static const SkColor kColors0[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF }; 21 static const SkColor kColors0[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF };
22 static const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF }; 22 static const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF };
23 23
24 24
25 SkPaint paint; 25 SkPaint paint;
26 26
27 paint.setShader(SkGradientShader::MakeLinear(kPts0, kColors0, kPos, 27 paint.setShader(SkGradientShader::CreateLinear(kPts0, kColors0, kPos,
28 SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode)); 28 SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode))->unref ();
29 canvas.drawPaint(paint); 29 canvas.drawPaint(paint);
30 paint.setShader(SkGradientShader::MakeLinear(kPts1, kColors1, kPos, 30 paint.setShader(SkGradientShader::CreateLinear(kPts1, kColors1, kPos,
31 SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode)); 31 SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode))->unref ();
32 canvas.drawPaint(paint); 32 canvas.drawPaint(paint);
33 } 33 }
34 34
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 36
37 struct LabeledMatrix { 37 struct LabeledMatrix {
38 SkMatrix fMatrix; 38 SkMatrix fMatrix;
39 const char* fLabel; 39 const char* fLabel;
40 }; 40 };
41 41
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 SkScalar columnH = 0; 130 SkScalar columnH = 0;
131 for (int m = 0; m < matrices.count(); ++m) { 131 for (int m = 0; m < matrices.count(); ++m) {
132 columnH = 0; 132 columnH = 0;
133 canvas->save(); 133 canvas->save();
134 canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel), 134 canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel),
135 0, labelPaint.getTextSize() - 1, labelPaint); 135 0, labelPaint.getTextSize() - 1, labelPaint);
136 canvas->translate(0, kPadY / 2 + kPointSize); 136 canvas->translate(0, kPadY / 2 + kPointSize);
137 columnH += kPadY / 2 + kPointSize; 137 columnH += kPadY / 2 + kPointSize;
138 for (int lm = 0; lm < localMatrices.count(); ++lm) { 138 for (int lm = 0; lm < localMatrices.count(); ++lm) {
139 paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kM irror_TileMode, 139 paint.setShader(
140 SkShader::kRepeat _TileMode, 140 SkShader::CreateBitmapShader(bmp,
141 &localMatrices[lm ].fMatrix)); 141 SkShader::kMirror_TileM ode,
142 SkShader::kRepeat_TileM ode,
143 &localMatrices[lm].fMat rix))->unref();
142 144
143 canvas->save(); 145 canvas->save();
144 canvas->concat(matrices[m].fMatrix); 146 canvas->concat(matrices[m].fMatrix);
145 canvas->drawText(kText, kTextLen, 0, 0, paint); 147 canvas->drawText(kText, kTextLen, 0, 0, paint);
146 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); 148 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint);
147 canvas->restore(); 149 canvas->restore();
148 150
149 SkPath path; 151 SkPath path;
150 path.arcTo(SkRect::MakeXYWH(-0.1f * w, 0.f, 152 path.arcTo(SkRect::MakeXYWH(-0.1f * w, 0.f,
151 1.2f * w, 2.f * kPointSize), 153 1.2f * w, 2.f * kPointSize),
(...skipping 23 matching lines...) Expand all
175 static const char kFillLabel[] = "Filled"; 177 static const char kFillLabel[] = "Filled";
176 static const char kStrokeLabel[] = "Stroked"; 178 static const char kStrokeLabel[] = "Stroked";
177 SkScalar y = columnH + kPadY / 2; 179 SkScalar y = columnH + kPadY / 2;
178 SkScalar fillX = -outlinePaint.measureText(kFillLabel, strlen(kF illLabel)) - kPadX; 180 SkScalar fillX = -outlinePaint.measureText(kFillLabel, strlen(kF illLabel)) - kPadX;
179 SkScalar strokeX = kPadX; 181 SkScalar strokeX = kPadX;
180 canvas->drawText(kFillLabel, strlen(kFillLabel), fillX, y, label Paint); 182 canvas->drawText(kFillLabel, strlen(kFillLabel), fillX, y, label Paint);
181 canvas->drawText(kStrokeLabel, strlen(kStrokeLabel), strokeX, y, labelPaint); 183 canvas->drawText(kStrokeLabel, strlen(kStrokeLabel), strokeX, y, labelPaint);
182 } 184 }
183 } 185 }
184 } 186 }
OLDNEW
« no previous file with comments | « gm/shadertext.cpp ('k') | gm/shadertext3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698