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 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 SkISize onISize() SK_OVERRIDE{ return SkISize::Make(800, 1000); } | 60 SkISize onISize() SK_OVERRIDE{ return SkISize::Make(800, 1000); } |
61 | 61 |
62 void onOnceBeforeDraw() SK_OVERRIDE { | 62 void onOnceBeforeDraw() SK_OVERRIDE { |
63 makebm(&fBmp, kPointSize / 4, kPointSize / 4); | 63 makebm(&fBmp, kPointSize / 4, kPointSize / 4); |
64 } | 64 } |
65 | 65 |
66 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 66 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
67 | 67 |
68 SkPaint bmpPaint; | 68 SkPaint bmpPaint; |
69 bmpPaint.setAntiAlias(true); | 69 bmpPaint.setAntiAlias(true); |
70 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); | 70 bmpPaint.setFilterQuality(kLow_SkFilterQuality); |
71 bmpPaint.setAlpha(0x80); | 71 bmpPaint.setAlpha(0x80); |
72 canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint); | 72 canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint); |
73 | 73 |
74 SkPaint outlinePaint; | 74 SkPaint outlinePaint; |
75 outlinePaint.setAntiAlias(true); | 75 outlinePaint.setAntiAlias(true); |
76 sk_tool_utils::set_portable_typeface(&outlinePaint); | 76 sk_tool_utils::set_portable_typeface(&outlinePaint); |
77 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); | 77 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); |
78 outlinePaint.setStyle(SkPaint::kStroke_Style); | 78 outlinePaint.setStyle(SkPaint::kStroke_Style); |
79 outlinePaint.setStrokeWidth(0.f); | 79 outlinePaint.setStrokeWidth(0.f); |
80 | 80 |
(...skipping 21 matching lines...) Expand all Loading... |
102 | 102 |
103 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, | 103 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, |
104 kTile
Modes[tm0], | 104 kTile
Modes[tm0], |
105 kTile
Modes[tm1], | 105 kTile
Modes[tm1], |
106 &loca
lM)); | 106 &loca
lM)); |
107 | 107 |
108 SkPaint fillPaint; | 108 SkPaint fillPaint; |
109 fillPaint.setAntiAlias(true); | 109 fillPaint.setAntiAlias(true); |
110 sk_tool_utils::set_portable_typeface(&fillPaint); | 110 sk_tool_utils::set_portable_typeface(&fillPaint); |
111 fillPaint.setTextSize(SkIntToScalar(kPointSize)); | 111 fillPaint.setTextSize(SkIntToScalar(kPointSize)); |
112 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); | 112 fillPaint.setFilterQuality(kLow_SkFilterQuality); |
113 fillPaint.setShader(shader); | 113 fillPaint.setShader(shader); |
114 | 114 |
115 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); | 115 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); |
116 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); | 116 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); |
117 SkScalar w = fillPaint.measureText(kText, kTextLen); | 117 SkScalar w = fillPaint.measureText(kText, kTextLen); |
118 canvas->translate(w + 10.f, 0.f); | 118 canvas->translate(w + 10.f, 0.f); |
119 ++i; | 119 ++i; |
120 if (!(i % 2)) { | 120 if (!(i % 2)) { |
121 canvas->restore(); | 121 canvas->restore(); |
122 canvas->translate(0, 0.75f * kPointSize); | 122 canvas->translate(0, 0.75f * kPointSize); |
123 canvas->save(); | 123 canvas->save(); |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 canvas->restore(); | 127 canvas->restore(); |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
131 SkBitmap fBmp; | 131 SkBitmap fBmp; |
132 typedef GM INHERITED; | 132 typedef GM INHERITED; |
133 }; | 133 }; |
134 | 134 |
135 /////////////////////////////////////////////////////////////////////////////// | 135 /////////////////////////////////////////////////////////////////////////////// |
136 | 136 |
137 static GM* MyFactory(void*) { return new ShaderText3GM; } | 137 static GM* MyFactory(void*) { return new ShaderText3GM; } |
138 static GMRegistry reg(MyFactory); | 138 static GMRegistry reg(MyFactory); |
139 } | 139 } |
OLD | NEW |