OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props); | 111 surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props); |
112 canvas = surface.get() ? surface->getCanvas() : inputCanvas; | 112 canvas = surface.get() ? surface->getCanvas() : inputCanvas; |
113 // init our new canvas with the old canvas's matrix | 113 // init our new canvas with the old canvas's matrix |
114 canvas->setMatrix(inputCanvas->getTotalMatrix()); | 114 canvas->setMatrix(inputCanvas->getTotalMatrix()); |
115 #endif | 115 #endif |
116 } | 116 } |
117 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); | 117 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); |
118 | 118 |
119 SkRect bounds = fBlob->bounds(); | 119 SkRect bounds = fBlob->bounds(); |
120 | 120 |
121 static const int kPadX = SkScalarFloorToInt(bounds.width() / 3); | 121 const int kPadX = SkScalarFloorToInt(bounds.width() / 3); |
122 static const int kPadY = SkScalarFloorToInt(bounds.height() / 3); | 122 const int kPadY = SkScalarFloorToInt(bounds.height() / 3); |
123 | 123 |
124 int rowCount = 0; | 124 int rowCount = 0; |
125 canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY)); | 125 canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY)); |
126 canvas->save(); | 126 canvas->save(); |
127 SkRandom random; | 127 SkRandom random; |
128 | 128 |
129 SkPaint paint; | 129 SkPaint paint; |
130 if (!fUseDFT) { | 130 if (!fUseDFT) { |
131 paint.setColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); | 131 paint.setColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); |
132 } | 132 } |
133 paint.setAntiAlias(false); | 133 paint.setAntiAlias(false); |
134 | 134 |
135 static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToS
calar(8)); | 135 const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(8
)); |
136 | 136 |
137 // setup blur paint | 137 // setup blur paint |
138 SkPaint blurPaint(paint); | 138 SkPaint blurPaint(paint); |
139 blurPaint.setColor(sk_tool_utils::color_to_565(SK_ColorBLACK)); | 139 blurPaint.setColor(sk_tool_utils::color_to_565(SK_ColorBLACK)); |
140 blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSig
ma)); | 140 blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSig
ma)); |
141 | 141 |
142 for (int i = 0; i < 4; i++) { | 142 for (int i = 0; i < 4; i++) { |
143 canvas->save(); | 143 canvas->save(); |
144 switch (i % 2) { | 144 switch (i % 2) { |
145 case 0: | 145 case 0: |
146 canvas->rotate(random.nextF() * 45.f); | 146 canvas->rotate(random.nextF() * 45.f); |
147 break; | 147 break; |
148 case 1: | 148 case 1: |
149 canvas->rotate(-random.nextF() * 45.f); | 149 canvas->rotate(-random.nextF() * 45.f); |
150 break; | 150 break; |
151 } | 151 } |
(...skipping 20 matching lines...) Expand all Loading... |
172 // since we prepended this matrix already, we blit using identity | 172 // since we prepended this matrix already, we blit using identity |
173 inputCanvas->resetMatrix(); | 173 inputCanvas->resetMatrix(); |
174 inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, nul
lptr); | 174 inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, nul
lptr); |
175 } | 175 } |
176 #endif | 176 #endif |
177 } | 177 } |
178 | 178 |
179 private: | 179 private: |
180 SkAutoTUnref<const SkTextBlob> fBlob; | 180 SkAutoTUnref<const SkTextBlob> fBlob; |
181 | 181 |
182 static const int kWidth = 2100; | 182 static constexpr int kWidth = 2100; |
183 static const int kHeight = 1900; | 183 static constexpr int kHeight = 1900; |
184 | 184 |
185 bool fUseDFT; | 185 bool fUseDFT; |
186 | 186 |
187 typedef GM INHERITED; | 187 typedef GM INHERITED; |
188 }; | 188 }; |
189 | 189 |
190 ////////////////////////////////////////////////////////////////////////////// | 190 ////////////////////////////////////////////////////////////////////////////// |
191 | 191 |
192 DEF_GM( return new TextBlobMixedSizes(false); ) | 192 DEF_GM( return new TextBlobMixedSizes(false); ) |
193 #if SK_SUPPORT_GPU | 193 #if SK_SUPPORT_GPU |
194 DEF_GM( return new TextBlobMixedSizes(true); ) | 194 DEF_GM( return new TextBlobMixedSizes(true); ) |
195 #endif | 195 #endif |
196 } | 196 } |
OLD | NEW |