Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: tests/PaintTest.cpp

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 size_t (*fSeedTextProc)(const SkUnichar[], void* dst, int count); 73 size_t (*fSeedTextProc)(const SkUnichar[], void* dst, int count);
74 SkPaint::TextEncoding fEncoding; 74 SkPaint::TextEncoding fEncoding;
75 } gRec[] = { 75 } gRec[] = {
76 { uni_to_utf8, SkPaint::kUTF8_TextEncoding }, 76 { uni_to_utf8, SkPaint::kUTF8_TextEncoding },
77 { uni_to_utf16, SkPaint::kUTF16_TextEncoding }, 77 { uni_to_utf16, SkPaint::kUTF16_TextEncoding },
78 { uni_to_utf32, SkPaint::kUTF32_TextEncoding }, 78 { uni_to_utf32, SkPaint::kUTF32_TextEncoding },
79 }; 79 };
80 80
81 SkRandom rand; 81 SkRandom rand;
82 SkPaint paint; 82 SkPaint paint;
83 paint.setTypeface(SkTypeface::RefDefault())->unref(); 83 paint.setTypeface(SkTypeface::MakeDefault());
84 SkTypeface* face = paint.getTypeface(); 84 SkTypeface* face = paint.getTypeface();
85 85
86 for (int i = 0; i < 1000; ++i) { 86 for (int i = 0; i < 1000; ++i) {
87 // generate some random text 87 // generate some random text
88 for (int j = 0; j < NGLYPHS; ++j) { 88 for (int j = 0; j < NGLYPHS; ++j) {
89 src[j] = ' ' + j; 89 src[j] = ' ' + j;
90 } 90 }
91 // inject some random chars, to sometimes abort early 91 // inject some random chars, to sometimes abort early
92 src[rand.nextU() & 63] = rand.nextU() & 0xFFF; 92 src[rand.nextU() & 63] = rand.nextU() & 0xFFF;
93 93
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 SkPaint paint; 322 SkPaint paint;
323 const uint32_t defaultHash = paint.getHash(); 323 const uint32_t defaultHash = paint.getHash();
324 324
325 // Check that some arbitrary field affects the hash. 325 // Check that some arbitrary field affects the hash.
326 paint.setColor(0xFF00FF00); 326 paint.setColor(0xFF00FF00);
327 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 327 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
328 paint.setColor(SK_ColorBLACK); // Reset to default value. 328 paint.setColor(SK_ColorBLACK); // Reset to default value.
329 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 329 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
330 330
331 // SkTypeface is the first field we hash, so test it specially. 331 // SkTypeface is the first field we hash, so test it specially.
332 paint.setTypeface(SkTypeface::RefDefault())->unref(); 332 paint.setTypeface(SkTypeface::MakeDefault());
333 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 333 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
334 paint.setTypeface(nullptr); 334 paint.setTypeface(nullptr);
335 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 335 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
336 336
337 // This is part of fBitfields, the last field we hash. 337 // This is part of fBitfields, the last field we hash.
338 paint.setHinting(SkPaint::kSlight_Hinting); 338 paint.setHinting(SkPaint::kSlight_Hinting);
339 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 339 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
340 paint.setHinting(SkPaint::kNormal_Hinting); 340 paint.setHinting(SkPaint::kNormal_Hinting);
341 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 341 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
342 } 342 }
(...skipping 16 matching lines...) Expand all
359 359
360 SkColorMatrix cm; 360 SkColorMatrix cm;
361 cm.setIdentity(); // does not change alpha 361 cm.setIdentity(); // does not change alpha
362 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 362 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
363 REPORTER_ASSERT(r, paint.nothingToDraw()); 363 REPORTER_ASSERT(r, paint.nothingToDraw());
364 364
365 cm.postTranslate(0, 0, 0, 1); // wacks alpha 365 cm.postTranslate(0, 0, 0, 1); // wacks alpha
366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
367 REPORTER_ASSERT(r, !paint.nothingToDraw()); 367 REPORTER_ASSERT(r, !paint.nothingToDraw());
368 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698