| OLD | NEW |
| 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 "SkColorSpace_Base.h" | 10 #include "SkColorSpace_Base.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 GrTexture* texture = as_IB(image)->peekTexture(); | 553 GrTexture* texture = as_IB(image)->peekTexture(); |
| 554 REPORTER_ASSERT(reporter, texture); | 554 REPORTER_ASSERT(reporter, texture); |
| 555 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); | 555 REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); |
| 556 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); | 556 surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); |
| 557 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture); | 557 REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture); |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 #endif | 560 #endif |
| 561 | 561 |
| 562 #if SK_SUPPORT_GPU | 562 #if SK_SUPPORT_GPU |
| 563 #include "GrRenderTargetContextPriv.h" |
| 563 #include "GrGpuResourcePriv.h" | 564 #include "GrGpuResourcePriv.h" |
| 564 #include "SkGpuDevice.h" | 565 #include "SkGpuDevice.h" |
| 565 #include "SkImage_Gpu.h" | 566 #include "SkImage_Gpu.h" |
| 566 #include "SkSurface_Gpu.h" | 567 #include "SkSurface_Gpu.h" |
| 567 | 568 |
| 568 static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) { | 569 static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) { |
| 569 SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get(); | 570 SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get(); |
| 570 return gsurf->getDevice()->accessRenderTargetContext() | 571 return gsurf->getDevice()->accessRenderTargetContext() |
| 571 ->accessRenderTarget()->resourcePriv().isBudgeted(); | 572 ->accessRenderTarget()->resourcePriv().isBudgeted(); |
| 572 } | 573 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 784 } |
| 784 ERRORF(reporter, | 785 ERRORF(reporter, |
| 785 "%s but read 0x%08x (instead of 0x%08x) at %x,%d", msg.c_
str(), pixel, | 786 "%s but read 0x%08x (instead of 0x%08x) at %x,%d", msg.c_
str(), pixel, |
| 786 expectedValue, x, y); | 787 expectedValue, x, y); |
| 787 return; | 788 return; |
| 788 } | 789 } |
| 789 } | 790 } |
| 790 } | 791 } |
| 791 } | 792 } |
| 792 | 793 |
| 794 #if 0 |
| 793 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { | 795 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { |
| 794 GrContext* context = ctxInfo.grContext(); | 796 GrContext* context = ctxInfo.grContext(); |
| 795 | 797 |
| 796 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { | 798 std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { |
| 797 [] (SkSurface* s){ | 799 [] (SkSurface* s){ |
| 798 GrRenderTargetContext* rtc = | 800 GrRenderTargetContext* rtc = |
| 799 s->getCanvas()->internal_private_accessTopLayerRenderTargetConte
xt(); | 801 s->getCanvas()->internal_private_accessTopLayerRenderTargetConte
xt(); |
| 800 return rtc->accessRenderTarget(); }, | 802 return rtc->accessRenderTarget(); }, |
| 801 [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); | 803 [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); |
| 802 return as_IB(i)->peekTexture(); } | 804 return as_IB(i)->peekTexture(); } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 813 for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, | 815 for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, |
| 814 &create_gpu_surface_backend_texture_as_render_
target}) { | 816 &create_gpu_surface_backend_texture_as_render_
target}) { |
| 815 GrBackendObject textureObject; | 817 GrBackendObject textureObject; |
| 816 auto surface = surfaceFunc(context, 0, kOrigColor, &textureObject); | 818 auto surface = surfaceFunc(context, 0, kOrigColor, &textureObject); |
| 817 test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor); | 819 test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor); |
| 818 surface.reset(); | 820 surface.reset(); |
| 819 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); | 821 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); |
| 820 } | 822 } |
| 821 } | 823 } |
| 822 } | 824 } |
| 825 #endif |
| 823 | 826 |
| 824 static void test_surface_draw_partially( | 827 static void test_surface_draw_partially( |
| 825 skiatest::Reporter* reporter, sk_sp<SkSurface> surface, uint32_t origColor)
{ | 828 skiatest::Reporter* reporter, sk_sp<SkSurface> surface, uint32_t origColor)
{ |
| 826 const int kW = surface->width(); | 829 const int kW = surface->width(); |
| 827 const int kH = surface->height(); | 830 const int kH = surface->height(); |
| 828 SkPaint paint; | 831 SkPaint paint; |
| 829 const SkColor kRectColor = ~origColor | 0xFF000000; | 832 const SkColor kRectColor = ~origColor | 0xFF000000; |
| 830 paint.setColor(kRectColor); | 833 paint.setColor(kRectColor); |
| 831 surface->getCanvas()->drawRect(SkRect::MakeWH(SkIntToScalar(kW), SkIntToScal
ar(kH)/2), | 834 surface->getCanvas()->drawRect(SkRect::MakeWH(SkIntToScalar(kW), SkIntToScal
ar(kH)/2), |
| 832 paint); | 835 paint); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 GrBackendObject textureObject; | 881 GrBackendObject textureObject; |
| 879 auto surface = surfaceFunc(ctxInfo.grContext(), 0, kOrigColor, &textureO
bject); | 882 auto surface = surfaceFunc(ctxInfo.grContext(), 0, kOrigColor, &textureO
bject); |
| 880 if (surface) { | 883 if (surface) { |
| 881 test_surface_draw_partially(reporter, surface, kOrigColor); | 884 test_surface_draw_partially(reporter, surface, kOrigColor); |
| 882 surface.reset(); | 885 surface.reset(); |
| 883 gpu->deleteTestingOnlyBackendTexture(textureObject); | 886 gpu->deleteTestingOnlyBackendTexture(textureObject); |
| 884 } | 887 } |
| 885 } | 888 } |
| 886 } | 889 } |
| 887 | 890 |
| 888 | 891 #if 0 |
| 889 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf
o) { | 892 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf
o) { |
| 890 GrGpu* gpu = ctxInfo.grContext()->getGpu(); | 893 GrGpu* gpu = ctxInfo.grContext()->getGpu(); |
| 891 if (!gpu) { | 894 if (!gpu) { |
| 892 return; | 895 return; |
| 893 } | 896 } |
| 894 static const uint32_t kOrigColor = 0xFFAABBCC; | 897 static const uint32_t kOrigColor = 0xFFAABBCC; |
| 895 | 898 |
| 896 for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, | 899 for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, |
| 897 &create_gpu_surface_backend_texture_as_render_targ
et}) { | 900 &create_gpu_surface_backend_texture_as_render_targ
et}) { |
| 898 for (int sampleCnt : {0, 4, 8}) { | 901 for (int sampleCnt : {0, 4, 8}) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 }; | 1017 }; |
| 1015 | 1018 |
| 1016 test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16
Support, | 1019 test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16
Support, |
| 1017 wrappedSurfaceMaker); | 1020 wrappedSurfaceMaker); |
| 1018 | 1021 |
| 1019 for (auto textureHandle : textureHandles) { | 1022 for (auto textureHandle : textureHandles) { |
| 1020 context->getGpu()->deleteTestingOnlyBackendTexture(textureHandle); | 1023 context->getGpu()->deleteTestingOnlyBackendTexture(textureHandle); |
| 1021 } | 1024 } |
| 1022 } | 1025 } |
| 1023 #endif | 1026 #endif |
| 1027 |
| 1028 #endif |
| OLD | NEW |