diff options
author | Brian Salomon <bsalomon@google.com> | 2018-02-03 00:25:12 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-03 00:25:20 +0000 |
commit | 3a2cc2c2ec124de36d2544b2a523ef1dd317ca32 (patch) | |
tree | df3154eabde3275c5a6b88f66233b9a3984bd04f /tests/SurfaceTest.cpp | |
parent | 5bb82cbecd740d21b92e8d2944280ab6eb6af7a6 (diff) |
Revert "Revert "Revert "Revert "Revert "Redefine the meaning of sample counts in GPU backend."""""
This reverts commit 5bb82cbecd740d21b92e8d2944280ab6eb6af7a6.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Revert "Revert "Revert "Revert "Redefine the meaning of sample counts in GPU backend.""""
>
> This reverts commit 18c52a7b52211de5d0dcd86dc048adef758c6c75.
>
> Also relands "More sample count cleanup:" and "Add new GrContext queries for imagability, surfacability, and max sample count of color types"
>
>
> Bug: skia:
> Change-Id: I4028105a3a1f16ce3944e134619eb6245af6b947
> Reviewed-on: https://skia-review.googlesource.com/102940
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
Change-Id: Idee23be2f1719f0bdc9305043e95a2d589bee8d1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/103220
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/SurfaceTest.cpp')
-rw-r--r-- | tests/SurfaceTest.cpp | 137 |
1 files changed, 11 insertions, 126 deletions
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index de1cd9a984..471953b373 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -19,17 +19,13 @@ #include "Test.h" #if SK_SUPPORT_GPU -#include <vector> #include "GrContext.h" #include "GrContextPriv.h" -#include "GrGpu.h" -#include "GrGpuResourcePriv.h" #include "GrRenderTargetContext.h" +#include "GrGpu.h" #include "GrResourceProvider.h" #include "GrTest.h" -#include "SkGpuDevice.h" -#include "SkImage_Gpu.h" -#include "SkSurface_Gpu.h" +#include <vector> #endif #include <initializer_list> @@ -92,121 +88,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, ctxInfo) { } #endif -#if SK_SUPPORT_GPU -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, reporter, ctxInfo) { - for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) { - static constexpr int kSize = 10; - - SkColorType colorType = static_cast<SkColorType>(ct); - auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr); - bool can = ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType); - auto surf = SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kYes, info, 1, - nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", - colorType, can, SkToBool(surf)); - - auto* gpu = ctxInfo.grContext()->contextPriv().getGpu(); - GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( - nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo); - surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, - kTopLeft_GrSurfaceOrigin, 0, colorType, nullptr, - nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", - colorType, can, SkToBool(surf)); - - surf = SkSurface::MakeFromBackendTextureAsRenderTarget(ctxInfo.grContext(), backendTex, - kTopLeft_GrSurfaceOrigin, 1, - colorType, nullptr, nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", - colorType, can, SkToBool(surf)); - - surf.reset(); - ctxInfo.grContext()->flush(); - if (backendTex.isValid()) { - gpu->deleteTestingOnlyBackendTexture(&backendTex); - } - - static constexpr int kSampleCnt = 2; - - can = ctxInfo.grContext()->maxSurfaceSampleCountForColorType(colorType) >= kSampleCnt; - surf = SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kYes, info, kSampleCnt, - nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", - colorType, can, SkToBool(surf)); - - backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kSize, kSize, colorType, true, - GrMipMapped::kNo); - surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, - kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType, - nullptr, nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), - "colorTypeSupportedAsSurface:%d, surf:%d, ct:%d", can, SkToBool(surf), - colorType); - // Ensure that the sample count stored on the resulting SkSurface is a valid value. - if (surf) { - auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext(); - int storedCnt = rtc->numStencilSamples(); - int allowedCnt = ctxInfo.grContext()->caps()->getSampleCount( - storedCnt, rtc->asSurfaceProxy()->config()); - REPORTER_ASSERT(reporter, storedCnt == allowedCnt, - "Should store an allowed sample count (%d vs %d)", allowedCnt, - storedCnt); - } - - surf = SkSurface::MakeFromBackendTextureAsRenderTarget(ctxInfo.grContext(), backendTex, - kTopLeft_GrSurfaceOrigin, kSampleCnt, - colorType, nullptr, nullptr); - REPORTER_ASSERT(reporter, can == SkToBool(surf), - "colorTypeSupportedAsSurface:%d, surf:%d, ct:%d", can, SkToBool(surf), - colorType); - if (surf) { - auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext(); - int storedCnt = rtc->numStencilSamples(); - int allowedCnt = ctxInfo.grContext()->caps()->getSampleCount( - storedCnt, rtc->asSurfaceProxy()->config()); - REPORTER_ASSERT(reporter, storedCnt == allowedCnt, - "Should store an allowed sample count (%d vs %d)", allowedCnt, - storedCnt); - } - - surf.reset(); - ctxInfo.grContext()->flush(); - if (backendTex.isValid()) { - gpu->deleteTestingOnlyBackendTexture(&backendTex); - } - } -} - -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, reporter, ctxInfo) { - for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) { - static constexpr int kSize = 10; - - SkColorType colorType = static_cast<SkColorType>(ct); - int max = ctxInfo.grContext()->maxSurfaceSampleCountForColorType(colorType); - if (!max) { - continue; - } - auto* gpu = ctxInfo.grContext()->contextPriv().getGpu(); - GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( - nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo); - - auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr); - auto surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, - kTopLeft_GrSurfaceOrigin, max, - colorType, nullptr, nullptr); - REPORTER_ASSERT(reporter, surf); - if (!surf) { - continue; - } - int sampleCnt = ((SkSurface_Gpu*)(surf.get())) - ->getDevice() - ->accessRenderTargetContext() - ->numStencilSamples(); - REPORTER_ASSERT(reporter, sampleCnt == max, "Exected: %d, actual: %d", max, sampleCnt); - } -} -#endif - static void test_canvas_peek(skiatest::Reporter* reporter, sk_sp<SkSurface>& surface, const SkImageInfo& requestInfo, @@ -556,6 +437,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) { #endif #if SK_SUPPORT_GPU +#include "GrGpuResourcePriv.h" +#include "SkGpuDevice.h" +#include "SkImage_Gpu.h" +#include "SkSurface_Gpu.h" static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) { SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get(); @@ -819,7 +704,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, &create_gpu_surface_backend_texture_as_render_target}) { GrBackendTexture backendTex; - auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex); + auto surface = surfaceFunc(context, 0, kOrigColor, &backendTex); test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor); surface.reset(); gpu->deleteTestingOnlyBackendTexture(&backendTex); @@ -882,7 +767,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacePartialDraw_Gpu, reporter, ctxInfo) { // preserved in pixels that aren't rendered to via the surface. // This works only for non-multisampled case. GrBackendTexture backendTex; - auto surface = surfaceFunc(ctxInfo.grContext(), 1, kOrigColor, &backendTex); + auto surface = surfaceFunc(ctxInfo.grContext(), 0, kOrigColor, &backendTex); if (surface) { test_surface_draw_partially(reporter, surface, kOrigColor); surface.reset(); @@ -906,11 +791,11 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, &create_gpu_surface_backend_texture_as_render_target}) { - for (int sampleCnt : {1, 4, 8}) { + for (int sampleCnt : {0, 4, 8}) { GrBackendTexture backendTex; auto surface = surfaceFunc(ctxInfo.grContext(), sampleCnt, kOrigColor, &backendTex); - if (!surface && sampleCnt > 1) { + if (!surface && sampleCnt > 0) { // Certain platforms don't support MSAA, skip these. continue; } @@ -995,7 +880,7 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig); + bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig, false); auto surfaceMaker = [context](const SkImageInfo& info) { return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); }; |