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

Side by Side Diff: tests/UnpremultiplyTest.cpp

Issue 560453002: Back to hashing source content, not .png. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove test Created 6 years, 3 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 | « gyp/tests.gypi ('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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkColorPriv.h"
9 #include "SkUnPreMultiply.h"
10 #include "Test.h"
11
12 DEF_TEST(Unpremultiply, reporter) {
13 // Here we test that unpremultiplication is injective:
14 // no two distinct premul colors map to the same unpremul color.
15
16 // DM exploits this fact to safely hash .pngs instead of the original bitmap s.
17
18 // It is sufficient to test red. Green and blue follow the same rules.
19 // This means we have at most 256*256 possible colors to deal with.
20 int hits[256*256];
21 for (size_t i = 0; i < SK_ARRAY_COUNT(hits); i++) {
22 hits[i] = 0;
23 }
24
25 for (int a = 0; a < 256; a++) {
26 for (int r = 0; r <= a; r++) {
27 SkPMColor pm = SkPackARGB32(a, r, 0, 0);
28 SkColor upm = SkUnPreMultiply::PMColorToColor(pm);
29
30 // ARGB -> AR
31 hits[upm >> 16]++;
32 }
33 }
34
35 for (size_t i = 0; i < SK_ARRAY_COUNT(hits); i++) {
36 REPORTER_ASSERT(reporter, hits[i] < 2);
37 }
38 }
OLDNEW
« no previous file with comments | « gyp/tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698