From f865b05fe50ca2c094b9c60e4405c6094415b4f6 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 9 Mar 2018 09:01:53 -0500 Subject: Add GM configs that test rendering to a GL backend texture and render target This also adds GrGpu::create/deleteTestingOnlyBackendRenderTarget. Implemented in GL only for now. Change-Id: I9e5fdc953c4a249959af89e08332f520cefe9d90 Reviewed-on: https://skia-review.googlesource.com/113305 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- tools/flags/SkCommonFlagsConfig.cpp | 61 +++++++++++++++++++++++++++++++------ tools/flags/SkCommonFlagsConfig.h | 19 +++++++++--- 2 files changed, 66 insertions(+), 14 deletions(-) (limited to 'tools/flags') diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index 85495c68d8..bb53c2d64e 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -34,7 +34,7 @@ static const struct { const char* predefinedConfig; const char* backend; const char* options; -} gPredefinedConfigs[] ={ +} gPredefinedConfigs[] = { #if SK_SUPPORT_GPU { "gl", "gpu", "api=gl" }, { "gles", "gpu", "api=gles" }, @@ -44,6 +44,10 @@ static const struct { { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" }, { "glnvpr8" , "gpu", "api=gl,nvpr=true,samples=8" }, { "glesnvpr4", "gpu", "api=gles,nvpr=true,samples=4" }, + { "glbetex", "gpu", "api=gl,surf=betex" }, + { "glesbetex", "gpu", "api=gles,surf=betex" }, + { "glbert", "gpu", "api=gl,surf=bert" }, + { "glesbert", "gpu", "api=gles,surf=bert" }, { "gl4444", "gpu", "api=gl,color=4444" }, { "gl565", "gpu", "api=gl,color=565" }, { "glf16", "gpu", "api=gl,color=f16" }, @@ -162,6 +166,12 @@ static const char configExtendedHelp[] = "\t Allow the use of stencil buffers.\n" "\ttestThreading\ttype: bool\tdefault: false.\n" "\t Run config with and without worker threads, check that results match.\n" + "\tsurf\ttype: string\tdefault: default.\n" + "\t Controls the type of backing store for SkSurfaces.\n" + "\t Options:\n" + "\t\tdefault\t\t\tA renderable texture created in Skia's resource cache.\n" + "\t\tbetex\t\t\tA wrapped backend texture.\n" + "\t\tbert\t\t\tA wrapped backend render target\n" "\n" "Predefined configs:\n\n" // Help text for pre-defined configs is auto-generated from gPredefinedConfigs @@ -272,6 +282,7 @@ static bool parse_option_gpu_api(const SkString& value, #endif return false; } + static bool parse_option_gpu_color(const SkString& value, SkColorType* outColorType, SkAlphaType* alphaType, @@ -351,6 +362,23 @@ static bool parse_option_gpu_color(const SkString& value, } return false; } + +static bool parse_option_gpu_surf_type(const SkString& value, + SkCommandLineConfigGpu::SurfType* surfType) { + if (value.equals("default")) { + *surfType = SkCommandLineConfigGpu::SurfType::kDefault; + return true; + } + if (value.equals("betex")) { + *surfType = SkCommandLineConfigGpu::SurfType::kBackendTexture; + return true; + } + if (value.equals("bert")) { + *surfType = SkCommandLineConfigGpu::SurfType::kBackendRenderTarget; + return true; + } + return false; +} #endif // Extended options take form --config item[key1=value1,key2=value2,...] @@ -402,6 +430,16 @@ public: } return parse_option_gpu_api(*optionValue, outContextType); } + + bool get_option_gpu_surf_type(const char* optionKey, + SkCommandLineConfigGpu::SurfType* outSurfType, + bool optional = true) const { + SkString* optionValue = fOptionsMap.find(SkString(optionKey)); + if (optionValue == nullptr) { + return optional; + } + return parse_option_gpu_surf_type(*optionValue, outSurfType); + } #endif bool get_option_int(const char* optionKey, int* outInt, bool optional = true) const { @@ -426,9 +464,10 @@ private: #if SK_SUPPORT_GPU SkCommandLineConfigGpu::SkCommandLineConfigGpu( - const SkString& tag, const SkTArray& viaParts, ContextType contextType, bool useNVPR, - bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType, - sk_sp colorSpace, bool useStencilBuffers, bool testThreading) + const SkString& tag, const SkTArray& viaParts, ContextType contextType, + bool useNVPR, bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType, + sk_sp colorSpace, bool useStencilBuffers, bool testThreading, + SurfType surfType) : SkCommandLineConfig(tag, SkString("gpu"), viaParts) , fContextType(contextType) , fContextOverrides(ContextOverrides::kNone) @@ -437,7 +476,8 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu( , fColorType(colorType) , fAlphaType(alphaType) , fColorSpace(std::move(colorSpace)) - , fTestThreading(testThreading) { + , fTestThreading(testThreading) + , fSurfType(surfType) { if (useNVPR) { fContextOverrides |= ContextOverrides::kRequireNVPRSupport; } else { @@ -474,6 +514,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, sk_sp colorSpace = nullptr; bool useStencils = true; bool testThreading = false; + SkCommandLineConfigGpu::SurfType surfType = SkCommandLineConfigGpu::SurfType::kDefault; bool parseSucceeded = false; ExtendedOptions extendedOptions(options, &parseSucceeded); @@ -488,15 +529,17 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, extendedOptions.get_option_int("samples", &samples) && extendedOptions.get_option_gpu_color("color", &colorType, &alphaType, &colorSpace) && extendedOptions.get_option_bool("stencils", &useStencils) && - extendedOptions.get_option_bool("testThreading", &testThreading); + extendedOptions.get_option_bool("testThreading", &testThreading) && + extendedOptions.get_option_bool("testThreading", &testThreading) && + extendedOptions.get_option_gpu_surf_type("surf", &surfType); if (!validOptions) { return nullptr; } - return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, - samples, colorType, alphaType, colorSpace, useStencils, - testThreading); + return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples, + colorType, alphaType, colorSpace, useStencils, testThreading, + surfType); } #endif diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h index d88edf1c3b..3f1056d113 100644 --- a/tools/flags/SkCommonFlagsConfig.h +++ b/tools/flags/SkCommonFlagsConfig.h @@ -52,14 +52,21 @@ class SkCommandLineConfig { // * backends that represent a shorthand of above (such as "glmsaa16" representing // "gpu(api=gl,samples=16)") class SkCommandLineConfigGpu : public SkCommandLineConfig { - public: +public: + enum class SurfType { + kDefault, + kBackendTexture, + kBackendRenderTarget + }; typedef sk_gpu_test::GrContextFactory::ContextType ContextType; typedef sk_gpu_test::GrContextFactory::ContextOverrides ContextOverrides; + SkCommandLineConfigGpu(const SkString& tag, const SkTArray& viaParts, - ContextType contextType, bool useNVPR, bool useDIText, - int samples, SkColorType colorType, SkAlphaType alphaType, + ContextType contextType, bool useNVPR, bool useDIText, int samples, + SkColorType colorType, SkAlphaType alphaType, sk_sp colorSpace, bool useStencilBuffers, - bool testThreading); + bool testThreading, SurfType); + const SkCommandLineConfigGpu* asConfigGpu() const override { return this; } ContextType getContextType() const { return fContextType; } ContextOverrides getContextOverrides() const { return fContextOverrides; } @@ -74,8 +81,9 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig { SkAlphaType getAlphaType() const { return fAlphaType; } SkColorSpace* getColorSpace() const { return fColorSpace.get(); } bool getTestThreading() const { return fTestThreading; } + SurfType getSurfType() const { return fSurfType; } - private: +private: ContextType fContextType; ContextOverrides fContextOverrides; bool fUseDIText; @@ -84,6 +92,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig { SkAlphaType fAlphaType; sk_sp fColorSpace; bool fTestThreading; + SurfType fSurfType; }; #endif -- cgit v1.2.3