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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1885623002: Make more unit tests run on Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 <functional> 8 #include <functional>
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 for (auto& handle_access_func : 293 for (auto& handle_access_func :
294 { &get_surface_backend_texture_handle, &get_surface_backend_render_t arget_handle }) { 294 { &get_surface_backend_texture_handle, &get_surface_backend_render_t arget_handle }) {
295 for (auto& accessMode : accessModes) { 295 for (auto& accessMode : accessModes) {
296 auto surface(create_surface()); 296 auto surface(create_surface());
297 test_backend_handle_access_copy_on_write(reporter, surface.get(), ac cessMode, 297 test_backend_handle_access_copy_on_write(reporter, surface.get(), ac cessMode,
298 handle_access_func); 298 handle_access_func);
299 } 299 }
300 } 300 }
301 } 301 }
302 #if SK_SUPPORT_GPU 302 #if SK_SUPPORT_GPU
303 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceBackendHandleAccessCopyOnWrite_Gpu, reporter, ctxInfo) { 303 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessCopyOnWrite_Gpu, re porter, ctxInfo) {
304 const SkSurface::BackendHandleAccess accessModes[] = { 304 const SkSurface::BackendHandleAccess accessModes[] = {
305 SkSurface::kFlushRead_BackendHandleAccess, 305 SkSurface::kFlushRead_BackendHandleAccess,
306 SkSurface::kFlushWrite_BackendHandleAccess, 306 SkSurface::kFlushWrite_BackendHandleAccess,
307 SkSurface::kDiscardWrite_BackendHandleAccess, 307 SkSurface::kDiscardWrite_BackendHandleAccess,
308 }; 308 };
309 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { 309 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
310 for (auto& handle_access_func : 310 for (auto& handle_access_func :
311 { &get_surface_backend_texture_handle, &get_surface_backend_rend er_target_handle }) { 311 { &get_surface_backend_texture_handle, &get_surface_backend_rend er_target_handle }) {
312 for (auto& accessMode : accessModes) { 312 for (auto& accessMode : accessModes) {
313 auto surface(surface_func(ctxInfo.fGrContext, kPremul_SkAlphaTyp e, nullptr)); 313 auto surface(surface_func(ctxInfo.fGrContext, kPremul_SkAlphaTyp e, nullptr));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 auto surface(create_surface()); 392 auto surface(create_surface());
393 test_unique_image_snap(reporter, surface.get(), false, getImageBackingStore, 393 test_unique_image_snap(reporter, surface.get(), false, getImageBackingStore,
394 getSufaceBackingStore); 394 getSufaceBackingStore);
395 surface = create_direct_surface(); 395 surface = create_direct_surface();
396 test_unique_image_snap(reporter, surface.get(), true, getImageBackingStore, 396 test_unique_image_snap(reporter, surface.get(), true, getImageBackingStore,
397 getSufaceBackingStore); 397 getSufaceBackingStore);
398 } 398 }
399 399
400 #if SK_SUPPORT_GPU 400 #if SK_SUPPORT_GPU
401 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo ) { 401 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
402 GrContext* context = ctxInfo.fGrContext; 402 GrContext* context = ctxInfo.fGrContext;
403 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { 403 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
404 auto surface(surface_func(context, kOpaque_SkAlphaType, nullptr)); 404 auto surface(surface_func(context, kOpaque_SkAlphaType, nullptr));
405 405
406 auto imageBackingStore = [reporter](SkImage* image) { 406 auto imageBackingStore = [reporter](SkImage* image) {
407 GrTexture* texture = as_IB(image)->peekTexture(); 407 GrTexture* texture = as_IB(image)->peekTexture();
408 if (!texture) { 408 if (!texture) {
409 ERRORF(reporter, "Not texture backed."); 409 ERRORF(reporter, "Not texture backed.");
410 return static_cast<intptr_t>(0); 410 return static_cast<intptr_t>(0);
411 } 411 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID()); 494 REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID());
495 495
496 obj = func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); 496 obj = func(surface, SkSurface::kDiscardWrite_BackendHandleAccess);
497 REPORTER_ASSERT(reporter, obj != 0); 497 REPORTER_ASSERT(reporter, obj != 0);
498 sk_sp<SkImage> image3(surface->makeImageSnapshot()); 498 sk_sp<SkImage> image3(surface->makeImageSnapshot());
499 // expect a new(er) image, since we claimed we would write 499 // expect a new(er) image, since we claimed we would write
500 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID()); 500 REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID());
501 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID()); 501 REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID());
502 } 502 }
503 // No CPU test. 503 // No CPU test.
504 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporte r, ctxInfo) { 504 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter, ctxInfo) {
505 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { 505 for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
506 for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_h andle_gen_id }) { 506 for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_h andle_gen_id }) {
507 for (auto& handle_access_func : 507 for (auto& handle_access_func :
508 { &get_surface_backend_texture_handle, &get_surface_backend_rend er_target_handle}) { 508 { &get_surface_backend_texture_handle, &get_surface_backend_rend er_target_handle}) {
509 auto surface(surface_func(ctxInfo.fGrContext, kPremul_SkAlphaTyp e, nullptr)); 509 auto surface(surface_func(ctxInfo.fGrContext, kPremul_SkAlphaTyp e, nullptr));
510 test_func(reporter, surface.get(), handle_access_func); 510 test_func(reporter, surface.get(), handle_access_func);
511 } 511 }
512 } 512 }
513 } 513 }
514 } 514 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 desc.fHeight = kHeight; 890 desc.fHeight = kHeight;
891 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 891 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
892 desc.fTextureHandle = textureObject; 892 desc.fTextureHandle = textureObject;
893 893
894 auto surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr) ; 894 auto surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr) ;
895 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); 895 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB);
896 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); 896 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject);
897 } 897 }
898 } 898 }
899 #endif 899 #endif
OLDNEW
« no previous file with comments | « tests/SpecialImageTest.cpp ('k') | tests/Test.h » ('j') | tests/Test.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698