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

Side by Side Diff: tests/BlitRowTest.cpp

Issue 2195893002: Always return ImageShader, even from SkShader::MakeBitmapShader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update serialize-8888 ignore list: skbug.com/5595 Created 4 years, 4 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
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 static void test_diagonal(skiatest::Reporter* reporter) { 188 static void test_diagonal(skiatest::Reporter* reporter) {
189 static const int W = 64; 189 static const int W = 64;
190 static const int H = W; 190 static const int H = W;
191 191
192 static const SkColorType gDstColorType[] = { 192 static const SkColorType gDstColorType[] = {
193 kN32_SkColorType, 193 kN32_SkColorType,
194 kRGB_565_SkColorType, 194 kRGB_565_SkColorType,
195 }; 195 };
196 196
197 static const SkColor gDstBG[] = { 0, 0xFFFFFFFF }; 197 static const SkColor gDstBG[] = { 0, 0xFFFFFFFF };
198 198 const SkRect srcR = SkRect::MakeIWH(W, H);
199 SkPaint paint;
200 199
201 SkBitmap srcBM; 200 SkBitmap srcBM;
202 srcBM.allocN32Pixels(W, H); 201 srcBM.allocN32Pixels(W, H);
203 SkRect srcR = { 202 SkImageInfo info = SkImageInfo::Make(W, H, kUnknown_SkColorType, kPremul_SkA lphaType);
204 0, 0, SkIntToScalar(srcBM.width()), SkIntToScalar(srcBM.height()) };
205
206 // cons up a mesh to draw the bitmap with
207 Mesh mesh(srcBM, &paint);
208
209 SkImageInfo info = SkImageInfo::Make(W, H, kUnknown_SkColorType,
210 kPremul_SkAlphaType);
211 203
212 for (size_t i = 0; i < SK_ARRAY_COUNT(gDstColorType); i++) { 204 for (size_t i = 0; i < SK_ARRAY_COUNT(gDstColorType); i++) {
213 info = info.makeColorType(gDstColorType[i]); 205 info = info.makeColorType(gDstColorType[i]);
214 206
215 SkBitmap dstBM0, dstBM1; 207 SkBitmap dstBM0, dstBM1;
216 dstBM0.allocPixels(info); 208 dstBM0.allocPixels(info);
217 dstBM1.allocPixels(info); 209 dstBM1.allocPixels(info);
218 210
219 SkCanvas canvas0(dstBM0); 211 SkCanvas canvas0(dstBM0);
220 SkCanvas canvas1(dstBM1); 212 SkCanvas canvas1(dstBM1);
221 SkColor bgColor; 213 SkColor bgColor;
222 214
223 for (size_t j = 0; j < SK_ARRAY_COUNT(gDstBG); j++) { 215 for (size_t j = 0; j < SK_ARRAY_COUNT(gDstBG); j++) {
224 bgColor = gDstBG[j]; 216 bgColor = gDstBG[j];
225 217
226 for (int c = 0; c <= 0xFF; c++) { 218 for (int c = 0; c <= 0xFF; c++) {
219 // cons up a mesh to draw the bitmap with
220 SkPaint paint;
227 srcBM.eraseARGB(0xFF, c, c, c); 221 srcBM.eraseARGB(0xFF, c, c, c);
222 Mesh mesh(srcBM, &paint);
228 223
229 for (int k = 0; k < 4; k++) { 224 for (int k = 0; k < 4; k++) {
230 bool dither = (k & 1) != 0; 225 bool dither = (k & 1) != 0;
231 uint8_t alpha = (k & 2) ? 0x80 : 0xFF; 226 uint8_t alpha = (k & 2) ? 0x80 : 0xFF;
232 paint.setDither(dither); 227 paint.setDither(dither);
233 paint.setAlpha(alpha); 228 paint.setAlpha(alpha);
234 229
235 dstBM0.eraseColor(bgColor); 230 dstBM0.eraseColor(bgColor);
236 dstBM1.eraseColor(bgColor); 231 dstBM1.eraseColor(bgColor);
237 232
(...skipping 15 matching lines...) Expand all
253 } 248 }
254 } 249 }
255 } 250 }
256 } 251 }
257 } 252 }
258 253
259 DEF_TEST(BlitRow, reporter) { 254 DEF_TEST(BlitRow, reporter) {
260 test_00_FF(reporter); 255 test_00_FF(reporter);
261 test_diagonal(reporter); 256 test_diagonal(reporter);
262 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698