aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/flags
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-07-17 11:31:31 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-17 17:09:08 +0000
commitce5ee602ed19b8493bf4dd1654d29486088bad63 (patch)
tree8b658834cd37a7ad0e400f6bb708f056956c024e /tools/flags
parent1c8f73d9b55746b9139bfe734f7b016f0bdb0259 (diff)
Add support for GL 565 and 4444 configs to test tools
Change-Id: I395e3387df44cf5370fef6ab73db73228225622f Reviewed-on: https://skia-review.googlesource.com/23946 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/flags')
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp25
-rw-r--r--tools/flags/SkCommonFlagsConfig.h6
2 files changed, 26 insertions, 5 deletions
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 3fb5cb98d1..03b3b96822 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -55,6 +55,8 @@ static const struct {
{ "glesinst", "gpu", "api=gles,inst=true" },
{ "glesinst4", "gpu", "api=gles,inst=true,samples=4" },
{ "glesinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
+ { "gl4444", "gpu", "api=gl,color=4444" },
+ { "gl565", "gpu", "api=gl,color=565" },
{ "glf16", "gpu", "api=gl,color=f16" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
{ "glsrgbnl", "gpu", "api=gl,color=srgbnl" },
@@ -151,6 +153,8 @@ static const char configExtendedHelp[] =
"\t Select framebuffer color format.\n"
"\t Options:\n"
"\t\t8888\t\t\tLinear 8888.\n"
+ "\t\t4444\t\t\tLinear 4444.\n"
+ "\t\t565\t\t\tLinear 565.\n"
"\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
"\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
"\t gamut\ttype: string\tdefault: srgb.\n"
@@ -195,7 +199,7 @@ SkCommandLineConfig::~SkCommandLineConfig() {
#if SK_SUPPORT_GPU
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR,
- bool useInstanced, bool useDIText, int samples, SkColorType colorType,
+ bool useInstanced, bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
@@ -203,6 +207,7 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu(
, fUseDIText(useDIText)
, fSamples(samples)
, fColorType(colorType)
+ , fAlphaType(alphaType)
, fColorSpace(std::move(colorSpace)) {
if (useNVPR) {
fContextOverrides |= ContextOverrides::kRequireNVPRSupport;
@@ -320,11 +325,24 @@ static bool parse_option_gpu_api(const SkString& value,
}
static bool parse_option_gpu_color(const SkString& value,
SkColorType* outColorType,
+ SkAlphaType* alphaType,
sk_sp<SkColorSpace>* outColorSpace) {
+ // We always use premul unless the color type is 565.
+ *alphaType = kPremul_SkAlphaType;
+
if (value.equals("8888")) {
*outColorType = kRGBA_8888_SkColorType;
*outColorSpace = nullptr;
return true;
+ } else if (value.equals("4444")) {
+ *outColorType = kARGB_4444_SkColorType;
+ *outColorSpace = nullptr;
+ return true;
+ } else if (value.equals("565")) {
+ *outColorType = kRGB_565_SkColorType;
+ *alphaType = kOpaque_SkAlphaType;
+ *outColorSpace = nullptr;
+ return true;
}
SkTArray<SkString> commands;
@@ -397,6 +415,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
int samples = 0;
bool seenColor = false;
SkColorType colorType = kRGBA_8888_SkColorType;
+ SkAlphaType alphaType = kPremul_SkAlphaType;
sk_sp<SkColorSpace> colorSpace = nullptr;
bool seenUseStencils = false;
bool useStencils = true;
@@ -428,7 +447,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
valueOk = parse_option_int(value, &samples);
seenSamples = true;
} else if (key.equals("color") && !seenColor) {
- valueOk = parse_option_gpu_color(value, &colorType, &colorSpace);
+ valueOk = parse_option_gpu_color(value, &colorType, &alphaType, &colorSpace);
seenColor = true;
} else if (key.equals("stencils") && !seenUseStencils) {
valueOk = parse_option_bool(value, &useStencils);
@@ -442,7 +461,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
return nullptr;
}
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
- samples, colorType, colorSpace, useStencils);
+ samples, colorType, alphaType, colorSpace, useStencils);
}
#endif
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index a3c3b38cd4..77f31c32c2 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -55,8 +55,8 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
typedef sk_gpu_test::GrContextFactory::ContextOverrides ContextOverrides;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useInstanced, bool useDIText,
- int samples, SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
- bool useStencilBuffers);
+ int samples, SkColorType colorType, SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers);
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
ContextType getContextType() const { return fContextType; }
ContextOverrides getContextOverrides() const { return fContextOverrides; }
@@ -69,6 +69,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
bool getUseDIText() const { return fUseDIText; }
int getSamples() const { return fSamples; }
SkColorType getColorType() const { return fColorType; }
+ SkAlphaType getAlphaType() const { return fAlphaType; }
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
private:
@@ -77,6 +78,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
bool fUseDIText;
int fSamples;
SkColorType fColorType;
+ SkAlphaType fAlphaType;
sk_sp<SkColorSpace> fColorSpace;
};
#endif