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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1569393002: Revert of Add a class representing texture swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('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 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 return GR_GL_ALPHA; 2478 return GR_GL_ALPHA;
2479 default: 2479 default:
2480 SkFAIL("Unsupported component"); 2480 SkFAIL("Unsupported component");
2481 return 0; 2481 return 0;
2482 } 2482 }
2483 } 2483 }
2484 2484
2485 /** If texture swizzling is available using tex parameters then it is preferred over mangling 2485 /** If texture swizzling is available using tex parameters then it is preferred over mangling
2486 the generated shader code. This potentially allows greater reuse of cached sha ders. */ 2486 the generated shader code. This potentially allows greater reuse of cached sha ders. */
2487 static void get_tex_param_swizzle(GrPixelConfig config, 2487 static void get_tex_param_swizzle(GrPixelConfig config,
2488 const GrGLCaps& caps, 2488 const GrGLSLCaps& caps,
2489 GrGLenum* glSwizzle) { 2489 GrGLenum* glSwizzle) {
2490 const GrSwizzle& swizzle = caps.configSwizzle(config); 2490 const char* swizzle = caps.getSwizzleMap(config);
2491 for (int i = 0; i < 4; ++i) { 2491 for (int i = 0; i < 4; ++i) {
2492 glSwizzle[i] = get_component_enum_from_char(swizzle.c_str()[i]); 2492 glSwizzle[i] = get_component_enum_from_char(swizzle[i]);
2493 } 2493 }
2494 } 2494 }
2495 2495
2496 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) { 2496 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) {
2497 SkASSERT(texture); 2497 SkASSERT(texture);
2498 2498
2499 #ifdef SK_DEBUG 2499 #ifdef SK_DEBUG
2500 if (!this->caps()->npotTextureTileSupport()) { 2500 if (!this->caps()->npotTextureTileSupport()) {
2501 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX(); 2501 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX();
2502 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY(); 2502 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 newTexParams.fMagFilter = glMagFilterModes[filterMode]; 2551 newTexParams.fMagFilter = glMagFilterModes[filterMode];
2552 2552
2553 if (GrTextureParams::kMipMap_FilterMode == filterMode && 2553 if (GrTextureParams::kMipMap_FilterMode == filterMode &&
2554 texture->texturePriv().mipMapsAreDirty()) { 2554 texture->texturePriv().mipMapsAreDirty()) {
2555 GL_CALL(GenerateMipmap(target)); 2555 GL_CALL(GenerateMipmap(target));
2556 texture->texturePriv().dirtyMipMaps(false); 2556 texture->texturePriv().dirtyMipMaps(false);
2557 } 2557 }
2558 2558
2559 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); 2559 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
2560 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); 2560 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY());
2561 get_tex_param_swizzle(texture->config(), this->glCaps(), newTexParams.fSwizz leRGBA); 2561 get_tex_param_swizzle(texture->config(), *this->glCaps().glslCaps(), newTexP arams.fSwizzleRGBA);
2562 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { 2562 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) {
2563 this->setTextureUnit(unitIdx); 2563 this->setTextureUnit(unitIdx);
2564 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMa gFilter)); 2564 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMa gFilter));
2565 } 2565 }
2566 if (setAll || newTexParams.fMinFilter != oldTexParams.fMinFilter) { 2566 if (setAll || newTexParams.fMinFilter != oldTexParams.fMinFilter) {
2567 this->setTextureUnit(unitIdx); 2567 this->setTextureUnit(unitIdx);
2568 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, newTexParams.fMi nFilter)); 2568 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, newTexParams.fMi nFilter));
2569 } 2569 }
2570 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { 2570 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) {
2571 this->setTextureUnit(unitIdx); 2571 this->setTextureUnit(unitIdx);
2572 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_S, newTexParams.fWrapS) ); 2572 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_S, newTexParams.fWrapS) );
2573 } 2573 }
2574 if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) { 2574 if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) {
2575 this->setTextureUnit(unitIdx); 2575 this->setTextureUnit(unitIdx);
2576 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_T, newTexParams.fWrapT) ); 2576 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_T, newTexParams.fWrapT) );
2577 } 2577 }
2578 if (this->glCaps().textureSwizzleSupport() && 2578 if (!this->glCaps().glslCaps()->mustSwizzleInShader() &&
2579 (setAll || memcmp(newTexParams.fSwizzleRGBA, 2579 (setAll || memcmp(newTexParams.fSwizzleRGBA,
2580 oldTexParams.fSwizzleRGBA, 2580 oldTexParams.fSwizzleRGBA,
2581 sizeof(newTexParams.fSwizzleRGBA)))) { 2581 sizeof(newTexParams.fSwizzleRGBA)))) {
2582 this->setTextureUnit(unitIdx); 2582 this->setTextureUnit(unitIdx);
2583 if (this->glStandard() == kGLES_GrGLStandard) { 2583 if (this->glStandard() == kGLES_GrGLStandard) {
2584 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA. 2584 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA.
2585 const GrGLenum* swizzle = newTexParams.fSwizzleRGBA; 2585 const GrGLenum* swizzle = newTexParams.fSwizzleRGBA;
2586 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_R, swizzle[0])); 2586 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_R, swizzle[0]));
2587 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_G, swizzle[1])); 2587 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_G, swizzle[1]));
2588 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_B, swizzle[2])); 2588 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SWIZZLE_B, swizzle[2]));
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 this->setVertexArrayID(gpu, 0); 3427 this->setVertexArrayID(gpu, 0);
3428 } 3428 }
3429 int attrCount = gpu->glCaps().maxVertexAttributes(); 3429 int attrCount = gpu->glCaps().maxVertexAttributes();
3430 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3430 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3431 fDefaultVertexArrayAttribState.resize(attrCount); 3431 fDefaultVertexArrayAttribState.resize(attrCount);
3432 } 3432 }
3433 attribState = &fDefaultVertexArrayAttribState; 3433 attribState = &fDefaultVertexArrayAttribState;
3434 } 3434 }
3435 return attribState; 3435 return attribState;
3436 } 3436 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698