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

Side by Side Diff: tests/WritePixelsTest.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) 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/TileGridTest.cpp ('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
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 8
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 SkAbs32(aR - bR) <= 1 && 220 SkAbs32(aR - bR) <= 1 &&
221 SkAbs32(aG - bG) <= 1 && 221 SkAbs32(aG - bG) <= 1 &&
222 SkAbs32(aB - bB) <= 1; 222 SkAbs32(aB - bB) <= 1;
223 } 223 }
224 224
225 bool checkWrite(skiatest::Reporter* reporter, 225 bool checkWrite(skiatest::Reporter* reporter,
226 SkCanvas* canvas, 226 SkCanvas* canvas,
227 const SkBitmap& bitmap, 227 const SkBitmap& bitmap,
228 int writeX, int writeY, 228 int writeX, int writeY,
229 SkCanvas::Config8888 config8888) { 229 SkCanvas::Config8888 config8888) {
230 SkDevice* dev = canvas->getDevice(); 230 SkBaseDevice* dev = canvas->getDevice();
231 if (!dev) { 231 if (!dev) {
232 return false; 232 return false;
233 } 233 }
234 SkBitmap devBmp = dev->accessBitmap(false); 234 SkBitmap devBmp = dev->accessBitmap(false);
235 if (devBmp.width() != DEV_W || 235 if (devBmp.width() != DEV_W ||
236 devBmp.height() != DEV_H || 236 devBmp.height() != DEV_H ||
237 devBmp.config() != SkBitmap::kARGB_8888_Config || 237 devBmp.config() != SkBitmap::kARGB_8888_Config ||
238 devBmp.isNull()) { 238 devBmp.isNull()) {
239 return false; 239 return false;
240 } 240 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 static const CanvasConfig gCanvasConfigs[] = { 299 static const CanvasConfig gCanvasConfigs[] = {
300 {kRaster_DevType, true}, 300 {kRaster_DevType, true},
301 {kRaster_DevType, false}, 301 {kRaster_DevType, false},
302 #if SK_SUPPORT_GPU && defined(SK_SCALAR_IS_FLOAT) 302 #if SK_SUPPORT_GPU && defined(SK_SCALAR_IS_FLOAT)
303 {kGpu_BottomLeft_DevType, true}, // row bytes has no meaning on gpu devices 303 {kGpu_BottomLeft_DevType, true}, // row bytes has no meaning on gpu devices
304 {kGpu_TopLeft_DevType, true}, // row bytes has no meaning on gpu devices 304 {kGpu_TopLeft_DevType, true}, // row bytes has no meaning on gpu devices
305 #endif 305 #endif
306 }; 306 };
307 307
308 SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) { 308 SkBaseDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
309 switch (c.fDevType) { 309 switch (c.fDevType) {
310 case kRaster_DevType: { 310 case kRaster_DevType: {
311 SkBitmap bmp; 311 SkBitmap bmp;
312 size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100; 312 size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100;
313 bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes); 313 bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes);
314 if (!bmp.allocPixels()) { 314 if (!bmp.allocPixels()) {
315 sk_throw(); 315 sk_throw();
316 return NULL; 316 return NULL;
317 } 317 }
318 // if rowBytes isn't tight then set the padding to a known value 318 // if rowBytes isn't tight then set the padding to a known value
319 if (rowBytes) { 319 if (rowBytes) {
320 SkAutoLockPixels alp(bmp); 320 SkAutoLockPixels alp(bmp);
321 memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize()); 321 memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize());
322 } 322 }
323 return new SkDevice(bmp); 323 return new SkBitmapDevice(bmp);
324 } 324 }
325 #if SK_SUPPORT_GPU 325 #if SK_SUPPORT_GPU
326 case kGpu_BottomLeft_DevType: 326 case kGpu_BottomLeft_DevType:
327 case kGpu_TopLeft_DevType: 327 case kGpu_TopLeft_DevType:
328 GrTextureDesc desc; 328 GrTextureDesc desc;
329 desc.fFlags = kRenderTarget_GrTextureFlagBit; 329 desc.fFlags = kRenderTarget_GrTextureFlagBit;
330 desc.fWidth = DEV_W; 330 desc.fWidth = DEV_W;
331 desc.fHeight = DEV_H; 331 desc.fHeight = DEV_H;
332 desc.fConfig = kSkia8888_GrPixelConfig; 332 desc.fConfig = kSkia8888_GrPixelConfig;
333 desc.fOrigin = kGpu_TopLeft_DevType == c.fDevType ? 333 desc.fOrigin = kGpu_TopLeft_DevType == c.fDevType ?
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 if (!GrContextFactory::IsRenderingGLContext(type)) { 428 if (!GrContextFactory::IsRenderingGLContext(type)) {
429 continue; 429 continue;
430 } 430 }
431 context = factory->get(type); 431 context = factory->get(type);
432 if (NULL == context) { 432 if (NULL == context) {
433 continue; 433 continue;
434 } 434 }
435 } 435 }
436 #endif 436 #endif
437 437
438 SkAutoTUnref<SkDevice> device(createDevice(gCanvasConfigs[i], contex t)); 438 SkAutoTUnref<SkBaseDevice> device(createDevice(gCanvasConfigs[i], co ntext));
439 SkCanvas canvas(device); 439 SkCanvas canvas(device);
440 440
441 static const SkCanvas::Config8888 gSrcConfigs[] = { 441 static const SkCanvas::Config8888 gSrcConfigs[] = {
442 SkCanvas::kNative_Premul_Config8888, 442 SkCanvas::kNative_Premul_Config8888,
443 SkCanvas::kNative_Unpremul_Config8888, 443 SkCanvas::kNative_Unpremul_Config8888,
444 SkCanvas::kBGRA_Premul_Config8888, 444 SkCanvas::kBGRA_Premul_Config8888,
445 SkCanvas::kBGRA_Unpremul_Config8888, 445 SkCanvas::kBGRA_Unpremul_Config8888,
446 SkCanvas::kRGBA_Premul_Config8888, 446 SkCanvas::kRGBA_Premul_Config8888,
447 SkCanvas::kRGBA_Unpremul_Config8888, 447 SkCanvas::kRGBA_Unpremul_Config8888,
448 }; 448 };
(...skipping 19 matching lines...) Expand all
468 } 468 }
469 } 469 }
470 } 470 }
471 } 471 }
472 } 472 }
473 } 473 }
474 } 474 }
475 475
476 #include "TestClassDef.h" 476 #include "TestClassDef.h"
477 DEFINE_GPUTESTCLASS("WritePixels", WritePixelsTestClass, WritePixelsTest) 477 DEFINE_GPUTESTCLASS("WritePixels", WritePixelsTestClass, WritePixelsTest)
OLDNEW
« no previous file with comments | « tests/TileGridTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698