diff options
author | Brian Salomon <bsalomon@google.com> | 2018-02-01 13:58:00 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-01 21:56:49 +0000 |
commit | d653cac70ed17983125ceed053138c09f1401846 (patch) | |
tree | 1c9c5395e5e16ba1be082f4160381285a8240a1d /src/gpu/GrCaps.cpp | |
parent | 704cff2c0cacdb13b7b0cd8da2cee72f24e4776c (diff) |
More sample count cleanup:
rename getSampleCount -> getRenderTargetSampleCount because it will return
0 when a config is not renderable but *is* supported as a texture format.
(Old name kept around until Chrome stops calling it)
Add virtual GrCaps::maxRenderTargetSampleCount(GrPixelConfig).
Devirtualize isConfigRenderable() and implement as maxRTSC != 0. Separate implementation for version with bool withMSAA param to be removed after Flutter is updated to no longer call.
Consolidate various file static GrSurfaceDesc validators fns into GrCaps::validateSurfaceDesc().
Bug: skia:
Change-Id: Ie30a291aa027e910df3bd90fac8518ccdb39e53f
Reviewed-on: https://skia-review.googlesource.com/102141
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrCaps.cpp')
-rw-r--r-- | src/gpu/GrCaps.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 427b20425a..dd589b436f 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -196,8 +196,7 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { kBlendEquationSupportNames[fBlendEquationSupport]); writer->appendString("Map Buffer Support", map_flags_to_string(fMapBufferFlags).c_str()); - SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, false)); - SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, true)); + SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig)); SkASSERT(!this->isConfigTexturable(kUnknown_GrPixelConfig)); writer->beginArray("configs"); @@ -206,8 +205,7 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { GrPixelConfig config = static_cast<GrPixelConfig>(i); writer->beginObject(nullptr, false); writer->appendString("name", pixel_config_name(config)); - writer->appendBool("renderable", this->isConfigRenderable(config, false)); - writer->appendBool("renderableMSAA", this->isConfigRenderable(config, true)); + writer->appendS32("max sample count", this->maxRenderTargetSampleCount(config)); writer->appendBool("texturable", this->isConfigTexturable(config)); writer->endObject(); } @@ -222,3 +220,39 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { writer->endObject(); } +bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrMipMapped mipped) const { + if (!this->isConfigTexturable(desc.fConfig)) { + return false; + } + + if (GrMipMapped::kYes == mipped) { + if (GrPixelConfigIsSint(desc.fConfig) || !this->mipMapSupport()) { + return false; + } + } + + if (desc.fWidth < 1 || desc.fHeight < 1) { + return false; + } + + if (SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) { + if (0 == this->getRenderTargetSampleCount(desc.fSampleCnt, desc.fConfig)) { + return false; + } + int maxRTSize = this->maxRenderTargetSize(); + if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { + return false; + } + } else { + // We currently do not support multisampled textures + if (desc.fSampleCnt > 1) { + return false; + } + int maxSize = this->maxTextureSize(); + if (desc.fWidth > maxSize || desc.fHeight > maxSize) { + return false; + } + } + + return true; +} |