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

Side by Side Diff: tests/ColorTest.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/ColorFilterTest.cpp ('k') | tests/DrawBitmapRectTest.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 } 140 }
141 141
142 /** 142 /**
143 This test fails: SkFourByteInterp does *not* preserve opaque destinations. 143 This test fails: SkFourByteInterp does *not* preserve opaque destinations.
144 SkAlpha255To256 implemented as (alpha + 1) is faster than 144 SkAlpha255To256 implemented as (alpha + 1) is faster than
145 (alpha + (alpha >> 7)), but inaccurate, and Skia intends to phase it out. 145 (alpha + (alpha >> 7)), but inaccurate, and Skia intends to phase it out.
146 */ 146 */
147 /* 147 /*
148 static void test_interp(skiatest::Reporter* reporter) { 148 static void test_interp(skiatest::Reporter* reporter) {
149 SkMWCRandom r; 149 SkRandom r;
150 150
151 U8CPU a0 = 0; 151 U8CPU a0 = 0;
152 U8CPU a255 = 255; 152 U8CPU a255 = 255;
153 for (int i = 0; i < 200; i++) { 153 for (int i = 0; i < 200; i++) {
154 SkColor colorSrc = r.nextU(); 154 SkColor colorSrc = r.nextU();
155 SkColor colorDst = r.nextU(); 155 SkColor colorDst = r.nextU();
156 SkPMColor src = SkPreMultiplyColor(colorSrc); 156 SkPMColor src = SkPreMultiplyColor(colorSrc);
157 SkPMColor dst = SkPreMultiplyColor(colorDst); 157 SkPMColor dst = SkPreMultiplyColor(colorDst);
158 158
159 REPORTER_ASSERT(reporter, SkFourByteInterp(src, dst, a0) == dst); 159 REPORTER_ASSERT(reporter, SkFourByteInterp(src, dst, a0) == dst);
160 REPORTER_ASSERT(reporter, SkFourByteInterp(src, dst, a255) == src); 160 REPORTER_ASSERT(reporter, SkFourByteInterp(src, dst, a255) == src);
161 } 161 }
162 } 162 }
163 */ 163 */
164 164
165 static inline void test_fast_interp(skiatest::Reporter* reporter) { 165 static inline void test_fast_interp(skiatest::Reporter* reporter) {
166 SkMWCRandom r; 166 SkRandom r;
167 167
168 U8CPU a0 = 0; 168 U8CPU a0 = 0;
169 U8CPU a255 = 255; 169 U8CPU a255 = 255;
170 for (int i = 0; i < 200; i++) { 170 for (int i = 0; i < 200; i++) {
171 SkColor colorSrc = r.nextU(); 171 SkColor colorSrc = r.nextU();
172 SkColor colorDst = r.nextU(); 172 SkColor colorDst = r.nextU();
173 SkPMColor src = SkPreMultiplyColor(colorSrc); 173 SkPMColor src = SkPreMultiplyColor(colorSrc);
174 SkPMColor dst = SkPreMultiplyColor(colorDst); 174 SkPMColor dst = SkPreMultiplyColor(colorDst);
175 175
176 REPORTER_ASSERT(reporter, SkFastFourByteInterp(src, dst, a0) == dst); 176 REPORTER_ASSERT(reporter, SkFastFourByteInterp(src, dst, a0) == dst);
177 REPORTER_ASSERT(reporter, SkFastFourByteInterp(src, dst, a255) == src); 177 REPORTER_ASSERT(reporter, SkFastFourByteInterp(src, dst, a255) == src);
178 } 178 }
179 } 179 }
180 180
181 static void TestColor(skiatest::Reporter* reporter) { 181 static void TestColor(skiatest::Reporter* reporter) {
182 test_premul(reporter); 182 test_premul(reporter);
183 //test_interp(reporter); 183 //test_interp(reporter);
184 test_fast_interp(reporter); 184 test_fast_interp(reporter);
185 // test_565blend(); 185 // test_565blend();
186 } 186 }
187 187
188 #include "TestClassDef.h" 188 #include "TestClassDef.h"
189 DEFINE_TESTCLASS("Color", ColorTestClass, TestColor) 189 DEFINE_TESTCLASS("Color", ColorTestClass, TestColor)
OLDNEW
« no previous file with comments | « tests/ColorFilterTest.cpp ('k') | tests/DrawBitmapRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698