Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: src/gpu/GrTexture.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fixing incorrect rebase. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrTexture.cpp
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 7984460545db61d3b5dfb8c6120f24719e909365..c837c0e4e24be5cbf0dc432cafdda71f8067af02 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -14,11 +14,12 @@
#include "GrRenderTargetPriv.h"
#include "GrTexture.h"
#include "GrTexturePriv.h"
+#include "SkFloatingPoint.h"
void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
if (mipMapsDirty) {
if (kValid_MipMapsStatus == fMipMapsStatus) {
- fMipMapsStatus = kAllocated_MipMapsStatus;
+ fMipMapsStatus = kAllocated_MipMapsStatus;
}
} else {
const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
@@ -82,8 +83,7 @@ GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) {
//////////////////////////////////////////////////////////////////////////////
GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
- : INHERITED(gpu, lifeCycle, desc)
- , fMipMapsStatus(kNotAllocated_MipMapsStatus) {
+ : INHERITED(gpu, lifeCycle, desc) {
if (!this->isExternal() && !GrPixelConfigIsCompressed(desc.fConfig)) {
GrScratchKey key;
@@ -93,6 +93,11 @@ GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
// only make sense if alloc size is pow2
fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
+ if (desc.fIsMipMapped) {
+ fMipMapsStatus = kAllocated_MipMapsStatus;
+ } else {
+ fMipMapsStatus = kNotAllocated_MipMapsStatus;
+ }
}
void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
@@ -105,11 +110,14 @@ void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k
SkASSERT(desc.fWidth <= SK_MaxU16);
SkASSERT(desc.fHeight <= SK_MaxU16);
- 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));
builder[0] = desc.fWidth | (desc.fHeight << 16);
- builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin << 24);
+ builder[1] = desc.fConfig | desc.fIsMipMapped << 5 | (desc.fSampleCnt << 6) | (flags << 14)
+ | (origin << 24);
}

Powered by Google App Engine
This is Rietveld 408576698