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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 17084012: Fixes for unpremul decode. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // bitmap at (i, j). 116 // bitmap at (i, j).
117 const SkPMColor c1 = premultiply_unpmcolor(*bm8888Unpremul.getAddr32 (i, j)); 117 const SkPMColor c1 = premultiply_unpmcolor(*bm8888Unpremul.getAddr32 (i, j));
118 // Compute the difference for each component. 118 // Compute the difference for each component.
119 int da = SkAbs32(SkGetPackedA32(c0) - SkGetPackedA32(c1)); 119 int da = SkAbs32(SkGetPackedA32(c0) - SkGetPackedA32(c1));
120 int dr = SkAbs32(SkGetPackedR32(c0) - SkGetPackedR32(c1)); 120 int dr = SkAbs32(SkGetPackedR32(c0) - SkGetPackedR32(c1));
121 int dg = SkAbs32(SkGetPackedG32(c0) - SkGetPackedG32(c1)); 121 int dg = SkAbs32(SkGetPackedG32(c0) - SkGetPackedG32(c1));
122 int db = SkAbs32(SkGetPackedB32(c0) - SkGetPackedB32(c1)); 122 int db = SkAbs32(SkGetPackedB32(c0) - SkGetPackedB32(c1));
123 123
124 // Alpha component must be exactly the same. 124 // Alpha component must be exactly the same.
125 REPORTER_ASSERT(reporter, 0 == da); 125 REPORTER_ASSERT(reporter, 0 == da);
126 // Other components may differ if rounding is done differently, 126
127 // but currently that is not the case. If an image fails here 127 // Color components may not match exactly due to rounding error.
128 // in the future, we can change these to account for differences. 128 REPORTER_ASSERT(reporter, dr <= 1);
129 REPORTER_ASSERT(reporter, 0 == dr); 129 REPORTER_ASSERT(reporter, dg <= 1);
130 REPORTER_ASSERT(reporter, 0 == dg); 130 REPORTER_ASSERT(reporter, db <= 1);
131 REPORTER_ASSERT(reporter, 0 == db);
132 } 131 }
133 } 132 }
134 } 133 }
135 134
136 static void test_imageDecodingTests(skiatest::Reporter* reporter) { 135 static void test_imageDecodingTests(skiatest::Reporter* reporter) {
137 // This test cannot run if there is no resource path. 136 // This test cannot run if there is no resource path.
138 SkString resourcePath = skiatest::Test::GetResourcePath(); 137 SkString resourcePath = skiatest::Test::GetResourcePath();
139 if (resourcePath.isEmpty()) { 138 if (resourcePath.isEmpty()) {
140 return; 139 return;
141 } 140 }
142 SkOSFile::Iter iter(resourcePath.c_str()); 141 SkOSFile::Iter iter(resourcePath.c_str());
143 SkString basename; 142 SkString basename;
144 if (iter.next(&basename)) { 143 if (iter.next(&basename)) {
145 do { 144 do {
146 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basen ame.c_str()); 145 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basen ame.c_str());
147 //SkDebugf("about to decode \"%s\"\n", filename.c_str()); 146 //SkDebugf("about to decode \"%s\"\n", filename.c_str());
148 compare_unpremul(reporter, filename); 147 compare_unpremul(reporter, filename);
149 } while (iter.next(&basename)); 148 } while (iter.next(&basename));
150 } else { 149 } else {
151 SkDebugf("Failed to find any files :(\n"); 150 SkDebugf("Failed to find any files :(\n");
152 } 151 }
153 } 152 }
154 153
155 #include "TestClassDef.h" 154 #include "TestClassDef.h"
156 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass, 155 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass,
157 test_imageDecodingTests) 156 test_imageDecodingTests)
OLDNEW
« src/ports/SkImageDecoder_CG.cpp ('K') | « src/ports/SkImageDecoder_CG.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698