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 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
37 | 37 |
38 struct LabeledMatrix { | 38 struct LabeledMatrix { |
39 SkMatrix fMatrix; | 39 SkMatrix fMatrix; |
40 const char* fLabel; | 40 const char* fLabel; |
41 }; | 41 }; |
42 | 42 |
43 class ShaderText2GM : public GM { | 43 class ShaderText2GM : public GM { |
44 public: | 44 public: |
45 ShaderText2GM() { | 45 ShaderText2GM() { |
46 this->setBGColor(0xFFDDDDDD); | 46 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
47 } | 47 } |
48 | 48 |
49 protected: | 49 protected: |
50 | 50 |
51 SkString onShortName() override { | 51 SkString onShortName() override { |
52 return SkString("shadertext2"); | 52 return SkString("shadertext2"); |
53 } | 53 } |
54 | 54 |
55 SkISize onISize() override { return SkISize::Make(1800, 900); } | 55 SkISize onISize() override { return SkISize::Make(1800, 900); } |
56 | 56 |
(...skipping 26 matching lines...) Expand all Loading... |
83 localMatrices.top().fMatrix.setPerspY(+0.008f); | 83 localMatrices.top().fMatrix.setPerspY(+0.008f); |
84 localMatrices.top().fLabel = "Persp"; | 84 localMatrices.top().fLabel = "Persp"; |
85 | 85 |
86 static SkBitmap bmp; | 86 static SkBitmap bmp; |
87 if (bmp.isNull()) { | 87 if (bmp.isNull()) { |
88 makebm(&bmp, kPointSize / 2, kPointSize / 2); | 88 makebm(&bmp, kPointSize / 2, kPointSize / 2); |
89 } | 89 } |
90 | 90 |
91 SkPaint fillPaint; | 91 SkPaint fillPaint; |
92 fillPaint.setAntiAlias(true); | 92 fillPaint.setAntiAlias(true); |
93 sk_tool_utils::set_portable_typeface(&fillPaint); | 93 sk_tool_utils::set_portable_typeface_always(&fillPaint); |
94 fillPaint.setTextSize(SkIntToScalar(kPointSize)); | 94 fillPaint.setTextSize(SkIntToScalar(kPointSize)); |
95 fillPaint.setFilterQuality(kLow_SkFilterQuality); | 95 fillPaint.setFilterQuality(kLow_SkFilterQuality); |
96 | 96 |
97 SkPaint outlinePaint; | 97 SkPaint outlinePaint; |
98 outlinePaint.setAntiAlias(true); | 98 outlinePaint.setAntiAlias(true); |
99 sk_tool_utils::set_portable_typeface(&outlinePaint); | 99 sk_tool_utils::set_portable_typeface_always(&outlinePaint); |
100 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); | 100 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); |
101 outlinePaint.setStyle(SkPaint::kStroke_Style); | 101 outlinePaint.setStyle(SkPaint::kStroke_Style); |
102 outlinePaint.setStrokeWidth(0.f); | 102 outlinePaint.setStrokeWidth(0.f); |
103 | 103 |
104 SkScalar w = fillPaint.measureText(kText, kTextLen); | 104 SkScalar w = fillPaint.measureText(kText, kTextLen); |
105 static SkScalar kPadY = 0.5f * kPointSize; | 105 static SkScalar kPadY = 0.5f * kPointSize; |
106 static SkScalar kPadX = 1.5f * kPointSize; | 106 static SkScalar kPadX = 1.5f * kPointSize; |
107 | 107 |
108 SkPaint strokePaint(fillPaint); | 108 SkPaint strokePaint(fillPaint); |
109 strokePaint.setStyle(SkPaint::kStroke_Style); | 109 strokePaint.setStyle(SkPaint::kStroke_Style); |
110 strokePaint.setStrokeWidth(kPointSize * 0.1f); | 110 strokePaint.setStrokeWidth(kPointSize * 0.1f); |
111 | 111 |
112 SkPaint labelPaint; | 112 SkPaint labelPaint; |
113 labelPaint.setColor(0xff000000); | 113 labelPaint.setColor(0xff000000); |
114 labelPaint.setAntiAlias(true); | 114 labelPaint.setAntiAlias(true); |
115 sk_tool_utils::set_portable_typeface(&labelPaint); | 115 sk_tool_utils::set_portable_typeface_always(&labelPaint); |
116 labelPaint.setTextSize(12.f); | 116 labelPaint.setTextSize(12.f); |
117 | 117 |
118 canvas->translate(15.f, 15.f); | 118 canvas->translate(15.f, 15.f); |
119 canvas->drawBitmap(bmp, 0, 0); | 119 canvas->drawBitmap(bmp, 0, 0); |
120 canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f); | 120 canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f); |
121 | 121 |
122 static const char kLabelLabel[] = "localM / canvasM"; | 122 static const char kLabelLabel[] = "localM / canvasM"; |
123 canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint); | 123 canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint); |
124 canvas->translate(0, 15.f); | 124 canvas->translate(0, 15.f); |
125 | 125 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 private: | 202 private: |
203 typedef GM INHERITED; | 203 typedef GM INHERITED; |
204 }; | 204 }; |
205 | 205 |
206 /////////////////////////////////////////////////////////////////////////////// | 206 /////////////////////////////////////////////////////////////////////////////// |
207 | 207 |
208 static GM* MyFactory(void*) { return new ShaderText2GM; } | 208 static GM* MyFactory(void*) { return new ShaderText2GM; } |
209 static GMRegistry reg(MyFactory); | 209 static GMRegistry reg(MyFactory); |
210 } | 210 } |
OLD | NEW |