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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1930623003: Clean up test drawContext usage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix typo Created 4 years, 7 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 | « src/gpu/SkGpuDevice.cpp ('k') | tools/VisualBench/WrappedBenchmark.h » ('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 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"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkImage_Base.h" 12 #include "SkImage_Base.h"
13 #include "SkPath.h" 13 #include "SkPath.h"
14 #include "SkRRect.h" 14 #include "SkRRect.h"
15 #include "SkSurface.h" 15 #include "SkSurface.h"
16 #include "SkUtils.h" 16 #include "SkUtils.h"
17 #include "Test.h" 17 #include "Test.h"
18 18
19 #if SK_SUPPORT_GPU 19 #if SK_SUPPORT_GPU
20 #include "GrContext.h" 20 #include "GrContext.h"
21 #include "GrDrawContext.h"
21 #include "GrGpu.h" 22 #include "GrGpu.h"
22 #endif 23 #endif
23 24
24 #include <initializer_list> 25 #include <initializer_list>
25 26
26 static void release_direct_surface_storage(void* pixels, void* context) { 27 static void release_direct_surface_storage(void* pixels, void* context) {
27 SkASSERT(pixels == context); 28 SkASSERT(pixels == context);
28 sk_free(pixels); 29 sk_free(pixels);
29 } 30 }
30 static sk_sp<SkSurface> create_surface(SkAlphaType at = kPremul_SkAlphaType, 31 static sk_sp<SkSurface> create_surface(SkAlphaType at = kPremul_SkAlphaType,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 auto imageBackingStore = [reporter](SkImage* image) { 407 auto imageBackingStore = [reporter](SkImage* image) {
407 GrTexture* texture = as_IB(image)->peekTexture(); 408 GrTexture* texture = as_IB(image)->peekTexture();
408 if (!texture) { 409 if (!texture) {
409 ERRORF(reporter, "Not texture backed."); 410 ERRORF(reporter, "Not texture backed.");
410 return static_cast<intptr_t>(0); 411 return static_cast<intptr_t>(0);
411 } 412 }
412 return static_cast<intptr_t>(texture->getUniqueID()); 413 return static_cast<intptr_t>(texture->getUniqueID());
413 }; 414 };
414 415
415 auto surfaceBackingStore = [reporter](SkSurface* surface) { 416 auto surfaceBackingStore = [reporter](SkSurface* surface) {
416 GrRenderTarget* rt = 417 GrDrawContext* dc = surface->getCanvas()->internal_private_accessTop LayerDrawContext();
417 surface->getCanvas()->internal_private_accessTopLayerRenderTarge t(); 418 GrRenderTarget* rt = dc->accessRenderTarget();
418 if (!rt) { 419 if (!rt) {
419 ERRORF(reporter, "Not render target backed."); 420 ERRORF(reporter, "Not render target backed.");
420 return static_cast<intptr_t>(0); 421 return static_cast<intptr_t>(0);
421 } 422 }
422 return static_cast<intptr_t>(rt->getUniqueID()); 423 return static_cast<intptr_t>(rt->getUniqueID());
423 }; 424 };
424 425
425 test_unique_image_snap(reporter, surface.get(), false, imageBackingStore , 426 test_unique_image_snap(reporter, surface.get(), false, imageBackingStore ,
426 surfaceBackingStore); 427 surfaceBackingStore);
427 428
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 expectedValue, x, y); 855 expectedValue, x, y);
855 return; 856 return;
856 } 857 }
857 } 858 }
858 } 859 }
859 } 860 }
860 861
861 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { 862 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
862 GrContext* context = ctxInfo.fGrContext; 863 GrContext* context = ctxInfo.fGrContext;
863 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { 864 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = {
864 [] (SkSurface* s){ return s->getCanvas()->internal_private_accessTopLaye rRenderTarget(); }, 865 [] (SkSurface* s){
866 GrDrawContext* dc = s->getCanvas()->internal_private_accessTopLayerD rawContext();
867 return dc->accessRenderTarget(); },
865 [] (SkSurface* s){ 868 [] (SkSurface* s){
866 SkBaseDevice* d = 869 SkBaseDevice* d =
867 s->getCanvas()->getDevice_just_for_deprecated_compatibility_test ing(); 870 s->getCanvas()->getDevice_just_for_deprecated_compatibility_test ing();
868 return d->accessRenderTarget(); }, 871 return d->accessRenderTarget(); },
869 [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); 872 [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot());
870 return as_IB(i)->peekTexture(); }, 873 return as_IB(i)->peekTexture(); },
871 }; 874 };
872 for (auto grSurfaceGetter : grSurfaceGetters) { 875 for (auto grSurfaceGetter : grSurfaceGetters) {
873 for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surf ace}) { 876 for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surf ace}) {
874 auto surface = surface_func(context, kPremul_SkAlphaType, nullptr); 877 auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
(...skipping 15 matching lines...) Expand all
890 desc.fHeight = kHeight; 893 desc.fHeight = kHeight;
891 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 894 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
892 desc.fTextureHandle = textureObject; 895 desc.fTextureHandle = textureObject;
893 896
894 auto surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr) ; 897 auto surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr) ;
895 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); 898 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB);
896 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); 899 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject);
897 } 900 }
898 } 901 }
899 #endif 902 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tools/VisualBench/WrappedBenchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698