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 "SkBlurMask.h" | 8 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkLayerDrawLooper.h" | 10 #include "SkLayerDrawLooper.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); | 221 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); |
222 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? | 222 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? |
223 SkScalarMul(paint.getStrokeWidth(), miter) : | 223 SkScalarMul(paint.getStrokeWidth(), miter) : |
224 paint.getStrokeWidth(); | 224 paint.getStrokeWidth(); |
225 maxR.inset(-inset, -inset); | 225 maxR.inset(-inset, -inset); |
226 | 226 |
227 // test that our stroke didn't explode | 227 // test that our stroke didn't explode |
228 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); | 228 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); |
229 } | 229 } |
230 | 230 |
| 231 DEF_TEST(Paint_flattening, reporter) { |
| 232 const SkPaint::FilterLevel levels[] = { |
| 233 SkPaint::kNone_FilterLevel, |
| 234 SkPaint::kLow_FilterLevel, |
| 235 SkPaint::kMedium_FilterLevel, |
| 236 SkPaint::kHigh_FilterLevel, |
| 237 }; |
| 238 const SkPaint::Hinting hinting[] = { |
| 239 SkPaint::kNo_Hinting, |
| 240 SkPaint::kSlight_Hinting, |
| 241 SkPaint::kNormal_Hinting, |
| 242 SkPaint::kFull_Hinting, |
| 243 }; |
| 244 const SkPaint::Align align[] = { |
| 245 SkPaint::kLeft_Align, |
| 246 SkPaint::kCenter_Align, |
| 247 SkPaint::kRight_Align |
| 248 }; |
| 249 const SkPaint::Cap caps[] = { |
| 250 SkPaint::kButt_Cap, |
| 251 SkPaint::kRound_Cap, |
| 252 SkPaint::kSquare_Cap, |
| 253 }; |
| 254 const SkPaint::Join joins[] = { |
| 255 SkPaint::kMiter_Join, |
| 256 SkPaint::kRound_Join, |
| 257 SkPaint::kBevel_Join, |
| 258 }; |
| 259 const SkPaint::TextEncoding encodings[] = { |
| 260 SkPaint::kUTF8_TextEncoding, |
| 261 SkPaint::kUTF16_TextEncoding, |
| 262 SkPaint::kUTF32_TextEncoding, |
| 263 SkPaint::kGlyphID_TextEncoding, |
| 264 }; |
| 265 const SkPaint::Style styles[] = { |
| 266 SkPaint::kFill_Style, |
| 267 SkPaint::kStroke_Style, |
| 268 SkPaint::kStrokeAndFill_Style, |
| 269 }; |
| 270 |
| 271 #define FOR_SETUP(index, array, setter) \ |
| 272 for (size_t index = 0; index < SK_ARRAY_COUNT(array); ++index) { \ |
| 273 paint.setter(array[index]); \ |
| 274 |
| 275 SkPaint paint; |
| 276 paint.setFlags(0x1234); |
| 277 |
| 278 FOR_SETUP(i, levels, setFilterLevel) |
| 279 FOR_SETUP(j, hinting, setHinting) |
| 280 FOR_SETUP(k, align, setTextAlign) |
| 281 FOR_SETUP(l, caps, setStrokeCap) |
| 282 FOR_SETUP(m, joins, setStrokeJoin) |
| 283 FOR_SETUP(n, encodings, setTextEncoding) |
| 284 FOR_SETUP(p, styles, setStyle) |
| 285 |
| 286 SkWriteBuffer writer; |
| 287 paint.flatten(writer); |
| 288 |
| 289 const uint32_t* written = writer.getWriter32()->contiguousArray(); |
| 290 SkReadBuffer reader(written, writer.bytesWritten()); |
| 291 |
| 292 SkPaint paint2; |
| 293 paint2.unflatten(reader); |
| 294 REPORTER_ASSERT(reporter, paint2 == paint); |
| 295 |
| 296 }}}}}}} |
| 297 #undef FOR_SETUP |
| 298 |
| 299 } |
| 300 |
231 // found and fixed for android: not initializing rect for string's of length 0 | 301 // found and fixed for android: not initializing rect for string's of length 0 |
232 DEF_TEST(Paint_regression_measureText, reporter) { | 302 DEF_TEST(Paint_regression_measureText, reporter) { |
233 | 303 |
234 SkPaint paint; | 304 SkPaint paint; |
235 paint.setTextSize(12.0f); | 305 paint.setTextSize(12.0f); |
236 | 306 |
237 SkRect r; | 307 SkRect r; |
238 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); | 308 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); |
239 | 309 |
240 // test that the rect was reset | 310 // test that the rect was reset |
(...skipping 30 matching lines...) Expand all Loading... |
271 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); | 341 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); |
272 ASSERT(other.getTextSize() == paint.getTextSize()); | 342 ASSERT(other.getTextSize() == paint.getTextSize()); |
273 ASSERT(other.getLooper() == paint.getLooper()); | 343 ASSERT(other.getLooper() == paint.getLooper()); |
274 | 344 |
275 // We have to be a little looser and compare just the modes. Pointers might
not be the same. | 345 // We have to be a little looser and compare just the modes. Pointers might
not be the same. |
276 SkXfermode::Mode otherMode, paintMode; | 346 SkXfermode::Mode otherMode, paintMode; |
277 ASSERT(other.getXfermode()->asMode(&otherMode)); | 347 ASSERT(other.getXfermode()->asMode(&otherMode)); |
278 ASSERT(paint.getXfermode()->asMode(&paintMode)); | 348 ASSERT(paint.getXfermode()->asMode(&paintMode)); |
279 ASSERT(otherMode == paintMode); | 349 ASSERT(otherMode == paintMode); |
280 } | 350 } |
OLD | NEW |