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

Side by Side Diff: tests/ReadPixelsTest.cpp

Issue 2187573002: Reduce usage of MakeRenderTargetDirect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up 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
« no previous file with comments | « tests/DeviceTest.cpp ('k') | tests/ReadWriteAlphaTest.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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 } 381 }
382 DEF_TEST(ReadPixels, reporter) { 382 DEF_TEST(ReadPixels, reporter) {
383 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); 383 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
384 auto surface(SkSurface::MakeRaster(info)); 384 auto surface(SkSurface::MakeRaster(info));
385 // SW readback fails a premul check when reading back to an unaligned rowbyt es. 385 // SW readback fails a premul check when reading back to an unaligned rowbyt es.
386 test_readpixels(reporter, surface, kLastAligned_BitmapInit); 386 test_readpixels(reporter, surface, kLastAligned_BitmapInit);
387 } 387 }
388 #if SK_SUPPORT_GPU 388 #if SK_SUPPORT_GPU
389 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) { 389 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) {
390 const SkImageInfo ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
390 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) { 391 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
391 GrSurfaceDesc desc; 392 sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctxInfo.grContext() , SkBudgeted::kNo,
392 desc.fFlags = kRenderTarget_GrSurfaceFlag; 393 ii, 0, origin, null ptr));
393 desc.fWidth = DEV_W;
394 desc.fHeight = DEV_H;
395 desc.fConfig = kSkia8888_GrPixelConfig;
396 desc.fOrigin = origin;
397 SkAutoTUnref<GrTexture> surfaceTexture(
398 ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudget ed::kNo));
399 auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderT arget(), nullptr));
400 desc.fFlags = kNone_GrSurfaceFlags;
401 test_readpixels(reporter, surface, kLast_BitmapInit); 394 test_readpixels(reporter, surface, kLast_BitmapInit);
402 } 395 }
403 } 396 }
404 #endif 397 #endif
405 398
406 #if SK_SUPPORT_GPU 399 #if SK_SUPPORT_GPU
407 static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex ture) { 400 static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex ture) {
408 fill_src_texture(texture); 401 fill_src_texture(texture);
409 for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) { 402 for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
410 const SkIRect& srcRect = gReadPixelsTestRects[rect]; 403 const SkIRect& srcRect = gReadPixelsTestRects[rect];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 desc.fHeight = DEV_H; 444 desc.fHeight = DEV_H;
452 desc.fConfig = kSkia8888_GrPixelConfig; 445 desc.fConfig = kSkia8888_GrPixelConfig;
453 desc.fOrigin = origin; 446 desc.fOrigin = origin;
454 desc.fFlags = kNone_GrSurfaceFlags; 447 desc.fFlags = kNone_GrSurfaceFlags;
455 texture.reset(ctxInfo.grContext()->textureProvider()->createTexture(desc , 448 texture.reset(ctxInfo.grContext()->textureProvider()->createTexture(desc ,
456 SkBu dgeted::kNo)); 449 SkBu dgeted::kNo));
457 test_readpixels_texture(reporter, texture); 450 test_readpixels_texture(reporter, texture);
458 } 451 }
459 } 452 }
460 #endif 453 #endif
OLDNEW
« no previous file with comments | « tests/DeviceTest.cpp ('k') | tests/ReadWriteAlphaTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698