diff options
author | Brian Salomon <bsalomon@google.com> | 2017-05-19 15:45:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-21 11:41:17 +0000 |
commit | d34edf3dc902532f88842f35375c474f94f82d83 (patch) | |
tree | 06a38d69c351e6675467daeafc1439124561cbd0 /src/gpu/GrTexture.cpp | |
parent | 76149aa5fba375ebedab3d0422e0677e0bb102a7 (diff) |
Revert "Revert "Remove GrSurfaceDesc member from GrSurface.""
This reverts commit 4b30a96a3e96b7f051e25025f4f17f3c54e04153.
Bug: skia:
Change-Id: I14d5b402c87df8fffbc29f16686fcfa18474fc48
Reviewed-on: https://skia-review.googlesource.com/17408
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r-- | src/gpu/GrTexture.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index 0aa1ac07a6..cbab5f0f60 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -40,18 +40,7 @@ size_t GrTexture::onGpuMemorySize() const { this->texturePriv().hasMipMaps(), false); } -void GrTexture::validateDesc() const { - if (this->asRenderTarget()) { - // This texture has a render target - SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); - SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numColorSamples()); - } else { - SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); - SkASSERT(0 == fDesc.fSampleCnt); - } -} - -////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// namespace { @@ -79,7 +68,7 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) { if (wasMipMapDataProvided) { fMipMapsStatus = kValid_MipMapsStatus; - fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight); + fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height()); } else { fMipMapsStatus = kNotAllocated_MipMapsStatus; fMaxMipMapLevel = 0; @@ -87,27 +76,42 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType } void GrTexture::computeScratchKey(GrScratchKey* key) const { - if (!GrPixelConfigIsCompressed(fDesc.fConfig)) { - GrTexturePriv::ComputeScratchKey(fDesc, key); + if (!GrPixelConfigIsCompressed(this->config())) { + const GrRenderTarget* rt = this->asRenderTarget(); + int sampleCount = 0; + if (rt) { + sampleCount = rt->numStencilSamples(); + } + GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(), + this->origin(), SkToBool(rt), sampleCount, + this->texturePriv().hasMipMaps(), key); } } -void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) { +void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int height, + GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt, + bool isMipMapped, GrScratchKey* key) { static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType(); + uint32_t flags = isRenderTarget; - GrSurfaceOrigin origin = resolve_origin(desc); - uint32_t flags = desc.fFlags; + SkASSERT(0 == sampleCnt || isRenderTarget); // make sure desc.fConfig fits in 5 bits SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5); - SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5)); - SkASSERT(desc.fSampleCnt < (1 << 8)); + SkASSERT(static_cast<int>(config) < (1 << 5)); + SkASSERT(sampleCnt < (1 << 8)); SkASSERT(flags < (1 << 10)); SkASSERT(static_cast<int>(origin) < (1 << 8)); GrScratchKey::Builder builder(key, kType, 3); - builder[0] = desc.fWidth; - builder[1] = desc.fHeight; - builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6) | (flags << 14) - | (origin << 24); + builder[0] = width; + builder[1] = height; + builder[2] = config | (isMipMapped << 5) | (sampleCnt << 6) | (flags << 14) | (origin << 24); +} + +void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) { + GrSurfaceOrigin origin = resolve_origin(desc); + return ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight, origin, + SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag), desc.fSampleCnt, + desc.fIsMipMapped, key); } |