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

Side by Side Diff: src/gpu/gl/GrGLGpu.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 | « src/gpu/SkGr.cpp ('k') | no next file » | 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 "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 3174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 3185
3186 if (GrTextureParams::kMipMap_FilterMode == filterMode) { 3186 if (GrTextureParams::kMipMap_FilterMode == filterMode) {
3187 if (!this->caps()->mipMapSupport() || GrPixelConfigIsCompressed(texture- >config())) { 3187 if (!this->caps()->mipMapSupport() || GrPixelConfigIsCompressed(texture- >config())) {
3188 filterMode = GrTextureParams::kBilerp_FilterMode; 3188 filterMode = GrTextureParams::kBilerp_FilterMode;
3189 } 3189 }
3190 } 3190 }
3191 3191
3192 newTexParams.fMinFilter = glMinFilterModes[filterMode]; 3192 newTexParams.fMinFilter = glMinFilterModes[filterMode];
3193 newTexParams.fMagFilter = glMagFilterModes[filterMode]; 3193 newTexParams.fMagFilter = glMagFilterModes[filterMode];
3194 3194
3195 bool enableSRGBDecode = false;
3196 if (GrPixelConfigIsSRGB(texture->config())) { 3195 if (GrPixelConfigIsSRGB(texture->config())) {
3197 enableSRGBDecode = allowSRGBInputs; 3196 newTexParams.fSRGBDecode = allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SK IP_DECODE_EXT;
3198
3199 newTexParams.fSRGBDecode = enableSRGBDecode ? GR_GL_DECODE_EXT : GR_GL_S KIP_DECODE_EXT;
3200 if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) { 3197 if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) {
3201 this->setTextureUnit(unitIdx); 3198 this->setTextureUnit(unitIdx);
3202 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexP arams.fSRGBDecode)); 3199 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexP arams.fSRGBDecode));
3203 } 3200 }
3204 } 3201 }
3205 3202
3206 #ifdef SK_DEBUG 3203 #ifdef SK_DEBUG
3207 // We were supposed to ensure MipMaps were up-to-date and built correctly be fore getting here. 3204 // We were supposed to ensure MipMaps were up-to-date and built correctly be fore getting here.
3208 if (GrTextureParams::kMipMap_FilterMode == filterMode) { 3205 if (GrTextureParams::kMipMap_FilterMode == filterMode) {
3209 SkASSERT(!texture->texturePriv().mipMapsAreDirty()); 3206 SkASSERT(!texture->texturePriv().mipMapsAreDirty());
3210 if (GrPixelConfigIsSRGB(texture->config())) { 3207 if (GrPixelConfigIsSRGB(texture->config())) {
3211 SkASSERT(texture->texturePriv().mipMapsAreSRGBCorrect() == enableSRG BDecode); 3208 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs ?
3209 SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgno re;
3210 SkASSERT(texture->texturePriv().gammaTreatment() == gammaTreatment);
3212 } 3211 }
3213 } 3212 }
3214 #endif 3213 #endif
3215 3214
3216 newTexParams.fMaxMipMapLevel = texture->texturePriv().maxMipMapLevel(); 3215 newTexParams.fMaxMipMapLevel = texture->texturePriv().maxMipMapLevel();
3217 3216
3218 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); 3217 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
3219 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); 3218 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY());
3220 get_tex_param_swizzle(texture->config(), this->glCaps(), newTexParams.fSwizz leRGBA); 3219 get_tex_param_swizzle(texture->config(), this->glCaps(), newTexParams.fSwizz leRGBA);
3221 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { 3220 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 } 3313 }
3315 } 3314 }
3316 3315
3317 if (GrTextureParams::kMipMap_FilterMode != filterMode) { 3316 if (GrTextureParams::kMipMap_FilterMode != filterMode) {
3318 return; 3317 return;
3319 } 3318 }
3320 3319
3321 // If this is an sRGB texture and the mips were previously built the "other" way 3320 // If this is an sRGB texture and the mips were previously built the "other" way
3322 // (gamma-correct vs. not), then we need to rebuild them. We don't need to c heck for 3321 // (gamma-correct vs. not), then we need to rebuild them. We don't need to c heck for
3323 // srgbSupport - we'll *never* get an sRGB pixel config if we don't support it. 3322 // srgbSupport - we'll *never* get an sRGB pixel config if we don't support it.
3323 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
3324 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
3324 if (GrPixelConfigIsSRGB(texture->config()) && 3325 if (GrPixelConfigIsSRGB(texture->config()) &&
3325 allowSRGBInputs != texture->texturePriv().mipMapsAreSRGBCorrect()) { 3326 gammaTreatment != texture->texturePriv().gammaTreatment()) {
3326 texture->texturePriv().dirtyMipMaps(true); 3327 texture->texturePriv().dirtyMipMaps(true);
3327 } 3328 }
3328 3329
3329 // If the mips aren't dirty, we're done: 3330 // If the mips aren't dirty, we're done:
3330 if (!texture->texturePriv().mipMapsAreDirty()) { 3331 if (!texture->texturePriv().mipMapsAreDirty()) {
3331 return; 3332 return;
3332 } 3333 }
3333 3334
3334 // If we created a rt/tex and rendered to it without using a texture and now we're texturing 3335 // If we created a rt/tex and rendered to it without using a texture and now we're texturing
3335 // from the rt it will still be the last bound texture, but it needs resolvi ng. 3336 // from the rt it will still be the last bound texture, but it needs resolvi ng.
(...skipping 11 matching lines...) Expand all
3347 if (GrPixelConfigIsSRGB(texture->config())) { 3348 if (GrPixelConfigIsSRGB(texture->config())) {
3348 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, 3349 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT,
3349 allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DE CODE_EXT)); 3350 allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DE CODE_EXT));
3350 } 3351 }
3351 3352
3352 // Either do manual mipmap generation or (if that fails), just rely on the d river: 3353 // Either do manual mipmap generation or (if that fails), just rely on the d river:
3353 if (!this->generateMipmap(texture, allowSRGBInputs)) { 3354 if (!this->generateMipmap(texture, allowSRGBInputs)) {
3354 GL_CALL(GenerateMipmap(target)); 3355 GL_CALL(GenerateMipmap(target));
3355 } 3356 }
3356 3357
3357 texture->texturePriv().dirtyMipMaps(false, allowSRGBInputs); 3358 texture->texturePriv().dirtyMipMaps(false);
3358 texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount( 3359 texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount(
3359 texture->width(), texture->height())); 3360 texture->width(), texture->height()));
3361 texture->texturePriv().setGammaTreatment(gammaTreatment);
3360 3362
3361 // We have potentially set lots of state on the texture. Easiest to dirty it all: 3363 // We have potentially set lots of state on the texture. Easiest to dirty it all:
3362 texture->textureParamsModified(); 3364 texture->textureParamsModified();
3363 } 3365 }
3364 3366
3365 void GrGLGpu::setTextureSwizzle(int unitIdx, GrGLenum target, const GrGLenum swi zzle[]) { 3367 void GrGLGpu::setTextureSwizzle(int unitIdx, GrGLenum target, const GrGLenum swi zzle[]) {
3366 this->setTextureUnit(unitIdx); 3368 this->setTextureUnit(unitIdx);
3367 if (this->glStandard() == kGLES_GrGLStandard) { 3369 if (this->glStandard() == kGLES_GrGLStandard) {
3368 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA. 3370 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA.
3369 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_R, swizzle[0])); 3371 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_R, swizzle[0]));
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
4645 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4647 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4646 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4648 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4647 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4649 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4648 copyParams->fWidth = texture->width(); 4650 copyParams->fWidth = texture->width();
4649 copyParams->fHeight = texture->height(); 4651 copyParams->fHeight = texture->height();
4650 return true; 4652 return true;
4651 } 4653 }
4652 } 4654 }
4653 return false; 4655 return false;
4654 } 4656 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698