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

Side by Side Diff: src/gpu/GrTexture.cpp

Issue 2058143002: Better (?) interface for controlling sRGB-ness of mipmaps on GrTexture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Set gamma treatment flag appropriately, after uploading CPU mips Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « include/gpu/GrTexture.h ('k') | src/gpu/GrTexturePriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrContext.h" 8 #include "GrContext.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
11 #include "GrResourceKey.h" 11 #include "GrResourceKey.h"
12 #include "GrRenderTarget.h" 12 #include "GrRenderTarget.h"
13 #include "GrRenderTargetPriv.h" 13 #include "GrRenderTargetPriv.h"
14 #include "GrTexture.h" 14 #include "GrTexture.h"
15 #include "GrTexturePriv.h" 15 #include "GrTexturePriv.h"
16 #include "GrTypes.h" 16 #include "GrTypes.h"
17 #include "SkMath.h" 17 #include "SkMath.h"
18 #include "SkMipMap.h" 18 #include "SkMipMap.h"
19 #include "SkTypes.h" 19 #include "SkTypes.h"
20 20
21 void GrTexture::dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect) { 21 void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
22 if (mipMapsDirty) { 22 if (mipMapsDirty) {
23 if (kValid_MipMapsStatus == fMipMapsStatus) { 23 if (kValid_MipMapsStatus == fMipMapsStatus) {
24 fMipMapsStatus = kAllocated_MipMapsStatus; 24 fMipMapsStatus = kAllocated_MipMapsStatus;
25 } 25 }
26 } else { 26 } else {
27 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; 27 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
28 fMipMapsStatus = kValid_MipMapsStatus; 28 fMipMapsStatus = kValid_MipMapsStatus;
29 fMipMapsAreSRGBCorrect = sRGBCorrect;
30 if (sizeChanged) { 29 if (sizeChanged) {
31 // This must not be called until after changing fMipMapsStatus. 30 // This must not be called until after changing fMipMapsStatus.
32 this->didChangeGpuMemorySize(); 31 this->didChangeGpuMemorySize();
33 // TODO(http://skbug.com/4548) - The desc and scratch key should be 32 // TODO(http://skbug.com/4548) - The desc and scratch key should be
34 // updated to reflect the newly-allocated mipmaps. 33 // updated to reflect the newly-allocated mipmaps.
35 } 34 }
36 } 35 }
37 } 36 }
38 37
39 size_t GrTexture::onGpuMemorySize() const { 38 size_t GrTexture::onGpuMemorySize() const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } else { 82 } else {
84 return desc.fOrigin; 83 return desc.fOrigin;
85 } 84 }
86 } 85 }
87 } 86 }
88 87
89 ////////////////////////////////////////////////////////////////////////////// 88 //////////////////////////////////////////////////////////////////////////////
90 GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType , 89 GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType ,
91 bool wasMipMapDataProvided) 90 bool wasMipMapDataProvided)
92 : INHERITED(gpu, desc) 91 : INHERITED(gpu, desc)
93 , fSamplerType(samplerType) { 92 , fSamplerType(samplerType)
93 // Gamma treatment is explicitly set after creation via GrTexturePriv
94 , fGammaTreatment(SkSourceGammaTreatment::kIgnore) {
94 if (wasMipMapDataProvided) { 95 if (wasMipMapDataProvided) {
95 fMipMapsStatus = kValid_MipMapsStatus; 96 fMipMapsStatus = kValid_MipMapsStatus;
96 fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeigh t); 97 fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeigh t);
97 // At the moment, the CPU code for generating mipmaps doesn't account fo r sRGB:
98 fMipMapsAreSRGBCorrect = false;
99 } else { 98 } else {
100 fMipMapsStatus = kNotAllocated_MipMapsStatus; 99 fMipMapsStatus = kNotAllocated_MipMapsStatus;
101 fMaxMipMapLevel = 0; 100 fMaxMipMapLevel = 0;
102 fMipMapsAreSRGBCorrect = false;
103 } 101 }
104 } 102 }
105 103
106 void GrTexture::computeScratchKey(GrScratchKey* key) const { 104 void GrTexture::computeScratchKey(GrScratchKey* key) const {
107 if (!GrPixelConfigIsCompressed(fDesc.fConfig)) { 105 if (!GrPixelConfigIsCompressed(fDesc.fConfig)) {
108 GrTexturePriv::ComputeScratchKey(fDesc, key); 106 GrTexturePriv::ComputeScratchKey(fDesc, key);
109 } 107 }
110 } 108 }
111 109
112 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) { 110 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) {
113 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType(); 111 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType();
114 112
115 GrSurfaceOrigin origin = resolve_origin(desc); 113 GrSurfaceOrigin origin = resolve_origin(desc);
116 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; 114 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag;
117 115
118 // make sure desc.fConfig fits in 5 bits 116 // make sure desc.fConfig fits in 5 bits
119 SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5); 117 SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5);
120 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5)); 118 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5));
121 SkASSERT(desc.fSampleCnt < (1 << 8)); 119 SkASSERT(desc.fSampleCnt < (1 << 8));
122 SkASSERT(flags < (1 << 10)); 120 SkASSERT(flags < (1 << 10));
123 SkASSERT(static_cast<int>(origin) < (1 << 8)); 121 SkASSERT(static_cast<int>(origin) < (1 << 8));
124 122
125 GrScratchKey::Builder builder(key, kType, 3); 123 GrScratchKey::Builder builder(key, kType, 3);
126 builder[0] = desc.fWidth; 124 builder[0] = desc.fWidth;
127 builder[1] = desc.fHeight; 125 builder[1] = desc.fHeight;
128 builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6 ) | (flags << 14) 126 builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6 ) | (flags << 14)
129 | (origin << 24); 127 | (origin << 24);
130 } 128 }
OLDNEW
« no previous file with comments | « include/gpu/GrTexture.h ('k') | src/gpu/GrTexturePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698