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

Side by Side Diff: gm/shadertext2.cpp

Issue 245963010: Move SkShader::fLocalMatrix into SkShader constructor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove wrapper Created 6 years, 7 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
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 "SkUnitMappers.h" 10 #include "SkUnitMappers.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 localMatrices.append()->fMatrix.reset(); 88 localMatrices.append()->fMatrix.reset();
89 localMatrices.top().fMatrix.setPerspX(-0.007f); 89 localMatrices.top().fMatrix.setPerspX(-0.007f);
90 localMatrices.top().fMatrix.setPerspY(+0.008f); 90 localMatrices.top().fMatrix.setPerspY(+0.008f);
91 localMatrices.top().fLabel = "Persp"; 91 localMatrices.top().fLabel = "Persp";
92 92
93 static SkBitmap bmp; 93 static SkBitmap bmp;
94 if (bmp.isNull()) { 94 if (bmp.isNull()) {
95 makebm(&bmp, kPointSize / 2, kPointSize / 2); 95 makebm(&bmp, kPointSize / 2, kPointSize / 2);
96 } 96 }
97 97
98 // TODO(dominikg): Do we still need to create this shader here?
99 // The only place where it may be used is in fillPaint.m easureText().
98 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, 100 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp,
99 SkShader::kMi rror_TileMode, 101 SkShader::kMi rror_TileMode,
100 SkShader::kRe peat_TileMode)); 102 SkShader::kRe peat_TileMode));
Dominik Grewe 2014/04/25 17:50:15 I think we can delete this shader here. Wdyt?
scroggo 2014/04/25 17:58:32 I agree. I can't imagine measureText needs to look
101 SkPaint fillPaint; 103 SkPaint fillPaint;
102 fillPaint.setAntiAlias(true); 104 fillPaint.setAntiAlias(true);
103 fillPaint.setTextSize(SkIntToScalar(kPointSize)); 105 fillPaint.setTextSize(SkIntToScalar(kPointSize));
104 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); 106 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
105 fillPaint.setShader(shader); 107 fillPaint.setShader(shader);
106 108
107 SkPaint outlinePaint; 109 SkPaint outlinePaint;
108 outlinePaint.setAntiAlias(true); 110 outlinePaint.setAntiAlias(true);
109 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); 111 outlinePaint.setTextSize(SkIntToScalar(kPointSize));
110 outlinePaint.setStyle(SkPaint::kStroke_Style); 112 outlinePaint.setStyle(SkPaint::kStroke_Style);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 153
152 SkScalar columnH = 0; 154 SkScalar columnH = 0;
153 for (int m = 0; m < matrices.count(); ++m) { 155 for (int m = 0; m < matrices.count(); ++m) {
154 columnH = 0; 156 columnH = 0;
155 canvas->save(); 157 canvas->save();
156 canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel), 158 canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel),
157 0, labelPaint.getTextSize() - 1, labelPaint); 159 0, labelPaint.getTextSize() - 1, labelPaint);
158 canvas->translate(0, kPadY / 2 + kPointSize); 160 canvas->translate(0, kPadY / 2 + kPointSize);
159 columnH += kPadY / 2 + kPointSize; 161 columnH += kPadY / 2 + kPointSize;
160 for (int lm = 0; lm < localMatrices.count(); ++lm) { 162 for (int lm = 0; lm < localMatrices.count(); ++lm) {
161 shader->setLocalMatrix(localMatrices[lm].fMatrix); 163 paint.setShader(SkShader::CreateBitmapShader(bmp,
164 SkShader::kMirr or_TileMode,
165 SkShader::kRepe at_TileMode,
166 &localMatrices[ lm].fMatrix));
162 167
163 canvas->save(); 168 canvas->save();
164 canvas->concat(matrices[m].fMatrix); 169 canvas->concat(matrices[m].fMatrix);
165 canvas->drawText(kText, kTextLen, 0, 0, paint); 170 canvas->drawText(kText, kTextLen, 0, 0, paint);
166 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); 171 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint);
167 canvas->restore(); 172 canvas->restore();
168 173
169 SkPath path; 174 SkPath path;
170 path.arcTo(SkRect::MakeXYWH(-0.1f * w, 0.f, 175 path.arcTo(SkRect::MakeXYWH(-0.1f * w, 0.f,
171 1.2f * w, 2.f * kPointSize), 176 1.2f * w, 2.f * kPointSize),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 215
211 private: 216 private:
212 typedef GM INHERITED; 217 typedef GM INHERITED;
213 }; 218 };
214 219
215 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
216 221
217 static GM* MyFactory(void*) { return new ShaderText2GM; } 222 static GM* MyFactory(void*) { return new ShaderText2GM; }
218 static GMRegistry reg(MyFactory); 223 static GMRegistry reg(MyFactory);
219 } 224 }
OLDNEW
« no previous file with comments | « gm/shaderbounds.cpp ('k') | gm/shadertext3.cpp » ('j') | include/core/SkColorShader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698