diff options
author | Brian Salomon <bsalomon@google.com> | 2018-03-09 09:01:53 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-09 16:32:10 +0000 |
commit | f865b05fe50ca2c094b9c60e4405c6094415b4f6 (patch) | |
tree | a00eab7c3787b5b977b3ae7c15aa1732f5a42c97 /tools | |
parent | ad06544cc6ac4b403a24adda4ee36b9f35b3071f (diff) |
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 <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.cpp | 61 | ||||
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.h | 19 | ||||
-rw-r--r-- | tools/skpbench/skpbench.cpp | 5 |
3 files changed, 71 insertions, 14 deletions
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<SkString>& viaParts, ContextType contextType, bool useNVPR, - bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType, - sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers, bool testThreading) + const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, + bool useNVPR, bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType, + sk_sp<SkColorSpace> 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<SkColorSpace> 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<SkString>& 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<SkColorSpace> 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<SkColorSpace> fColorSpace; bool fTestThreading; + SurfType fSurfType; }; #endif diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp index 562c48165f..92a642af1c 100644 --- a/tools/skpbench/skpbench.cpp +++ b/tools/skpbench/skpbench.cpp @@ -274,6 +274,11 @@ int main(int argc, char** argv) { SkScalarCeilToInt(skp->cullRect().height()), width, height); } + if (config->getSurfType() != SkCommandLineConfigGpu::SurfType::kDefault) { + exitf(ExitErr::kUnavailable, "This tool only supports the default surface type. (%s)", + config->getTag().c_str()); + } + // Create a context. GrContextOptions ctxOptions; SetCtxOptionsFromCommonFlags(&ctxOptions); |