aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTexture.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-05-18 18:13:40 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-18 18:13:48 +0000
commit4b30a96a3e96b7f051e25025f4f17f3c54e04153 (patch)
tree72e0561a19df0db0ca111ee58e4730b2068adb28 /src/gpu/GrTexture.cpp
parent14d54c207d7a175d14d34f5527af7cbfd579f4d5 (diff)
Revert "Remove GrSurfaceDesc member from GrSurface."
This reverts commit 84911546b9535a2fff6c5e07f588f175d5a04f45. Reason for revert: Breaking bots possibly? Original change's description: > 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> > TBR=bsalomon@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I404e509fcd3e3d5527b3bc6e286b7d436c12e879 Reviewed-on: https://skia-review.googlesource.com/17364 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r--src/gpu/GrTexture.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index cbab5f0f60..0aa1ac07a6 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -40,7 +40,18 @@ 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 {
@@ -68,7 +79,7 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
, fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) {
if (wasMipMapDataProvided) {
fMipMapsStatus = kValid_MipMapsStatus;
- fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height());
+ fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight);
} else {
fMipMapsStatus = kNotAllocated_MipMapsStatus;
fMaxMipMapLevel = 0;
@@ -76,42 +87,27 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
}
void GrTexture::computeScratchKey(GrScratchKey* key) const {
- 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);
+ if (!GrPixelConfigIsCompressed(fDesc.fConfig)) {
+ GrTexturePriv::ComputeScratchKey(fDesc, key);
}
}
-void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int height,
- GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt,
- bool isMipMapped, GrScratchKey* key) {
+void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
- uint32_t flags = isRenderTarget;
- SkASSERT(0 == sampleCnt || isRenderTarget);
+ GrSurfaceOrigin origin = resolve_origin(desc);
+ uint32_t flags = desc.fFlags;
// make sure desc.fConfig fits in 5 bits
SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5);
- SkASSERT(static_cast<int>(config) < (1 << 5));
- SkASSERT(sampleCnt < (1 << 8));
+ SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5));
+ SkASSERT(desc.fSampleCnt < (1 << 8));
SkASSERT(flags < (1 << 10));
SkASSERT(static_cast<int>(origin) < (1 << 8));
GrScratchKey::Builder builder(key, kType, 3);
- 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);
+ builder[0] = desc.fWidth;
+ builder[1] = desc.fHeight;
+ builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6) | (flags << 14)
+ | (origin << 24);
}