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

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

Issue 23128009: Use ES3 texture swizzling. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLCaps.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 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 fHWBlendState.fConstColor != blendConst)) { 1968 fHWBlendState.fConstColor != blendConst)) {
1969 GrGLfloat c[4]; 1969 GrGLfloat c[4];
1970 GrColorToRGBAFloat(blendConst, c); 1970 GrColorToRGBAFloat(blendConst, c);
1971 GL_CALL(BlendColor(c[0], c[1], c[2], c[3])); 1971 GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
1972 fHWBlendState.fConstColor = blendConst; 1972 fHWBlendState.fConstColor = blendConst;
1973 fHWBlendState.fConstColorValid = true; 1973 fHWBlendState.fConstColorValid = true;
1974 } 1974 }
1975 } 1975 }
1976 } 1976 }
1977 } 1977 }
1978 namespace {
1979 1978
1980 inline void set_tex_swizzle(GrGLenum swizzle[4], const GrGLInterface* gl) { 1979 static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
1981 GR_GL_CALL(gl, TexParameteriv(GR_GL_TEXTURE_2D,
1982 GR_GL_TEXTURE_SWIZZLE_RGBA,
1983 reinterpret_cast<const GrGLint*>(swizzle)));
1984 }
1985
1986 inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
1987 static const GrGLenum gWrapModes[] = { 1980 static const GrGLenum gWrapModes[] = {
1988 GR_GL_CLAMP_TO_EDGE, 1981 GR_GL_CLAMP_TO_EDGE,
1989 GR_GL_REPEAT, 1982 GR_GL_REPEAT,
1990 GR_GL_MIRRORED_REPEAT 1983 GR_GL_MIRRORED_REPEAT
1991 }; 1984 };
1992 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes)); 1985 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes));
1993 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode); 1986 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode);
1994 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode); 1987 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode);
1995 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode); 1988 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode);
1996 return gWrapModes[tm]; 1989 return gWrapModes[tm];
1997 } 1990 }
1998 1991
1999 }
2000
2001 void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) { 1992 void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) {
2002 SkASSERT(NULL != texture); 1993 SkASSERT(NULL != texture);
2003 1994
2004 // If we created a rt/tex and rendered to it without using a texture and now we're texturing 1995 // If we created a rt/tex and rendered to it without using a texture and now we're texturing
2005 // from the rt it will still be the last bound texture, but it needs resolvi ng. So keep this 1996 // from the rt it will still be the last bound texture, but it needs resolvi ng. So keep this
2006 // out of the "last != next" check. 1997 // out of the "last != next" check.
2007 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT arget()); 1998 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT arget());
2008 if (NULL != texRT) { 1999 if (NULL != texRT) {
2009 this->onResolveRenderTarget(texRT); 2000 this->onResolveRenderTarget(texRT);
2010 } 2001 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 this->setTextureUnit(unitIdx); 2060 this->setTextureUnit(unitIdx);
2070 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 2061 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
2071 GR_GL_TEXTURE_WRAP_T, 2062 GR_GL_TEXTURE_WRAP_T,
2072 newTexParams.fWrapT)); 2063 newTexParams.fWrapT));
2073 } 2064 }
2074 if (this->glCaps().textureSwizzleSupport() && 2065 if (this->glCaps().textureSwizzleSupport() &&
2075 (setAll || memcmp(newTexParams.fSwizzleRGBA, 2066 (setAll || memcmp(newTexParams.fSwizzleRGBA,
2076 oldTexParams.fSwizzleRGBA, 2067 oldTexParams.fSwizzleRGBA,
2077 sizeof(newTexParams.fSwizzleRGBA)))) { 2068 sizeof(newTexParams.fSwizzleRGBA)))) {
2078 this->setTextureUnit(unitIdx); 2069 this->setTextureUnit(unitIdx);
2079 set_tex_swizzle(newTexParams.fSwizzleRGBA, 2070 if (this->glBinding() == kES_GrGLBinding) {
2080 this->glInterface()); 2071 // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA.
2072 const GrGLenum* swizzle = newTexParams.fSwizzleRGBA;
2073 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_R, swi zzle[0]));
2074 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_G, swi zzle[1]));
2075 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_B, swi zzle[2]));
2076 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi zzle[3]));
2077 } else {
2078 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL int));
2079 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara ms.fSwizzleRGBA);
2080 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA, swizzle));
2081 }
2081 } 2082 }
2082 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); 2083 texture->setCachedTexParams(newTexParams, this->getResetTimestamp());
2083 } 2084 }
2084 2085
2085 void GrGpuGL::flushMiscFixedFunctionState() { 2086 void GrGpuGL::flushMiscFixedFunctionState() {
2086 2087
2087 const GrDrawState& drawState = this->getDrawState(); 2088 const GrDrawState& drawState = this->getDrawState();
2088 2089
2089 if (drawState.isDitherState()) { 2090 if (drawState.isDitherState()) {
2090 if (kYes_TriState != fHWDitherEnabled) { 2091 if (kYes_TriState != fHWDitherEnabled) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 this->setVertexArrayID(gpu, 0); 2553 this->setVertexArrayID(gpu, 0);
2553 } 2554 }
2554 int attrCount = gpu->glCaps().maxVertexAttributes(); 2555 int attrCount = gpu->glCaps().maxVertexAttributes();
2555 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2556 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2556 fDefaultVertexArrayAttribState.resize(attrCount); 2557 fDefaultVertexArrayAttribState.resize(attrCount);
2557 } 2558 }
2558 attribState = &fDefaultVertexArrayAttribState; 2559 attribState = &fDefaultVertexArrayAttribState;
2559 } 2560 }
2560 return attribState; 2561 return attribState;
2561 } 2562 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698