aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTexture.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-05-18 12:30:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-18 16:56:50 +0000
commit84911546b9535a2fff6c5e07f588f175d5a04f45 (patch)
treea159707e8fbf27532b354b18feb231be69c12acc /src/gpu/GrTexture.cpp
parent955235fa13db6cfd615dd6120e7f5060761fa3d1 (diff)
Remove GrSurfaceDesc member from GrSurface.
Change-Id: I0fe979994e1e3fc457b952dfb5e0090c45fad771 Reviewed-on: https://skia-review.googlesource.com/17273 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r--src/gpu/GrTexture.cpp52
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);
}