Index: src/gpu/GrTexture.cpp |
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp |
index 76916aee9ad0c57431b675289e46c46cf842ca8a..270bcbe5fbac94492288da3e230bb0a62985a20d 100644 |
--- a/src/gpu/GrTexture.cpp |
+++ b/src/gpu/GrTexture.cpp |
@@ -14,6 +14,10 @@ |
#include "GrRenderTargetPriv.h" |
#include "GrTexture.h" |
#include "GrTexturePriv.h" |
+#include "GrTypes.h" |
+#include "SkMath.h" |
+#include "SkMipMap.h" |
+#include "SkTypes.h" |
void GrTexture::dirtyMipMaps(bool mipMapsDirty) { |
if (mipMapsDirty) { |
@@ -26,6 +30,8 @@ void GrTexture::dirtyMipMaps(bool mipMapsDirty) { |
if (sizeChanged) { |
// This must not be called until after changing fMipMapsStatus. |
this->didChangeGpuMemorySize(); |
+ // TODO(http://skbug.com/4548) - The desc and scratch key should be |
+ // updated to reflect the newly-allocated mipmaps. |
} |
} |
} |
@@ -81,16 +87,23 @@ GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) { |
} |
////////////////////////////////////////////////////////////////////////////// |
-GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) |
- : INHERITED(gpu, lifeCycle, desc) |
- , fMipMapsStatus(kNotAllocated_MipMapsStatus) { |
- |
+GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc, |
+ bool wasMipMapDataProvided) |
+ : INHERITED(gpu, lifeCycle, desc) { |
if (!this->isExternal() && !GrPixelConfigIsCompressed(desc.fConfig) && |
!desc.fTextureStorageAllocator.fAllocateTextureStorage) { |
GrScratchKey key; |
GrTexturePriv::ComputeScratchKey(desc, &key); |
this->setScratchKey(key); |
} |
+ |
+ if (wasMipMapDataProvided) { |
+ fMipMapsStatus = kValid_MipMapsStatus; |
+ fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight); |
+ } else { |
+ fMipMapsStatus = kNotAllocated_MipMapsStatus; |
+ fMaxMipMapLevel = 0; |
+ } |
} |
void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) { |
@@ -99,7 +112,9 @@ void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k |
GrSurfaceOrigin origin = resolve_origin(desc); |
uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; |
- SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); |
+ // 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(flags < (1 << 10)); |
SkASSERT(static_cast<int>(origin) < (1 << 8)); |
@@ -107,5 +122,6 @@ void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k |
GrScratchKey::Builder builder(key, kType, 3); |
builder[0] = desc.fWidth; |
builder[1] = desc.fHeight; |
- builder[2] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin << 24); |
+ builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6) | (flags << 14) |
+ | (origin << 24); |
} |