| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 SkShader::kMirror_TileMode, | 93 SkShader::kMirror_TileMode, |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // position the baseline of the first run | 96 // position the baseline of the first run |
| 97 canvas->translate(0.f, 0.75f * kPointSize); | 97 canvas->translate(0.f, 0.75f * kPointSize); |
| 98 | 98 |
| 99 canvas->save(); | 99 canvas->save(); |
| 100 int i = 0; | 100 int i = 0; |
| 101 for (size_t tm0 = 0; tm0 < SK_ARRAY_COUNT(kTileModes); ++tm0) { | 101 for (size_t tm0 = 0; tm0 < SK_ARRAY_COUNT(kTileModes); ++tm0) { |
| 102 for (size_t tm1 = 0; tm1 < SK_ARRAY_COUNT(kTileModes); ++tm1) { | 102 for (size_t tm1 = 0; tm1 < SK_ARRAY_COUNT(kTileModes); ++tm1) { |
| 103 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, | |
| 104 kTile
Modes[tm0], | |
| 105 kTile
Modes[tm1])); | |
| 106 SkMatrix localM; | 103 SkMatrix localM; |
| 107 localM.setTranslate(5.f, 5.f); | 104 localM.setTranslate(5.f, 5.f); |
| 108 localM.postRotate(20); | 105 localM.postRotate(20); |
| 109 localM.postScale(1.15f, .85f); | 106 localM.postScale(1.15f, .85f); |
| 110 shader->setLocalMatrix(localM); | 107 |
| 108 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, |
| 109 kTile
Modes[tm0], |
| 110 kTile
Modes[tm1], |
| 111 &loca
lM)); |
| 111 | 112 |
| 112 SkPaint fillPaint; | 113 SkPaint fillPaint; |
| 113 fillPaint.setAntiAlias(true); | 114 fillPaint.setAntiAlias(true); |
| 114 fillPaint.setTextSize(SkIntToScalar(kPointSize)); | 115 fillPaint.setTextSize(SkIntToScalar(kPointSize)); |
| 115 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); | 116 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 116 fillPaint.setShader(shader); | 117 fillPaint.setShader(shader); |
| 117 | 118 |
| 118 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); | 119 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); |
| 119 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); | 120 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); |
| 120 SkScalar w = fillPaint.measureText(kText, kTextLen); | 121 SkScalar w = fillPaint.measureText(kText, kTextLen); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 133 private: | 134 private: |
| 134 SkBitmap fBmp; | 135 SkBitmap fBmp; |
| 135 typedef GM INHERITED; | 136 typedef GM INHERITED; |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 /////////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////////// |
| 139 | 140 |
| 140 static GM* MyFactory(void*) { return new ShaderText3GM; } | 141 static GM* MyFactory(void*) { return new ShaderText3GM; } |
| 141 static GMRegistry reg(MyFactory); | 142 static GMRegistry reg(MyFactory); |
| 142 } | 143 } |
| OLD | NEW |