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

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: Restore deleted Android code. 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
« no previous file with comments | « tests/PDFPrimitivesTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 SkPaint paint; 326 SkPaint paint;
327 const uint32_t defaultHash = paint.getHash(); 327 const uint32_t defaultHash = paint.getHash();
328 328
329 // Check that some arbitrary field affects the hash. 329 // Check that some arbitrary field affects the hash.
330 paint.setColor(0xFF00FF00); 330 paint.setColor(0xFF00FF00);
331 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 331 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
332 paint.setColor(SK_ColorBLACK); // Reset to default value. 332 paint.setColor(SK_ColorBLACK); // Reset to default value.
333 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 333 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
334 334
335 // SkTypeface is the first field we hash, so test it specially. 335 // SkTypeface is the first field we hash, so test it specially.
336 paint.setTypeface(SkTypeface::RefDefault())->unref(); 336 paint.setTypeface(SkTypeface::MakeDefault());
337 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 337 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
338 paint.setTypeface(nullptr); 338 paint.setTypeface(nullptr);
339 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 339 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
340 340
341 // This is part of fBitfields, the last field we hash. 341 // This is part of fBitfields, the last field we hash.
342 paint.setHinting(SkPaint::kSlight_Hinting); 342 paint.setHinting(SkPaint::kSlight_Hinting);
343 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 343 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
344 paint.setHinting(SkPaint::kNormal_Hinting); 344 paint.setHinting(SkPaint::kNormal_Hinting);
345 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 345 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
346 } 346 }
(...skipping 16 matching lines...) Expand all
363 363
364 SkColorMatrix cm; 364 SkColorMatrix cm;
365 cm.setIdentity(); // does not change alpha 365 cm.setIdentity(); // does not change 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
369 cm.postTranslate(0, 0, 0, 1); // wacks alpha 369 cm.postTranslate(0, 0, 0, 1); // wacks alpha
370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
371 REPORTER_ASSERT(r, !paint.nothingToDraw()); 371 REPORTER_ASSERT(r, !paint.nothingToDraw());
372 } 372 }
OLDNEW
« no previous file with comments | « tests/PDFPrimitivesTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698