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

Side by Side Diff: tests/WritePixelsTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 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
« no previous file with comments | « tests/WArrayTest.cpp ('k') | tests/Writer32Test.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 * 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkMathPriv.h" 10 #include "SkMathPriv.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Can't use canvas->peekPixels(), as we are trying to look at GPU pixels so metimes as well. 193 // Can't use canvas->peekPixels(), as we are trying to look at GPU pixels so metimes as well.
194 // At some point this will be unsupported, as we won't allow accessBitmap() to magically call 194 // At some point this will be unsupported, as we won't allow accessBitmap() to magically call
195 // readPixels for the client. 195 // readPixels for the client.
196 SkBitmap secretDevBitmap; 196 SkBitmap secretDevBitmap;
197 canvas->readPixels(canvasInfo.bounds(), &secretDevBitmap); 197 canvas->readPixels(canvasInfo.bounds(), &secretDevBitmap);
198 198
199 SkAutoLockPixels alp(secretDevBitmap); 199 SkAutoLockPixels alp(secretDevBitmap);
200 canvasRowBytes = secretDevBitmap.rowBytes(); 200 canvasRowBytes = secretDevBitmap.rowBytes();
201 canvasPixels = static_cast<const uint32_t*>(secretDevBitmap.getPixels()); 201 canvasPixels = static_cast<const uint32_t*>(secretDevBitmap.getPixels());
202 202
203 if (NULL == canvasPixels) { 203 if (nullptr == canvasPixels) {
204 return false; 204 return false;
205 } 205 }
206 206
207 if (canvasInfo.width() != DEV_W || 207 if (canvasInfo.width() != DEV_W ||
208 canvasInfo.height() != DEV_H || 208 canvasInfo.height() != DEV_H ||
209 canvasInfo.colorType() != kN32_SkColorType) { 209 canvasInfo.colorType() != kN32_SkColorType) {
210 return false; 210 return false;
211 } 211 }
212 212
213 const SkImageInfo bmInfo = bitmap.info(); 213 const SkImageInfo bmInfo = bitmap.info();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 #include "SkMallocPixelRef.h" 279 #include "SkMallocPixelRef.h"
280 280
281 // This is a tricky pattern, because we have to setConfig+rowBytes AND specify 281 // This is a tricky pattern, because we have to setConfig+rowBytes AND specify
282 // a custom pixelRef (which also has to specify its rowBytes), so we have to be 282 // a custom pixelRef (which also has to specify its rowBytes), so we have to be
283 // sure that the two rowBytes match (and the infos match). 283 // sure that the two rowBytes match (and the infos match).
284 // 284 //
285 static bool alloc_row_bytes(SkBitmap* bm, const SkImageInfo& info, size_t rowByt es) { 285 static bool alloc_row_bytes(SkBitmap* bm, const SkImageInfo& info, size_t rowByt es) {
286 if (!bm->setInfo(info, rowBytes)) { 286 if (!bm->setInfo(info, rowBytes)) {
287 return false; 287 return false;
288 } 288 }
289 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, rowBytes, NULL); 289 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, rowBytes, nullptr);
290 bm->setPixelRef(pr)->unref(); 290 bm->setPixelRef(pr)->unref();
291 return true; 291 return true;
292 } 292 }
293 293
294 static void free_pixels(void* pixels, void* ctx) { 294 static void free_pixels(void* pixels, void* ctx) {
295 sk_free(pixels); 295 sk_free(pixels);
296 } 296 }
297 297
298 static SkSurface* create_surface(const CanvasConfig& c, GrContext* grCtx) { 298 static SkSurface* create_surface(const CanvasConfig& c, GrContext* grCtx) {
299 SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); 299 SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
300 switch (c.fDevType) { 300 switch (c.fDevType) {
301 case kRaster_DevType: { 301 case kRaster_DevType: {
302 const size_t rowBytes = c.fTightRowBytes ? info.minRowBytes() : 4 * DEV_W + 100; 302 const size_t rowBytes = c.fTightRowBytes ? info.minRowBytes() : 4 * DEV_W + 100;
303 const size_t size = info.getSafeSize(rowBytes); 303 const size_t size = info.getSafeSize(rowBytes);
304 void* pixels = sk_malloc_throw(size); 304 void* pixels = sk_malloc_throw(size);
305 // if rowBytes isn't tight then set the padding to a known value 305 // if rowBytes isn't tight then set the padding to a known value
306 if (!c.fTightRowBytes) { 306 if (!c.fTightRowBytes) {
307 memset(pixels, DEV_PAD, size); 307 memset(pixels, DEV_PAD, size);
308 } 308 }
309 return SkSurface::NewRasterDirectReleaseProc(info, pixels, rowBytes, free_pixels, NULL); 309 return SkSurface::NewRasterDirectReleaseProc(info, pixels, rowBytes, free_pixels, nullptr);
310 } 310 }
311 #if SK_SUPPORT_GPU 311 #if SK_SUPPORT_GPU
312 case kGpu_BottomLeft_DevType: 312 case kGpu_BottomLeft_DevType:
313 case kGpu_TopLeft_DevType: 313 case kGpu_TopLeft_DevType:
314 GrSurfaceDesc desc; 314 GrSurfaceDesc desc;
315 desc.fFlags = kRenderTarget_GrSurfaceFlag; 315 desc.fFlags = kRenderTarget_GrSurfaceFlag;
316 desc.fWidth = DEV_W; 316 desc.fWidth = DEV_W;
317 desc.fHeight = DEV_H; 317 desc.fHeight = DEV_H;
318 desc.fConfig = kSkia8888_GrPixelConfig; 318 desc.fConfig = kSkia8888_GrPixelConfig;
319 desc.fOrigin = kGpu_TopLeft_DevType == c.fDevType ? 319 desc.fOrigin = kGpu_TopLeft_DevType == c.fDevType ?
320 kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; 320 kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
321 SkAutoTUnref<GrTexture> texture(grCtx->textureProvider()->createText ure(desc, false)); 321 SkAutoTUnref<GrTexture> texture(grCtx->textureProvider()->createText ure(desc, false));
322 return SkSurface::NewRenderTargetDirect(texture->asRenderTarget()); 322 return SkSurface::NewRenderTargetDirect(texture->asRenderTarget());
323 #endif 323 #endif
324 } 324 }
325 return NULL; 325 return nullptr;
326 } 326 }
327 327
328 static bool setup_bitmap(SkBitmap* bm, SkColorType ct, SkAlphaType at, int w, in t h, int tightRB) { 328 static bool setup_bitmap(SkBitmap* bm, SkColorType ct, SkAlphaType at, int w, in t h, int tightRB) {
329 size_t rowBytes = tightRB ? 0 : 4 * w + 60; 329 size_t rowBytes = tightRB ? 0 : 4 * w + 60;
330 SkImageInfo info = SkImageInfo::Make(w, h, ct, at); 330 SkImageInfo info = SkImageInfo::Make(w, h, ct, at);
331 if (!alloc_row_bytes(bm, info, rowBytes)) { 331 if (!alloc_row_bytes(bm, info, rowBytes)) {
332 return false; 332 return false;
333 } 333 }
334 SkAutoLockPixels alp(*bm); 334 SkAutoLockPixels alp(*bm);
335 for (int y = 0; y < h; ++y) { 335 for (int y = 0; y < h; ++y) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) { 410 for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) {
411 int glCtxTypeCnt = 1; 411 int glCtxTypeCnt = 1;
412 #if SK_SUPPORT_GPU 412 #if SK_SUPPORT_GPU
413 bool isGPUDevice = kGpu_TopLeft_DevType == gCanvasConfigs[i].fDevType || 413 bool isGPUDevice = kGpu_TopLeft_DevType == gCanvasConfigs[i].fDevType ||
414 kGpu_BottomLeft_DevType == gCanvasConfigs[i].fDevType ; 414 kGpu_BottomLeft_DevType == gCanvasConfigs[i].fDevType ;
415 if (isGPUDevice) { 415 if (isGPUDevice) {
416 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; 416 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt;
417 } 417 }
418 #endif 418 #endif
419 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { 419 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
420 GrContext* context = NULL; 420 GrContext* context = nullptr;
421 #if SK_SUPPORT_GPU 421 #if SK_SUPPORT_GPU
422 if (isGPUDevice) { 422 if (isGPUDevice) {
423 GrContextFactory::GLContextType type = 423 GrContextFactory::GLContextType type =
424 static_cast<GrContextFactory::GLContextType>(glCtxType); 424 static_cast<GrContextFactory::GLContextType>(glCtxType);
425 if (!GrContextFactory::IsRenderingGLContext(type)) { 425 if (!GrContextFactory::IsRenderingGLContext(type)) {
426 continue; 426 continue;
427 } 427 }
428 context = factory->get(type); 428 context = factory->get(type);
429 if (NULL == context) { 429 if (nullptr == context) {
430 continue; 430 continue;
431 } 431 }
432 } 432 }
433 #endif 433 #endif
434 434
435 SkAutoTUnref<SkSurface> surface(create_surface(gCanvasConfigs[i], co ntext)); 435 SkAutoTUnref<SkSurface> surface(create_surface(gCanvasConfigs[i], co ntext));
436 SkCanvas& canvas = *surface->getCanvas(); 436 SkCanvas& canvas = *surface->getCanvas();
437 437
438 static const struct { 438 static const struct {
439 SkColorType fColorType; 439 SkColorType fColorType;
(...skipping 29 matching lines...) Expand all
469 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top, 469 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top,
470 bmp.width(), bmp.h eight()); 470 bmp.width(), bmp.h eight());
471 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ; 471 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ;
472 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter)); 472 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter));
473 } 473 }
474 } 474 }
475 } 475 }
476 } 476 }
477 } 477 }
478 } 478 }
OLDNEW
« no previous file with comments | « tests/WArrayTest.cpp ('k') | tests/Writer32Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698