| OLD | NEW |
| 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 Loading... |
| 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)); |
| 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; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |