blob: 50f55fd8f0abb62fe3849929687ff67357cbc15e [file] [log] [blame]
bsalomon@google.comc6980972011-11-02 19:57:21 +00001/*
2 * Copyright 2011 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
robertphillips@google.com73672252013-08-29 12:40:26 +00008#include "SkBitmapDevice.h"
bsalomon@google.comc6980972011-11-02 19:57:21 +00009#include "SkCanvas.h"
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000010#include "SkColorPriv.h"
reed@google.com4b163ed2012-08-07 21:35:13 +000011#include "SkMathPriv.h"
bsalomon@google.comc6980972011-11-02 19:57:21 +000012#include "SkRegion.h"
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000013#include "Test.h"
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000014
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000015#if SK_SUPPORT_GPU
bsalomon@google.com67b915d2013-02-04 16:13:32 +000016#include "GrContextFactory.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000017#include "SkGpuDevice.h"
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000018#endif
bsalomon@google.comc6980972011-11-02 19:57:21 +000019
bsalomon@google.comc6980972011-11-02 19:57:21 +000020static const int DEV_W = 100, DEV_H = 100;
21static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H);
rmistry@google.comd6176b02012-08-23 18:14:13 +000022static const SkRect DEV_RECT_S = SkRect::MakeWH(DEV_W * SK_Scalar1,
bsalomon@google.comc6980972011-11-02 19:57:21 +000023 DEV_H * SK_Scalar1);
24
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +000025static SkPMColor getCanvasColor(int x, int y) {
bsalomon@google.comc6980972011-11-02 19:57:21 +000026 SkASSERT(x >= 0 && x < DEV_W);
27 SkASSERT(y >= 0 && y < DEV_H);
bsalomon@google.com6850eab2011-11-03 20:29:47 +000028
29 U8CPU r = x;
30 U8CPU g = y;
31 U8CPU b = 0xc;
32
33 U8CPU a = 0xff;
bsalomon@google.comc4364992011-11-07 15:54:49 +000034 switch ((x+y) % 5) {
bsalomon@google.com6850eab2011-11-03 20:29:47 +000035 case 0:
36 a = 0xff;
37 break;
38 case 1:
39 a = 0x80;
40 break;
41 case 2:
42 a = 0xCC;
43 break;
44 case 4:
45 a = 0x01;
46 break;
47 case 3:
48 a = 0x00;
49 break;
50 }
51 return SkPremultiplyARGBInline(a, r, g, b);
bsalomon@google.comc6980972011-11-02 19:57:21 +000052}
rmistry@google.comd6176b02012-08-23 18:14:13 +000053
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +000054static SkPMColor getBitmapColor(int x, int y, int w) {
bsalomon@google.comc6980972011-11-02 19:57:21 +000055 int n = y * w + x;
bsalomon@google.com6850eab2011-11-03 20:29:47 +000056
bsalomon@google.comc6980972011-11-02 19:57:21 +000057 U8CPU b = n & 0xff;
58 U8CPU g = (n >> 8) & 0xff;
59 U8CPU r = (n >> 16) & 0xff;
60 return SkPackARGB32(0xff, r, g , b);
61}
62
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +000063static SkPMColor convertConfig8888ToPMColor(SkCanvas::Config8888 config8888,
64 uint32_t color,
65 bool* premul) {
bsalomon@google.com6850eab2011-11-03 20:29:47 +000066 const uint8_t* c = reinterpret_cast<uint8_t*>(&color);
67 U8CPU a,r,g,b;
bsalomon@google.comc4364992011-11-07 15:54:49 +000068 *premul = false;
bsalomon@google.com6850eab2011-11-03 20:29:47 +000069 switch (config8888) {
70 case SkCanvas::kNative_Premul_Config8888:
71 return color;
72 case SkCanvas::kNative_Unpremul_Config8888:
bsalomon@google.comc4364992011-11-07 15:54:49 +000073 *premul = true;
bsalomon@google.com6850eab2011-11-03 20:29:47 +000074 a = SkGetPackedA32(color);
75 r = SkGetPackedR32(color);
76 g = SkGetPackedG32(color);
77 b = SkGetPackedB32(color);
78 break;
79 case SkCanvas::kBGRA_Unpremul_Config8888:
bsalomon@google.comc4364992011-11-07 15:54:49 +000080 *premul = true; // fallthru
bsalomon@google.com6850eab2011-11-03 20:29:47 +000081 case SkCanvas::kBGRA_Premul_Config8888:
82 a = static_cast<U8CPU>(c[3]);
83 r = static_cast<U8CPU>(c[2]);
84 g = static_cast<U8CPU>(c[1]);
85 b = static_cast<U8CPU>(c[0]);
86 break;
87 case SkCanvas::kRGBA_Unpremul_Config8888:
bsalomon@google.comc4364992011-11-07 15:54:49 +000088 *premul = true; // fallthru
bsalomon@google.com6850eab2011-11-03 20:29:47 +000089 case SkCanvas::kRGBA_Premul_Config8888:
90 a = static_cast<U8CPU>(c[3]);
91 r = static_cast<U8CPU>(c[0]);
92 g = static_cast<U8CPU>(c[1]);
93 b = static_cast<U8CPU>(c[2]);
94 break;
bsalomon@google.comccaa0022012-09-25 19:55:07 +000095 default:
96 SkDEBUGFAIL("Unexpected Config8888");
97 return 0;
bsalomon@google.com6850eab2011-11-03 20:29:47 +000098 }
bsalomon@google.comc4364992011-11-07 15:54:49 +000099 if (*premul) {
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000100 r = SkMulDiv255Ceiling(r, a);
101 g = SkMulDiv255Ceiling(g, a);
102 b = SkMulDiv255Ceiling(b, a);
103 }
104 return SkPackARGB32(a, r, g, b);
105}
106
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000107static void fillCanvas(SkCanvas* canvas) {
bsalomon@google.comc6980972011-11-02 19:57:21 +0000108 static SkBitmap bmp;
109 if (bmp.isNull()) {
commit-bot@chromium.orgfa9e5fa2014-02-13 22:00:04 +0000110 SkDEBUGCODE(bool alloc =) bmp.allocN32Pixels(DEV_W, DEV_H);
bsalomon@google.comc6980972011-11-02 19:57:21 +0000111 SkASSERT(alloc);
112 SkAutoLockPixels alp(bmp);
113 intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
114 for (int y = 0; y < DEV_H; ++y) {
115 for (int x = 0; x < DEV_W; ++x) {
116 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp.rowBytes() + x * bmp.bytesPerPixel());
117 *pixel = getCanvasColor(x, y);
118 }
119 }
120 }
121 canvas->save();
122 canvas->setMatrix(SkMatrix::I());
123 canvas->clipRect(DEV_RECT_S, SkRegion::kReplace_Op);
124 SkPaint paint;
125 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
126 canvas->drawBitmap(bmp, 0, 0, &paint);
127 canvas->restore();
128}
rmistry@google.comd6176b02012-08-23 18:14:13 +0000129
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000130static void fillBitmap(SkBitmap* bitmap) {
bsalomon@google.comc6980972011-11-02 19:57:21 +0000131 SkASSERT(bitmap->lockPixelsAreWritable());
132 SkAutoLockPixels alp(*bitmap);
133 int w = bitmap->width();
134 int h = bitmap->height();
135 intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels());
136 for (int y = 0; y < h; ++y) {
137 for (int x = 0; x < w; ++x) {
138 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bitmap->rowBytes() + x * bitmap->bytesPerPixel());
sugoi@google.com54f0d1b2013-02-27 19:17:41 +0000139 *pixel = getBitmapColor(x, y, w);
bsalomon@google.comc6980972011-11-02 19:57:21 +0000140 }
141 }
142}
143
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000144static bool checkPixel(SkPMColor a, SkPMColor b, bool didPremulConversion) {
bsalomon@google.comc4364992011-11-07 15:54:49 +0000145 if (!didPremulConversion) {
146 return a == b;
147 }
148 int32_t aA = static_cast<int32_t>(SkGetPackedA32(a));
149 int32_t aR = static_cast<int32_t>(SkGetPackedR32(a));
150 int32_t aG = static_cast<int32_t>(SkGetPackedG32(a));
151 int32_t aB = SkGetPackedB32(a);
152
153 int32_t bA = static_cast<int32_t>(SkGetPackedA32(b));
154 int32_t bR = static_cast<int32_t>(SkGetPackedR32(b));
155 int32_t bG = static_cast<int32_t>(SkGetPackedG32(b));
156 int32_t bB = static_cast<int32_t>(SkGetPackedB32(b));
157
158 return aA == bA &&
159 SkAbs32(aR - bR) <= 1 &&
160 SkAbs32(aG - bG) <= 1 &&
161 SkAbs32(aB - bB) <= 1;
162}
163
bsalomon@google.comc6980972011-11-02 19:57:21 +0000164// checks the bitmap contains correct pixels after the readPixels
165// if the bitmap was prefilled with pixels it checks that these weren't
166// overwritten in the area outside the readPixels.
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000167static bool checkRead(skiatest::Reporter* reporter,
168 const SkBitmap& bitmap,
169 int x, int y,
170 bool checkCanvasPixels,
171 bool checkBitmapPixels,
172 SkCanvas::Config8888 config8888) {
bsalomon@google.comc6980972011-11-02 19:57:21 +0000173 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
174 SkASSERT(!bitmap.isNull());
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000175 SkASSERT(checkCanvasPixels || checkBitmapPixels);
rmistry@google.comd6176b02012-08-23 18:14:13 +0000176
bsalomon@google.comc6980972011-11-02 19:57:21 +0000177 int bw = bitmap.width();
178 int bh = bitmap.height();
179
180 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bw, bh);
181 SkIRect clippedSrcRect = DEV_RECT;
182 if (!clippedSrcRect.intersect(srcRect)) {
183 clippedSrcRect.setEmpty();
184 }
bsalomon@google.comc6980972011-11-02 19:57:21 +0000185 SkAutoLockPixels alp(bitmap);
186 intptr_t pixels = reinterpret_cast<intptr_t>(bitmap.getPixels());
187 for (int by = 0; by < bh; ++by) {
188 for (int bx = 0; bx < bw; ++bx) {
189 int devx = bx + srcRect.fLeft;
190 int devy = by + srcRect.fTop;
rmistry@google.comd6176b02012-08-23 18:14:13 +0000191
bsalomon@google.comc4364992011-11-07 15:54:49 +0000192 uint32_t pixel = *reinterpret_cast<SkPMColor*>(pixels + by * bitmap.rowBytes() + bx * bitmap.bytesPerPixel());
bsalomon@google.comc6980972011-11-02 19:57:21 +0000193
194 if (clippedSrcRect.contains(devx, devy)) {
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000195 if (checkCanvasPixels) {
196 SkPMColor canvasPixel = getCanvasColor(devx, devy);
bsalomon@google.comc4364992011-11-07 15:54:49 +0000197 bool didPremul;
198 SkPMColor pmPixel = convertConfig8888ToPMColor(config8888, pixel, &didPremul);
199 bool check;
200 REPORTER_ASSERT(reporter, check = checkPixel(pmPixel, canvasPixel, didPremul));
201 if (!check) {
bsalomon@google.com72f3dca2012-08-17 13:32:06 +0000202 return false;
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000203 }
bsalomon@google.comc6980972011-11-02 19:57:21 +0000204 }
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000205 } else if (checkBitmapPixels) {
sugoi@google.com54f0d1b2013-02-27 19:17:41 +0000206 REPORTER_ASSERT(reporter, getBitmapColor(bx, by, bw) == pixel);
207 if (getBitmapColor(bx, by, bw) != pixel) {
bsalomon@google.com72f3dca2012-08-17 13:32:06 +0000208 return false;
bsalomon@google.comc6980972011-11-02 19:57:21 +0000209 }
210 }
211 }
212 }
bsalomon@google.com72f3dca2012-08-17 13:32:06 +0000213 return true;
bsalomon@google.comc6980972011-11-02 19:57:21 +0000214}
215
216enum BitmapInit {
217 kFirstBitmapInit = 0,
rmistry@google.comd6176b02012-08-23 18:14:13 +0000218
bsalomon@google.comc6980972011-11-02 19:57:21 +0000219 kNoPixels_BitmapInit = kFirstBitmapInit,
220 kTight_BitmapInit,
221 kRowBytes_BitmapInit,
rmistry@google.comd6176b02012-08-23 18:14:13 +0000222
bsalomon@google.comc6980972011-11-02 19:57:21 +0000223 kBitmapInitCnt
224};
225
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000226static BitmapInit nextBMI(BitmapInit bmi) {
bsalomon@google.comc6980972011-11-02 19:57:21 +0000227 int x = bmi;
228 return static_cast<BitmapInit>(++x);
229}
230
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +0000231static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init) {
commit-bot@chromium.orgfa9e5fa2014-02-13 22:00:04 +0000232 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
233 size_t rowBytes = 0;
bsalomon@google.comc6980972011-11-02 19:57:21 +0000234 bool alloc = true;
235 switch (init) {
236 case kNoPixels_BitmapInit:
237 alloc = false;
238 case kTight_BitmapInit:
239 break;
240 case kRowBytes_BitmapInit:
commit-bot@chromium.orgfa9e5fa2014-02-13 22:00:04 +0000241 rowBytes = (info.width() + 16) * sizeof(SkPMColor);
bsalomon@google.comc6980972011-11-02 19:57:21 +0000242 break;
243 default:
244 SkASSERT(0);
245 break;
246 }
commit-bot@chromium.orgfa9e5fa2014-02-13 22:00:04 +0000247
bsalomon@google.comc6980972011-11-02 19:57:21 +0000248 if (alloc) {
commit-bot@chromium.orgfa9e5fa2014-02-13 22:00:04 +0000249 bitmap->allocPixels(info);
250 } else {
251 bitmap->setConfig(info, rowBytes);
bsalomon@google.comc6980972011-11-02 19:57:21 +0000252 }
253}
254
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +0000255DEF_GPUTEST(ReadPixels, reporter, factory) {
bsalomon@google.comc6980972011-11-02 19:57:21 +0000256 const SkIRect testRects[] = {
257 // entire thing
258 DEV_RECT,
259 // larger on all sides
260 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10),
261 // fully contained
262 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4),
263 // outside top left
264 SkIRect::MakeLTRB(-10, -10, -1, -1),
265 // touching top left corner
266 SkIRect::MakeLTRB(-10, -10, 0, 0),
267 // overlapping top left corner
268 SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H / 4),
269 // overlapping top left and top right corners
270 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H / 4),
271 // touching entire top edge
272 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, 0),
273 // overlapping top right corner
274 SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H / 4),
275 // contained in x, overlapping top edge
276 SkIRect::MakeLTRB(DEV_W / 4, -10, 3 * DEV_W / 4, DEV_H / 4),
277 // outside top right corner
278 SkIRect::MakeLTRB(DEV_W + 1, -10, DEV_W + 10, -1),
279 // touching top right corner
280 SkIRect::MakeLTRB(DEV_W, -10, DEV_W + 10, 0),
281 // overlapping top left and bottom left corners
282 SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H + 10),
283 // touching entire left edge
284 SkIRect::MakeLTRB(-10, -10, 0, DEV_H + 10),
285 // overlapping bottom left corner
286 SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W / 4, DEV_H + 10),
287 // contained in y, overlapping left edge
288 SkIRect::MakeLTRB(-10, DEV_H / 4, DEV_W / 4, 3 * DEV_H / 4),
289 // outside bottom left corner
290 SkIRect::MakeLTRB(-10, DEV_H + 1, -1, DEV_H + 10),
291 // touching bottom left corner
292 SkIRect::MakeLTRB(-10, DEV_H, 0, DEV_H + 10),
293 // overlapping bottom left and bottom right corners
294 SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
295 // touching entire left edge
296 SkIRect::MakeLTRB(0, DEV_H, DEV_W, DEV_H + 10),
297 // overlapping bottom right corner
298 SkIRect::MakeLTRB(3 * DEV_W / 4, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
299 // overlapping top right and bottom right corners
300 SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H + 10),
301 };
302
senorblanco@chromium.org3cb406b2013-02-05 19:50:46 +0000303 for (int dtype = 0; dtype < 3; ++dtype) {
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000304 int glCtxTypeCnt = 1;
305#if SK_SUPPORT_GPU
306 if (0 != dtype) {
307 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt;
bsalomon@google.comc6980972011-11-02 19:57:21 +0000308 }
djsollen@google.com8688e5b2012-01-09 13:02:20 +0000309#endif
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000310 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000311 SkAutoTUnref<SkBaseDevice> device;
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000312 if (0 == dtype) {
skia.committer@gmail.com772c4e62013-08-30 07:01:34 +0000313 device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000314 DEV_W, DEV_H, false));
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000315 } else {
316#if SK_SUPPORT_GPU
317 GrContextFactory::GLContextType type =
318 static_cast<GrContextFactory::GLContextType>(glCtxType);
319 if (!GrContextFactory::IsRenderingGLContext(type)) {
320 continue;
bsalomon@google.comc6980972011-11-02 19:57:21 +0000321 }
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000322 GrContext* context = factory->get(type);
323 if (NULL == context) {
324 continue;
325 }
senorblanco@chromium.org3cb406b2013-02-05 19:50:46 +0000326 GrTextureDesc desc;
327 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
328 desc.fWidth = DEV_W;
329 desc.fHeight = DEV_H;
bsalomon@google.comfec0bc32013-02-07 14:43:04 +0000330 desc.fConfig = kSkia8888_GrPixelConfig;
senorblanco@chromium.org3cb406b2013-02-05 19:50:46 +0000331 desc.fOrigin = 1 == dtype ? kBottomLeft_GrSurfaceOrigin
332 : kTopLeft_GrSurfaceOrigin;
333 GrAutoScratchTexture ast(context, desc, GrContext::kExact_ScratchTexMatch);
334 SkAutoTUnref<GrTexture> tex(ast.detach());
335 device.reset(new SkGpuDevice(context, tex));
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000336#else
337 continue;
338#endif
339 }
340 SkCanvas canvas(device);
341 fillCanvas(&canvas);
342
343 static const SkCanvas::Config8888 gReadConfigs[] = {
344 SkCanvas::kNative_Premul_Config8888,
345 SkCanvas::kNative_Unpremul_Config8888,
commit-bot@chromium.org28621512013-08-07 19:43:45 +0000346
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000347 SkCanvas::kBGRA_Premul_Config8888,
348 SkCanvas::kBGRA_Unpremul_Config8888,
commit-bot@chromium.org28621512013-08-07 19:43:45 +0000349
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000350 SkCanvas::kRGBA_Premul_Config8888,
351 SkCanvas::kRGBA_Unpremul_Config8888,
352 };
353 for (size_t rect = 0; rect < SK_ARRAY_COUNT(testRects); ++rect) {
354 const SkIRect& srcRect = testRects[rect];
355 for (BitmapInit bmi = kFirstBitmapInit;
356 bmi < kBitmapInitCnt;
357 bmi = nextBMI(bmi)) {
358 for (size_t c = 0; c < SK_ARRAY_COUNT(gReadConfigs); ++c) {
359 SkCanvas::Config8888 config8888 = gReadConfigs[c];
360 SkBitmap bmp;
361 init_bitmap(&bmp, srcRect, bmi);
362
363 // if the bitmap has pixels allocated before the readPixels,
364 // note that and fill them with pattern
365 bool startsWithPixels = !bmp.isNull();
366 if (startsWithPixels) {
367 fillBitmap(&bmp);
368 }
369 uint32_t idBefore = canvas.getDevice()->accessBitmap(false).getGenerationID();
370 bool success =
371 canvas.readPixels(&bmp, srcRect.fLeft,
372 srcRect.fTop, config8888);
373 uint32_t idAfter = canvas.getDevice()->accessBitmap(false).getGenerationID();
374
375 // we expect to succeed when the read isn't fully clipped
376 // out.
377 bool expectSuccess = SkIRect::Intersects(srcRect, DEV_RECT);
378 // determine whether we expected the read to succeed.
379 REPORTER_ASSERT(reporter, success == expectSuccess);
380 // read pixels should never change the gen id
381 REPORTER_ASSERT(reporter, idBefore == idAfter);
382
383 if (success || startsWithPixels) {
384 checkRead(reporter, bmp, srcRect.fLeft, srcRect.fTop,
385 success, startsWithPixels, config8888);
386 } else {
387 // if we had no pixels beforehand and the readPixels
388 // failed then our bitmap should still not have pixels
389 REPORTER_ASSERT(reporter, bmp.isNull());
390 }
391 }
392 // check the old webkit version of readPixels that clips the
393 // bitmap size
394 SkBitmap wkbmp;
395 bool success = canvas.readPixels(srcRect, &wkbmp);
396 SkIRect clippedRect = DEV_RECT;
397 if (clippedRect.intersect(srcRect)) {
398 REPORTER_ASSERT(reporter, success);
399 checkRead(reporter, wkbmp, clippedRect.fLeft,
400 clippedRect.fTop, true, false,
401 SkCanvas::kNative_Premul_Config8888);
402 } else {
403 REPORTER_ASSERT(reporter, !success);
404 }
bsalomon@google.comc6980972011-11-02 19:57:21 +0000405 }
406 }
407 }
408 }
409}