diff options
author | Robert Phillips <robertphillips@google.com> | 2018-02-13 17:03:00 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-14 12:42:18 +0000 |
commit | fc711a2b0143aa4f559ef041068af1c04d7dab85 (patch) | |
tree | 3cd87b121b87566b9837112badccd5aa958f75f5 /src/gpu/GrContext.cpp | |
parent | 6ce969472e2ede1e3d6549579c095a12c2d576ca (diff) |
Add SkCharacterization creation helper to GrContextThreadSafeProxy (take 2)
TBR=bsalomon@google.com
Change-Id: Id96d4fdbb6889065f10a4a7e0c22a03ad9aa5fef
Reviewed-on: https://skia-review.googlesource.com/107000
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r-- | src/gpu/GrContext.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index af9472409b..09985e6f79 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -335,6 +335,42 @@ sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() { return fThreadSafeProxy; } +SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization( + size_t cacheMaxResourceBytes, + const SkImageInfo& ii, const GrBackendFormat& backendFormat, + int sampleCnt, GrSurfaceOrigin origin, + const SkSurfaceProps& surfaceProps, + bool isMipMapped) { + if (!backendFormat.isValid()) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + // We're assuming GrFSAAType::kMixedSamples will never be specified via this code path + GrFSAAType FSAAType = sampleCnt > 1 ? GrFSAAType::kUnifiedMSAA : GrFSAAType::kNone; + + if (!fCaps->mipMapSupport()) { + isMipMapped = false; + } + + GrPixelConfig config = kUnknown_GrPixelConfig; + if (!fCaps->getConfigFromBackendFormat(backendFormat, ii.colorType(), &config)) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + // This surface characterization factory assumes that the resulting characterization is + // textureable. + if (!fCaps->isConfigTexturable(config)) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this), + cacheMaxResourceBytes, + origin, ii.width(), ii.height(), config, FSAAType, sampleCnt, + SkSurfaceCharacterization::Textureable(true), + SkSurfaceCharacterization::MipMapped(isMipMapped), + ii.refColorSpace(), surfaceProps); +} + void GrContext::abandonContext() { ASSERT_SINGLE_OWNER @@ -1082,6 +1118,7 @@ bool GrContext::validPMUPMConversionExists() { ////////////////////////////////////////////////////////////////////////////// +// DDL TODO: remove 'maxResources' void GrContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const { ASSERT_SINGLE_OWNER if (maxResources) { |