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

Side by Side Diff: tests/PaintTest.cpp

Issue 637583002: Add SkPaint::getHash(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better Created 6 years, 2 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 | « src/core/SkPaint.cpp ('k') | no next file » | 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 336 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
337 ASSERT(other.getTextSize() == paint.getTextSize()); 337 ASSERT(other.getTextSize() == paint.getTextSize());
338 ASSERT(other.getLooper() == paint.getLooper()); 338 ASSERT(other.getLooper() == paint.getLooper());
339 339
340 // We have to be a little looser and compare just the modes. Pointers might not be the same. 340 // We have to be a little looser and compare just the modes. Pointers might not be the same.
341 SkXfermode::Mode otherMode, paintMode; 341 SkXfermode::Mode otherMode, paintMode;
342 ASSERT(other.getXfermode()->asMode(&otherMode)); 342 ASSERT(other.getXfermode()->asMode(&otherMode));
343 ASSERT(paint.getXfermode()->asMode(&paintMode)); 343 ASSERT(paint.getXfermode()->asMode(&paintMode));
344 ASSERT(otherMode == paintMode); 344 ASSERT(otherMode == paintMode);
345 } 345 }
346
347 DEF_TEST(Paint_getHash, r) {
348 // Try not to inspect the actual hash values in here.
349 // We might want to change the hash function.
350
351 SkPaint paint;
352 const uint32_t defaultHash = paint.getHash();
353
354 // Check that some arbitrary field affects the hash.
355 paint.setColor(0xFF00FF00);
356 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
357 paint.setColor(SK_ColorBLACK); // Reset to default value.
358 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
359
360 // SkTypeface is the first field we hash, so test it specially.
361 paint.setTypeface(SkTypeface::RefDefault())->unref();
362 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
363 paint.setTypeface(NULL);
364 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
365
366 // This is part of fBitfields, the last field we hash.
367 paint.setHinting(SkPaint::kSlight_Hinting);
368 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
369 paint.setHinting(SkPaint::kNormal_Hinting);
370 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
371 }
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698