| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; | 67 static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; |
| 68 static const int kPointSize = 300; | 68 static const int kPointSize = 300; |
| 69 | 69 |
| 70 static SkBitmap bmp; | 70 static SkBitmap bmp; |
| 71 if (bmp.isNull()) { | 71 if (bmp.isNull()) { |
| 72 makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 4, kPointSize
/ 4); | 72 makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 4, kPointSize
/ 4); |
| 73 } | 73 } |
| 74 | 74 |
| 75 SkPaint bmpPaint; | 75 SkPaint bmpPaint; |
| 76 bmpPaint.setAntiAlias(true); | 76 bmpPaint.setAntiAlias(true); |
| 77 bmpPaint.setFilterBitmap(true); | 77 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 78 bmpPaint.setAlpha(0x80); | 78 bmpPaint.setAlpha(0x80); |
| 79 canvas->drawBitmap(bmp, 5.f, 5.f, &bmpPaint); | 79 canvas->drawBitmap(bmp, 5.f, 5.f, &bmpPaint); |
| 80 | 80 |
| 81 SkPaint outlinePaint; | 81 SkPaint outlinePaint; |
| 82 outlinePaint.setAntiAlias(true); | 82 outlinePaint.setAntiAlias(true); |
| 83 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); | 83 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); |
| 84 outlinePaint.setStyle(SkPaint::kStroke_Style); | 84 outlinePaint.setStyle(SkPaint::kStroke_Style); |
| 85 outlinePaint.setStrokeWidth(0.f); | 85 outlinePaint.setStrokeWidth(0.f); |
| 86 | 86 |
| 87 canvas->translate(15.f, 15.f); | 87 canvas->translate(15.f, 15.f); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 106 kTile
Modes[tm1])); | 106 kTile
Modes[tm1])); |
| 107 SkMatrix localM; | 107 SkMatrix localM; |
| 108 localM.setTranslate(5.f, 5.f); | 108 localM.setTranslate(5.f, 5.f); |
| 109 localM.postRotate(20); | 109 localM.postRotate(20); |
| 110 localM.postScale(1.15f, .85f); | 110 localM.postScale(1.15f, .85f); |
| 111 shader->setLocalMatrix(localM); | 111 shader->setLocalMatrix(localM); |
| 112 | 112 |
| 113 SkPaint fillPaint; | 113 SkPaint fillPaint; |
| 114 fillPaint.setAntiAlias(true); | 114 fillPaint.setAntiAlias(true); |
| 115 fillPaint.setTextSize(SkIntToScalar(kPointSize)); | 115 fillPaint.setTextSize(SkIntToScalar(kPointSize)); |
| 116 fillPaint.setFilterBitmap(true); | 116 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 117 fillPaint.setShader(shader); | 117 fillPaint.setShader(shader); |
| 118 | 118 |
| 119 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); | 119 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); |
| 120 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); | 120 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); |
| 121 SkScalar w = fillPaint.measureText(kText, kTextLen); | 121 SkScalar w = fillPaint.measureText(kText, kTextLen); |
| 122 canvas->translate(w + 10.f, 0.f); | 122 canvas->translate(w + 10.f, 0.f); |
| 123 ++i; | 123 ++i; |
| 124 if (!(i % 2)) { | 124 if (!(i % 2)) { |
| 125 canvas->restore(); | 125 canvas->restore(); |
| 126 canvas->translate(0, 0.75f * kPointSize); | 126 canvas->translate(0, 0.75f * kPointSize); |
| 127 canvas->save(); | 127 canvas->save(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 canvas->restore(); | 131 canvas->restore(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 typedef GM INHERITED; | 135 typedef GM INHERITED; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
| 139 | 139 |
| 140 #ifndef SK_BUILD_FOR_ANDROID | 140 #ifndef SK_BUILD_FOR_ANDROID |
| 141 static GM* MyFactory(void*) { return new ShaderText3GM; } | 141 static GM* MyFactory(void*) { return new ShaderText3GM; } |
| 142 static GMRegistry reg(MyFactory); | 142 static GMRegistry reg(MyFactory); |
| 143 #endif | 143 #endif |
| 144 } | 144 } |
| OLD | NEW |