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

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

Issue 2007973002: Manually generated sRGB mipmaps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Break long columns 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) { 21 void GrTexture::dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect) {
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;
29 if (sizeChanged) { 30 if (sizeChanged) {
30 // This must not be called until after changing fMipMapsStatus. 31 // This must not be called until after changing fMipMapsStatus.
31 this->didChangeGpuMemorySize(); 32 this->didChangeGpuMemorySize();
32 // TODO(http://skbug.com/4548) - The desc and scratch key should be 33 // TODO(http://skbug.com/4548) - The desc and scratch key should be
33 // updated to reflect the newly-allocated mipmaps. 34 // updated to reflect the newly-allocated mipmaps.
34 } 35 }
35 } 36 }
36 } 37 }
37 38
38 size_t GrTexture::onGpuMemorySize() const { 39 size_t GrTexture::onGpuMemorySize() const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 87 }
87 88
88 ////////////////////////////////////////////////////////////////////////////// 89 //////////////////////////////////////////////////////////////////////////////
89 GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType , 90 GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType ,
90 bool wasMipMapDataProvided) 91 bool wasMipMapDataProvided)
91 : INHERITED(gpu, desc) 92 : INHERITED(gpu, desc)
92 , fSamplerType(samplerType) { 93 , fSamplerType(samplerType) {
93 if (wasMipMapDataProvided) { 94 if (wasMipMapDataProvided) {
94 fMipMapsStatus = kValid_MipMapsStatus; 95 fMipMapsStatus = kValid_MipMapsStatus;
95 fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeigh t); 96 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;
96 } else { 99 } else {
97 fMipMapsStatus = kNotAllocated_MipMapsStatus; 100 fMipMapsStatus = kNotAllocated_MipMapsStatus;
98 fMaxMipMapLevel = 0; 101 fMaxMipMapLevel = 0;
102 fMipMapsAreSRGBCorrect = false;
99 } 103 }
100 } 104 }
101 105
102 void GrTexture::computeScratchKey(GrScratchKey* key) const { 106 void GrTexture::computeScratchKey(GrScratchKey* key) const {
103 if (!GrPixelConfigIsCompressed(fDesc.fConfig)) { 107 if (!GrPixelConfigIsCompressed(fDesc.fConfig)) {
104 GrTexturePriv::ComputeScratchKey(fDesc, key); 108 GrTexturePriv::ComputeScratchKey(fDesc, key);
105 } 109 }
106 } 110 }
107 111
108 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) { 112 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) {
109 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType(); 113 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType();
110 114
111 GrSurfaceOrigin origin = resolve_origin(desc); 115 GrSurfaceOrigin origin = resolve_origin(desc);
112 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; 116 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag;
113 117
114 // make sure desc.fConfig fits in 5 bits 118 // make sure desc.fConfig fits in 5 bits
115 SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5); 119 SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5);
116 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5)); 120 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5));
117 SkASSERT(desc.fSampleCnt < (1 << 8)); 121 SkASSERT(desc.fSampleCnt < (1 << 8));
118 SkASSERT(flags < (1 << 10)); 122 SkASSERT(flags < (1 << 10));
119 SkASSERT(static_cast<int>(origin) < (1 << 8)); 123 SkASSERT(static_cast<int>(origin) < (1 << 8));
120 124
121 GrScratchKey::Builder builder(key, kType, 3); 125 GrScratchKey::Builder builder(key, kType, 3);
122 builder[0] = desc.fWidth; 126 builder[0] = desc.fWidth;
123 builder[1] = desc.fHeight; 127 builder[1] = desc.fHeight;
124 builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6 ) | (flags << 14) 128 builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6 ) | (flags << 14)
125 | (origin << 24); 129 | (origin << 24);
126 } 130 }
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