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

Side by Side Diff: tests/WritePixelsTest.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/TextureStorageAllocator.cpp ('k') | tools/VisualBench/VisualBench.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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 static void call_writepixels(SkCanvas* canvas) { 289 static void call_writepixels(SkCanvas* canvas) {
290 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); 290 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
291 SkPMColor pixel = 0; 291 SkPMColor pixel = 0;
292 canvas->writePixels(info, &pixel, sizeof(SkPMColor), 0, 0); 292 canvas->writePixels(info, &pixel, sizeof(SkPMColor), 0, 0);
293 } 293 }
294 294
295 DEF_TEST(WritePixelsSurfaceGenID, reporter) { 295 DEF_TEST(WritePixelsSurfaceGenID, reporter) {
296 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 296 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
297 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 297 auto surface(SkSurface::MakeRaster(info));
298 uint32_t genID1 = surface->generationID(); 298 uint32_t genID1 = surface->generationID();
299 call_writepixels(surface->getCanvas()); 299 call_writepixels(surface->getCanvas());
300 uint32_t genID2 = surface->generationID(); 300 uint32_t genID2 = surface->generationID();
301 REPORTER_ASSERT(reporter, genID1 != genID2); 301 REPORTER_ASSERT(reporter, genID1 != genID2);
302 } 302 }
303 303
304 static void test_write_pixels(skiatest::Reporter* reporter, SkSurface* surface) { 304 static void test_write_pixels(skiatest::Reporter* reporter, SkSurface* surface) {
305 const SkIRect testRects[] = { 305 const SkIRect testRects[] = {
306 // entire thing 306 // entire thing
307 DEV_RECT, 307 DEV_RECT,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 DEF_TEST(WritePixels, reporter) { 393 DEF_TEST(WritePixels, reporter) {
394 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); 394 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
395 for (auto& tightRowBytes : { true, false }) { 395 for (auto& tightRowBytes : { true, false }) {
396 const size_t rowBytes = tightRowBytes ? info.minRowBytes() : 4 * DEV_W + 100; 396 const size_t rowBytes = tightRowBytes ? info.minRowBytes() : 4 * DEV_W + 100;
397 const size_t size = info.getSafeSize(rowBytes); 397 const size_t size = info.getSafeSize(rowBytes);
398 void* pixels = sk_malloc_throw(size); 398 void* pixels = sk_malloc_throw(size);
399 // if rowBytes isn't tight then set the padding to a known value 399 // if rowBytes isn't tight then set the padding to a known value
400 if (!tightRowBytes) { 400 if (!tightRowBytes) {
401 memset(pixels, DEV_PAD, size); 401 memset(pixels, DEV_PAD, size);
402 } 402 }
403 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirectReleaseProc(in fo, pixels, rowBytes, free_pixels, nullptr)); 403 auto surface(SkSurface::MakeRasterDirectReleaseProc(info, pixels, rowByt es,
404 test_write_pixels(reporter, surface); 404 free_pixels, nullptr ));
405 test_write_pixels(reporter, surface.get());
405 } 406 }
406 } 407 }
407 #if SK_SUPPORT_GPU 408 #if SK_SUPPORT_GPU
408 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, context) { 409 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, context) {
409 for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { 410 for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
410 GrSurfaceDesc desc; 411 GrSurfaceDesc desc;
411 desc.fFlags = kRenderTarget_GrSurfaceFlag; 412 desc.fFlags = kRenderTarget_GrSurfaceFlag;
412 desc.fWidth = DEV_W; 413 desc.fWidth = DEV_W;
413 desc.fHeight = DEV_H; 414 desc.fHeight = DEV_H;
414 desc.fConfig = kSkia8888_GrPixelConfig; 415 desc.fConfig = kSkia8888_GrPixelConfig;
415 desc.fOrigin = origin; 416 desc.fOrigin = origin;
416 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTextur e(desc, 417 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTextur e(desc,
417 SkBudgeted::kNo)); 418 SkBudgeted::kNo));
418 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(texture ->asRenderTarget())); 419 auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget() ));
419 test_write_pixels(reporter, surface); 420 test_write_pixels(reporter, surface.get());
420 } 421 }
421 } 422 }
422 #endif 423 #endif
OLDNEW
« no previous file with comments | « tests/TextureStorageAllocator.cpp ('k') | tools/VisualBench/VisualBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698