diff options
author | 2011-11-14 19:29:53 +0000 | |
---|---|---|
committer | 2011-11-14 19:29:53 +0000 | |
commit | 1dcf506a1aa3771d1b36831da2ab3ce9fd6e1900 (patch) | |
tree | 2bce9916438600f8b437101854f5dfe16071467c /src/gpu | |
parent | ffdb018dae05f1688c6c036299f8c8a0f28342e5 (diff) |
Remove GrGpuGLFixed subclass and ES1 support
Review URL: http://codereview.appspot.com/5376094/
git-svn-id: http://skia.googlecode.com/svn/trunk@2678 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrGLInterface.cpp | 129 | ||||
-rw-r--r-- | src/gpu/GrGLProgram.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrGLTexture.cpp | 17 | ||||
-rw-r--r-- | src/gpu/GrGLTexture.h | 2 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/GrGpuFactory.cpp | 26 | ||||
-rw-r--r-- | src/gpu/GrGpuGL.cpp | 60 | ||||
-rw-r--r-- | src/gpu/GrGpuGLFixed.cpp | 382 | ||||
-rw-r--r-- | src/gpu/GrGpuGLFixed.h | 66 | ||||
-rw-r--r-- | src/gpu/GrGpuGLShaders.cpp | 3 | ||||
-rw-r--r-- | src/gpu/app-android.cpp | 1 | ||||
-rw-r--r-- | src/gpu/ios/GrGLDefaultInterface_iOS.cpp | 5 |
13 files changed, 71 insertions, 634 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 12b8b07a0e..ca01192b77 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -55,10 +55,6 @@ GrContext* GrContext::Create(GrEngine engine, return ctx; } -GrContext* GrContext::CreateGLShaderContext() { - return GrContext::Create(kOpenGL_Shaders_GrEngine, 0); -} - GrContext::~GrContext() { this->flush(); delete fTextureCache; diff --git a/src/gpu/GrGLInterface.cpp b/src/gpu/GrGLInterface.cpp index 471b5a66cd..b70e2074e7 100644 --- a/src/gpu/GrGLInterface.cpp +++ b/src/gpu/GrGLInterface.cpp @@ -241,83 +241,21 @@ GrGLInterface::GrGLInterface() { #endif } - -bool GrGLInterface::validateShaderFunctions() const { - // required for GrGpuGLShaders - if (NULL == fAttachShader || - NULL == fBindAttribLocation || - NULL == fCompileShader || - NULL == fCreateProgram || - NULL == fCreateShader || - NULL == fDeleteProgram || - NULL == fDeleteShader || - NULL == fDisableVertexAttribArray || - NULL == fEnableVertexAttribArray || - NULL == fGetProgramInfoLog || - NULL == fGetProgramiv || - NULL == fGetShaderInfoLog || - NULL == fGetShaderiv || - NULL == fGetUniformLocation || - NULL == fLinkProgram || - NULL == fShaderSource || - NULL == fUniform1f || - NULL == fUniform1i || - NULL == fUniform1fv || - NULL == fUniform1iv || - NULL == fUniform2f || - NULL == fUniform2i || - NULL == fUniform2fv || - NULL == fUniform2iv || - NULL == fUniform3f || - NULL == fUniform3i || - NULL == fUniform3fv || - NULL == fUniform3iv || - NULL == fUniform4f || - NULL == fUniform4i || - NULL == fUniform4fv || - NULL == fUniform4iv || - NULL == fUniformMatrix2fv || - NULL == fUniformMatrix3fv || - NULL == fUniformMatrix4fv || - NULL == fUseProgram || - NULL == fVertexAttrib4fv || - NULL == fVertexAttribPointer) { - return false; - } - return true; -} - -bool GrGLInterface::validateFixedFunctions() const { - if (NULL == fClientActiveTexture || - NULL == fColor4ub || - NULL == fColorPointer || - NULL == fDisableClientState || - NULL == fEnableClientState || - NULL == fLoadMatrixf || - NULL == fMatrixMode || - NULL == fPointSize || - NULL == fShadeModel || - NULL == fTexCoordPointer || - NULL == fTexEnvi || - NULL == fVertexPointer) { - return false; - } - return true; -} - -bool GrGLInterface::validate(GrEngine engine) const { +bool GrGLInterface::validate() const { bool isDesktop = this->supportsDesktop(); - bool isES = this->supportsES(); + bool isES2 = this->supportsES2(); - if (isDesktop == isES) { + if (isDesktop == isES2) { // must have one, don't support both in same interface return false; } // functions that are always required if (NULL == fActiveTexture || + NULL == fAttachShader || + NULL == fBindAttribLocation || NULL == fBindBuffer || NULL == fBindTexture || NULL == fBlendFunc || @@ -327,30 +265,66 @@ bool GrGLInterface::validate(GrEngine engine) const { NULL == fClearColor || NULL == fClearStencil || NULL == fColorMask || + NULL == fCompileShader || + NULL == fCreateProgram || + NULL == fCreateShader || NULL == fCullFace || NULL == fDeleteBuffers || + NULL == fDeleteProgram || + NULL == fDeleteShader || NULL == fDeleteTextures || NULL == fDepthMask || NULL == fDisable || + NULL == fDisableVertexAttribArray || NULL == fDrawArrays || NULL == fDrawElements || NULL == fEnable || + NULL == fEnableVertexAttribArray || NULL == fFrontFace || NULL == fGenBuffers || NULL == fGenTextures || NULL == fGetBufferParameteriv || NULL == fGetError || NULL == fGetIntegerv || + NULL == fGetProgramInfoLog || + NULL == fGetProgramiv || + NULL == fGetShaderInfoLog || + NULL == fGetShaderiv || NULL == fGetString || + NULL == fGetUniformLocation || + NULL == fLinkProgram || NULL == fPixelStorei || NULL == fReadPixels || NULL == fScissor || + NULL == fShaderSource || NULL == fStencilFunc || NULL == fStencilMask || NULL == fStencilOp || NULL == fTexImage2D || NULL == fTexParameteri || NULL == fTexSubImage2D || + NULL == fUniform1f || + NULL == fUniform1i || + NULL == fUniform1fv || + NULL == fUniform1iv || + NULL == fUniform2f || + NULL == fUniform2i || + NULL == fUniform2fv || + NULL == fUniform2iv || + NULL == fUniform3f || + NULL == fUniform3i || + NULL == fUniform3fv || + NULL == fUniform3iv || + NULL == fUniform4f || + NULL == fUniform4i || + NULL == fUniform4fv || + NULL == fUniform4iv || + NULL == fUniformMatrix2fv || + NULL == fUniformMatrix3fv || + NULL == fUniformMatrix4fv || + NULL == fUseProgram || + NULL == fVertexAttrib4fv || + NULL == fVertexAttribPointer || NULL == fViewport || NULL == fBindFramebuffer || NULL == fBindRenderbuffer || @@ -369,27 +343,6 @@ bool GrGLInterface::validate(GrEngine engine) const { return false; } - switch (engine) { - case kOpenGL_Shaders_GrEngine: - if (kES1_GrGLBinding == fBindingsExported) { - return false; - } - if (!this->validateShaderFunctions()) { - return false; - } - break; - case kOpenGL_Fixed_GrEngine: - if (kES1_GrGLBinding == fBindingsExported) { - return false; - } - if (!this->validateFixedFunctions()) { - return false; - } - break; - default: - return false; - } - const char* ext; GrGLVersion glVer = GrGLGetVersion(this); ext = (const char*)fGetString(GR_GL_EXTENSIONS); diff --git a/src/gpu/GrGLProgram.cpp b/src/gpu/GrGLProgram.cpp index 770d9102b9..92b8f54376 100644 --- a/src/gpu/GrGLProgram.cpp +++ b/src/gpu/GrGLProgram.cpp @@ -24,7 +24,7 @@ enum { const char* GrPrecision(const GrGLInterface* gl) { - if (gl->supportsES()) { + if (gl->supportsES2()) { return "mediump"; } else { return " "; @@ -32,7 +32,7 @@ const char* GrPrecision(const GrGLInterface* gl) { } const char* GrShaderPrecision(const GrGLInterface* gl) { - if (gl->supportsES()) { + if (gl->supportsES2()) { return "precision mediump float;\n"; } else { return ""; @@ -372,7 +372,7 @@ const char* glsl_version_string(const GrGLInterface* gl, GrGLProgram::GLSLVersion v) { switch (v) { case GrGLProgram::k110_GLSLVersion: - if (gl->supportsES()) { + if (gl->supportsES2()) { // ES2s shader language is based on version 1.20 but is version // 1.00 of the ES language. return "#version 100\n"; @@ -514,7 +514,7 @@ void GrGLProgram::genEdgeCoverage(const GrGLInterface* gl, segments->fFSCode.appendf("\tfloat dfdy = 2.0*%s.x*duvdy.x - duvdy.y;\n", fsName); segments->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName); segments->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / (dfdx*dfdx + dfdy*dfdy));\n"); - if (gl->supportsES()) { + if (gl->supportsES2()) { segments->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n"); } } diff --git a/src/gpu/GrGLTexture.cpp b/src/gpu/GrGLTexture.cpp index 2a0d5d6fa8..06efb8a36b 100644 --- a/src/gpu/GrGLTexture.cpp +++ b/src/gpu/GrGLTexture.cpp @@ -15,24 +15,13 @@ #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) -const GrGLenum* GrGLTexture::WrapMode2GLWrap(GrGLBinding binding) { - static const GrGLenum mirrorRepeatModes[] = { - GR_GL_CLAMP_TO_EDGE, - GR_GL_REPEAT, - GR_GL_MIRRORED_REPEAT - }; - +const GrGLenum* GrGLTexture::WrapMode2GLWrap() { static const GrGLenum repeatModes[] = { GR_GL_CLAMP_TO_EDGE, GR_GL_REPEAT, - GR_GL_REPEAT + GR_GL_MIRRORED_REPEAT }; - - if (kES1_GrGLBinding == binding) { - return repeatModes; // GL_MIRRORED_REPEAT not supported. - } else { - return mirrorRepeatModes; - } + return repeatModes; }; void GrGLTexture::init(GrGpuGL* gpu, diff --git a/src/gpu/GrGLTexture.h b/src/gpu/GrGLTexture.h index a6888ee65a..ce30e11741 100644 --- a/src/gpu/GrGLTexture.h +++ b/src/gpu/GrGLTexture.h @@ -128,7 +128,7 @@ public: // and it is up to the GrGpuGL derivative to handle y-mirroing. Orientation orientation() const { return fOrientation; } - static const GrGLenum* WrapMode2GLWrap(GrGLBinding binding); + static const GrGLenum* WrapMode2GLWrap(); protected: diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 1482d13236..cec03bcf50 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -31,7 +31,7 @@ struct GrGpuStats { uint32_t fIndexCnt; //<! Number of indices drawn uint32_t fDrawCnt; //<! Number of draws - uint32_t fProgChngCnt;//<! Number of program changes (N/A for fixed) + uint32_t fProgChngCnt;//<! Number of program changes /** * Number of times the texture is set in 3D API diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp index 9498da21c3..c954c7a121 100644 --- a/src/gpu/GrGpuFactory.cpp +++ b/src/gpu/GrGpuFactory.cpp @@ -17,7 +17,6 @@ #include "GrGLConfig.h" #include "GrGpu.h" -#include "GrGpuGLFixed.h" #include "GrGpuGLShaders.h" GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) { @@ -25,8 +24,7 @@ GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) { const GrGLInterface* glInterface = NULL; SkAutoTUnref<const GrGLInterface> glInterfaceUnref; - if (kOpenGL_Shaders_GrEngine == engine || - kOpenGL_Fixed_GrEngine == engine) { + if (kOpenGL_Shaders_GrEngine == engine) { glInterface = reinterpret_cast<const GrGLInterface*>(context3D); if (NULL == glInterface) { glInterface = GrGLDefaultInterface(); @@ -41,29 +39,15 @@ GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) { #endif return NULL; } - if (!glInterface->validate(engine)) { + if (!glInterface->validate()) { #if GR_DEBUG GrPrintf("Failed GL interface validation!\n"); #endif return NULL; } - } - - GrGpu* gpu = NULL; - switch (engine) { - case kOpenGL_Shaders_GrEngine: - GrAssert(NULL != glInterface); - gpu = new GrGpuGLShaders(glInterface); - break; - case kOpenGL_Fixed_GrEngine: - GrAssert(NULL != glInterface); - gpu = new GrGpuGLFixed(glInterface); - break; - default: - GrAssert(!"unknown engine"); - break; + return new GrGpuGLShaders(glInterface); + } else { + return NULL; } - - return gpu; } diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp index 774b8d9553..cd9de91818 100644 --- a/src/gpu/GrGpuGL.cpp +++ b/src/gpu/GrGpuGL.cpp @@ -268,9 +268,6 @@ GrGpuGL::GrGpuGL(const GrGLInterface* gl, GrGLBinding glBinding) { case kDesktop_GrGLBinding: GrAssert(gl->supportsDesktop()); break; - case kES1_GrGLBinding: - GrAssert(gl->supportsES1()); - break; case kES2_GrGLBinding: GrAssert(gl->supportsES2()); break; @@ -326,10 +323,8 @@ void GrGpuGL::initCaps() { // check FS and fixed-function texture unit limits // we only use textures in the fragment stage currently. // checks are > to make sure we have a spare unit. - if (kES1_GrGLBinding != this->glBinding()) { - GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - GrAssert(maxTextureUnits > GrDrawState::kNumStages); - } + GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + GrAssert(maxTextureUnits > GrDrawState::kNumStages); if (kES2_GrGLBinding != this->glBinding()) { GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_UNITS, &maxTextureUnits); GrAssert(maxTextureUnits > GrDrawState::kNumStages); @@ -357,14 +352,6 @@ void GrGpuGL::initCaps() { } if (kDesktop_GrGLBinding == this->glBinding()) { - fCaps.fStencilWrapOpsSupport = (fGLVersion >= GR_GL_VER(1,4)) || - this->hasExtension("GL_EXT_stencil_wrap"); - } else { - fCaps.fStencilWrapOpsSupport = (fGLVersion >= GR_GL_VER(2,0)) || - this->hasExtension("GL_OES_stencil_wrap"); - } - - if (kDesktop_GrGLBinding == this->glBinding()) { // we could also look for GL_ATI_separate_stencil extension or // GL_EXT_stencil_two_side but they use different function signatures // than GL2.0+ (and than each other). @@ -373,12 +360,9 @@ void GrGpuGL::initCaps() { fCaps.fStencilWrapOpsSupport = (fGLVersion >= GR_GL_VER(1,4)) || this->hasExtension("GL_EXT_stencil_wrap"); } else { - // ES 2 has two sided stencil but 1.1 doesn't. There doesn't seem to be - // an ES1 extension. - fCaps.fTwoSidedStencilSupport = (fGLVersion >= GR_GL_VER(2,0)); - // stencil wrap support is in ES2, ES1 requires extension. - fCaps.fStencilWrapOpsSupport = (fGLVersion >= GR_GL_VER(2,0)) || - this->hasExtension("GL_OES_stencil_wrap"); + // ES 2 has two sided stencil and stencil wrap + fCaps.fTwoSidedStencilSupport = true; + fCaps.fStencilWrapOpsSupport = true; } if (kDesktop_GrGLBinding == this->glBinding()) { @@ -438,14 +422,9 @@ void GrGpuGL::initCaps() { fCaps.fNPOTTextureSupport = false; } } else { - if (fGLVersion >= GR_GL_VER(2,0)) { - fCaps.fNPOTTextureSupport = true; - fCaps.fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot"); - } else { - fCaps.fNPOTTextureSupport = - this->hasExtension("GL_APPLE_texture_2D_limited_npot"); - fCaps.fNPOTTextureTileSupport = false; - } + // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only + fCaps.fNPOTTextureSupport = true; + fCaps.fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot"); } fCaps.fHWAALineSupport = (kDesktop_GrGLBinding == this->glBinding()); @@ -563,17 +542,11 @@ void GrGpuGL::initStencilFormats() { fGLCaps.fStencilFormats.push_back() = gDS; } } else { - // ES2 has STENCIL_INDEX8 without extensions. - // ES1 with GL_OES_framebuffer_object (which we require for ES1) - // introduces tokens for S1 thu S8 but there are separate extensions - // that make them legal (GL_OES_stencil1, ...). - // GL_OES_packed_depth_stencil adds DEPTH24_STENCIL8 - // ES doesn't support using the unsized formats. + // ES2 has STENCIL_INDEX8 without extensions but requires extensions + // for other formats. + // ES doesn't support using the unsized format. - if (fGLVersion >= GR_GL_VER(2,0) || - this->hasExtension("GL_OES_stencil8")) { - fGLCaps.fStencilFormats.push_back() = gS8; - } + fGLCaps.fStencilFormats.push_back() = gS8; //fStencilFormats.push_back() = gS16; if (this->hasExtension("GL_OES_packed_depth_stencil")) { fGLCaps.fStencilFormats.push_back() = gD24S8; @@ -581,8 +554,6 @@ void GrGpuGL::initStencilFormats() { if (this->hasExtension("GL_OES_stencil4")) { fGLCaps.fStencilFormats.push_back() = gS4; } - // we require some stencil format. - GrAssert(fGLCaps.fStencilFormats.count() > 0); } } @@ -2150,8 +2121,7 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { newTexParams.fFilter = gr_to_gl_filter(sampler.getFilter()); - const GrGLenum* wraps = - GrGLTexture::WrapMode2GLWrap(this->glBinding()); + const GrGLenum* wraps = GrGLTexture::WrapMode2GLWrap(); newTexParams.fWrapS = wraps[sampler.getWrapX()]; newTexParams.fWrapT = wraps[sampler.getWrapY()]; memcpy(newTexParams.fSwizzleRGBA, @@ -2406,9 +2376,7 @@ bool GrGpuGL::fboInternalFormat(GrPixelConfig config, GrGLenum* format) { return false; } case kRGB_565_GrPixelConfig: - // ES2 supports 565. ES1 supports it - // with FBO extension desktop GL has - // no such internal format + // ES2 supports 565, but desktop GL does not. if (kDesktop_GrGLBinding != this->glBinding()) { *format = GR_GL_RGB565; return true; diff --git a/src/gpu/GrGpuGLFixed.cpp b/src/gpu/GrGpuGLFixed.cpp deleted file mode 100644 index 3534ee777f..0000000000 --- a/src/gpu/GrGpuGLFixed.cpp +++ /dev/null @@ -1,382 +0,0 @@ - -/* - * Copyright 2010 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - - -#include "GrGLConfig.h" - -#include "GrGpuGLFixed.h" -#include "GrGpuVertex.h" - -#define SKIP_CACHE_CHECK true - -struct GrGpuMatrix { - GrGLfloat fMat[16]; - - void reset() { - Gr_bzero(fMat, sizeof(fMat)); - fMat[0] = fMat[5] = fMat[10] = fMat[15] = GR_Scalar1; - } - - void set(const GrMatrix& m) { - Gr_bzero(fMat, sizeof(fMat)); - fMat[0] = GrScalarToFloat(m[GrMatrix::kMScaleX]); - fMat[4] = GrScalarToFloat(m[GrMatrix::kMSkewX]); - fMat[12] = GrScalarToFloat(m[GrMatrix::kMTransX]); - - fMat[1] = GrScalarToFloat(m[GrMatrix::kMSkewY]); - fMat[5] = GrScalarToFloat(m[GrMatrix::kMScaleY]); - fMat[13] = GrScalarToFloat(m[GrMatrix::kMTransY]); - - fMat[3] = GrScalarToFloat(m[GrMatrix::kMPersp0]); - fMat[7] = GrScalarToFloat(m[GrMatrix::kMPersp1]); - fMat[15] = GrScalarToFloat(m[GrMatrix::kMPersp2]); - - fMat[10] = 1.f; // z-scale - } -}; - -// these must match the order in the corresponding enum in GrGpu.h -static const GrGLenum gMatrixMode2Enum[] = { - GR_GL_MODELVIEW, GR_GL_TEXTURE -}; - -#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) -/////////////////////////////////////////////////////////////////////////////// - -namespace { -GrGLBinding get_binding_in_use(const GrGLInterface* gl) { - if (gl->supportsDesktop()) { - return kDesktop_GrGLBinding; - } else { - GrAssert(gl->supportsES1()); - return kES1_GrGLBinding; - } -} -} - -GrGpuGLFixed::GrGpuGLFixed(const GrGLInterface* gl) - : GrGpuGL(gl, get_binding_in_use(gl)) { -} - -GrGpuGLFixed::~GrGpuGLFixed() { -} - -void GrGpuGLFixed::onResetContext() { - INHERITED::onResetContext(); - - GL_CALL(Disable(GR_GL_TEXTURE_2D)); - - for (int s = 0; s < GrDrawState::kNumStages; ++s) { - setTextureUnit(s); - GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_TEXTURE_ENV_MODE, - GR_GL_COMBINE)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_COMBINE_RGB, - GR_GL_MODULATE)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_SRC0_RGB, - GR_GL_TEXTURE0+s)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_SRC1_RGB, - GR_GL_PREVIOUS)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_OPERAND1_RGB, - GR_GL_SRC_COLOR)); - - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_COMBINE_ALPHA, - GR_GL_MODULATE)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_SRC0_ALPHA, - GR_GL_TEXTURE0+s)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_OPERAND0_ALPHA, - GR_GL_SRC_ALPHA)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_SRC1_ALPHA, - GR_GL_PREVIOUS)); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_OPERAND1_ALPHA, - GR_GL_SRC_ALPHA)); - - // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending - // upon whether we have a (premultiplied) RGBA texture or just an ALPHA - // texture, e.g.: - //glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1; - } - - fHWGeometryState.fVertexLayout = 0; - fHWGeometryState.fVertexOffset = ~0; - GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY)); - GL_CALL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY)); - GL_CALL(ShadeModel(GR_GL_FLAT)); - GL_CALL(DisableClientState(GR_GL_COLOR_ARRAY)); - - GL_CALL(PointSize(1.f)); - - GrGLClearErr(this->glInterface()); - fTextVerts = false; - - fBaseVertex = 0xffffffff; -} - - -void GrGpuGLFixed::flushProjectionMatrix() { - float mat[16]; - Gr_bzero(mat, sizeof(mat)); - - GrAssert(NULL != fCurrDrawState.fRenderTarget); - - mat[0] = 2.f / fCurrDrawState.fRenderTarget->width(); - mat[5] = -2.f / fCurrDrawState.fRenderTarget->height(); - mat[10] = -1.f; - mat[15] = 1; - - mat[12] = -1.f; - mat[13] = 1.f; - - GL_CALL(MatrixMode(GR_GL_PROJECTION)); - GL_CALL(LoadMatrixf(mat)); -} - -bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) { - - bool usingTextures[GrDrawState::kNumStages]; - - for (int s = 0; s < GrDrawState::kNumStages; ++s) { - usingTextures[s] = this->isStageEnabled(s); - if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) { - unimpl("Fixed pipe doesn't support radial/sweep gradients"); - return false; - } - } - - if (kES1_GrGLBinding == this->glBinding()) { - if (BlendCoeffReferencesConstant(fCurrDrawState.fSrcBlend) || - BlendCoeffReferencesConstant(fCurrDrawState.fDstBlend)) { - unimpl("ES1 doesn't support blend constant"); - return false; - } - } - - if (!flushGLStateCommon(type)) { - return false; - } - - GrBlendCoeff srcCoeff, dstCoeff; - if (kSkipDraw_BlendOptFlag & - this->getBlendOpts(false, &srcCoeff, &dstCoeff)) { - return false; - } - - this->flushBlend(type, srcCoeff, dstCoeff); - - if (fDirtyFlags.fRenderTargetChanged) { - flushProjectionMatrix(); - } - - for (int s = 0; s < GrDrawState::kNumStages; ++s) { - bool wasUsingTexture = StageWillBeUsed(s, fHWGeometryState.fVertexLayout, fHWDrawState); - if (usingTextures[s] != wasUsingTexture) { - setTextureUnit(s); - if (usingTextures[s]) { - GL_CALL(Enable(GR_GL_TEXTURE_2D)); - } else { - GL_CALL(Disable(GR_GL_TEXTURE_2D)); - } - } - } - - uint32_t vertColor = (this->getGeomSrc().fVertexLayout & kColor_VertexLayoutBit); - uint32_t prevVertColor = (fHWGeometryState.fVertexLayout & - kColor_VertexLayoutBit); - - if (vertColor != prevVertColor) { - if (vertColor) { - GL_CALL(ShadeModel(GR_GL_SMOOTH)); - // invalidate the immediate mode color - fHWDrawState.fColor = GrColor_ILLEGAL; - } else { - GL_CALL(ShadeModel(GR_GL_FLAT)); - } - } - - - if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) { - GL_CALL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor), - GrColorUnpackG(fCurrDrawState.fColor), - GrColorUnpackB(fCurrDrawState.fColor), - GrColorUnpackA(fCurrDrawState.fColor))); - fHWDrawState.fColor = fCurrDrawState.fColor; - } - - // set texture environment, decide whether we are modulating by RGB or A. - for (int s = 0; s < GrDrawState::kNumStages; ++s) { - if (usingTextures[s]) { - GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s]; - if (NULL != texture) { - TextureEnvRGBOperands nextRGBOperand0 = - (GrPixelConfigIsAlphaOnly(texture->config())) ? - kAlpha_TextureEnvRGBOperand : - kColor_TextureEnvRGBOperand; - if (fHWRGBOperand0[s] != nextRGBOperand0) { - setTextureUnit(s); - GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV, - GR_GL_OPERAND0_RGB, - (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ? - GR_GL_SRC_ALPHA : - GR_GL_SRC_COLOR)); - fHWRGBOperand0[s] = nextRGBOperand0; - } - - if (((1 << s) & fDirtyFlags.fTextureChangedMask) || - (fHWDrawState.fSamplerStates[s].getMatrix() != - getSamplerMatrix(s))) { - - GrMatrix texMat = getSamplerMatrix(s); - AdjustTextureMatrix(texture, - GrSamplerState::kNormal_SampleMode, - &texMat); - GrGpuMatrix glm; - glm.set(texMat); - setTextureUnit(s); - GL_CALL(MatrixMode(GR_GL_TEXTURE)); - GL_CALL(LoadMatrixf(glm.fMat)); - recordHWSamplerMatrix(s, getSamplerMatrix(s)); - } - } else { - GrAssert(!"Rendering with texture vert flag set but no bound texture"); - return false; - } - } - } - - if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) { - GrGpuMatrix glm; - glm.set(fCurrDrawState.fViewMatrix); - GL_CALL(MatrixMode(GR_GL_MODELVIEW)); - GL_CALL(LoadMatrixf(glm.fMat)); - fHWDrawState.fViewMatrix = - fCurrDrawState.fViewMatrix; - } - resetDirtyFlags(); - return true; -} - -void GrGpuGLFixed::setupGeometry(int* startVertex, - int* startIndex, - int vertexCount, - int indexCount) { - - int newColorOffset; - int newCoverageOffset; - int newTexCoordOffsets[GrDrawState::kNumStages]; - int newEdgeOffset; - - GrGLsizei newStride = VertexSizeAndOffsetsByStage(this->getGeomSrc().fVertexLayout, - newTexCoordOffsets, - &newColorOffset, - &newCoverageOffset, - &newEdgeOffset); - GrAssert(-1 == newEdgeOffset); // not supported by fixed pipe - GrAssert(-1 == newCoverageOffset); // not supported by fixed pipe - - int oldColorOffset; - int oldCoverageOffset; - int oldTexCoordOffsets[GrDrawState::kNumStages]; - int oldEdgeOffset; - GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout, - oldTexCoordOffsets, - &oldColorOffset, - &oldCoverageOffset, - &oldEdgeOffset); - GrAssert(-1 == oldEdgeOffset); - GrAssert(-1 == oldCoverageOffset); - - bool indexed = NULL != startIndex; - - int extraVertexOffset; - int extraIndexOffset; - setBuffers(indexed, &extraVertexOffset, &extraIndexOffset); - - GrGLenum scalarType; - if (this->getGeomSrc().fVertexLayout & kTextFormat_VertexLayoutBit) { - scalarType = GrGLTextType; - } else { - scalarType = GrGLType; - } - - size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride; - *startVertex = 0; - if (indexed) { - *startIndex += extraIndexOffset; - } - - // all the Pointers must be set if any of these are true - bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty || - vertexOffset != fHWGeometryState.fVertexOffset || - newStride != oldStride; - - // position and tex coord offsets change if above conditions are true - // or the type changed based on text vs nontext type coords. - bool posAndTexChange = allOffsetsChange || - ((GrGLTextType != GrGLType) && - (kTextFormat_VertexLayoutBit & - (fHWGeometryState.fVertexLayout ^ - this->getGeomSrc().fVertexLayout))); - - if (posAndTexChange) { - GL_CALL(VertexPointer(2, scalarType, - newStride, (GrGLvoid*)vertexOffset)); - fHWGeometryState.fVertexOffset = vertexOffset; - } - - for (int s = 0; s < GrDrawState::kNumStages; ++s) { - // need to enable array if tex coord offset is 0 - // (using positions as coords) - if (newTexCoordOffsets[s] >= 0) { - GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + - newTexCoordOffsets[s]); - if (oldTexCoordOffsets[s] < 0) { - GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s)); - GL_CALL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY)); - GL_CALL(TexCoordPointer(2, scalarType, - newStride, texCoordOffset)); - } else if (posAndTexChange || - newTexCoordOffsets[s] != oldTexCoordOffsets[s]) { - GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s)); - GL_CALL(TexCoordPointer(2, scalarType, - newStride, texCoordOffset)); - } - } else if (oldTexCoordOffsets[s] >= 0) { - GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s)); - GL_CALL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY)); - } - } - - if (newColorOffset > 0) { - GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset); - if (oldColorOffset <= 0) { - GL_CALL(EnableClientState(GR_GL_COLOR_ARRAY)); - GL_CALL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, - newStride, colorOffset)); - } else if (allOffsetsChange || newColorOffset != oldColorOffset) { - GL_CALL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, - newStride, colorOffset)); - } - } else if (oldColorOffset > 0) { - GL_CALL(DisableClientState(GR_GL_COLOR_ARRAY)); - } - - fHWGeometryState.fVertexLayout = this->getGeomSrc().fVertexLayout; - fHWGeometryState.fArrayPtrsDirty = false; -} diff --git a/src/gpu/GrGpuGLFixed.h b/src/gpu/GrGpuGLFixed.h deleted file mode 100644 index a1fce7013e..0000000000 --- a/src/gpu/GrGpuGLFixed.h +++ /dev/null @@ -1,66 +0,0 @@ - -/* - * Copyright 2010 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - - -#ifndef GrGpuGLFixed_DEFINED -#define GrGpuGLFixed_DEFINED - -#include "GrDrawState.h" -#include "GrGpuGL.h" - -// Fixed Pipeline OpenGL or OpenGL ES 1.x -class GrGpuGLFixed : public GrGpuGL { -public: - GrGpuGLFixed(const GrGLInterface* glInterface); - virtual ~GrGpuGLFixed(); - -protected: - // overrides from GrGpu - virtual bool flushGraphicsState(GrPrimitiveType type); - virtual void setupGeometry(int* startVertex, - int* startIndex, - int vertexCount, - int indexCount); - -private: - virtual void onResetContext() SK_OVERRIDE; - - // Helpers to make code more readable - const GrMatrix& getHWSamplerMatrix(int stage) const { - return fHWDrawState.fSamplerStates[stage].getMatrix(); - } - void recordHWSamplerMatrix(int stage, const GrMatrix& matrix) { - fHWDrawState.fSamplerStates[stage].setMatrix(matrix); - } - - // when the texture is GL_RGBA we set the GL_COMBINE texture - // environment rgb operand 0 to be GL_COLOR to modulate each incoming - // R,G, & B by the texture's R, G, & B. When the texture is alpha-only we - // set the operand to GL_ALPHA so that the incoming frag's R, G, &B are all - // modulated by the texture's A. - enum TextureEnvRGBOperands { - kAlpha_TextureEnvRGBOperand, - kColor_TextureEnvRGBOperand, - }; - TextureEnvRGBOperands fHWRGBOperand0[GrDrawState::kNumStages]; - - void flushProjectionMatrix(); - - // are the currently bound vertex buffers/arrays laid - // out for text or other drawing. - bool fTextVerts; - - // On GL we have to build the base vertex offset into the - // glVertexPointer/glTexCoordPointer/etc - int fBaseVertex; - - typedef GrGpuGL INHERITED; -}; - -#endif diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp index 76b02ac76d..ae5b1725a2 100644 --- a/src/gpu/GrGpuGLShaders.cpp +++ b/src/gpu/GrGpuGLShaders.cpp @@ -162,8 +162,7 @@ GrGLProgram::GLSLVersion get_glsl_version(GrGLBinding binding, GrAssert(ver >= GR_GL_VER(1,00)); return GrGLProgram::k110_GLSLVersion; default: - GrCrash("Attempting to get GLSL version in unknown or fixed-" - "function GL binding."); + GrCrash("Unknown GL Binding"); return GrGLProgram::k110_GLSLVersion; // suppress warning } } diff --git a/src/gpu/app-android.cpp b/src/gpu/app-android.cpp index 39cca6ce1a..ae8b7ddaea 100644 --- a/src/gpu/app-android.cpp +++ b/src/gpu/app-android.cpp @@ -22,7 +22,6 @@ static GrContext* make_context() { SkDebugf("---- before create\n"); GrContext* ctx = GrContext::Create(GrGpu::kOpenGL_Shaders_Engine, 0); -// GrContext* ctx = GrContext::Create(GrGpu::kOpenGL_Fixed_Engine, 0); SkDebugf("---- after create %p\n", ctx); return ctx; } diff --git a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp index 7be40db89a..7f6dd1c68c 100644 --- a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp +++ b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp @@ -9,9 +9,6 @@ #include "GrGLInterface.h" -#import <OpenGLES/ES1/gl.h> -#import <OpenGLES/ES1/glext.h> - #import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/glext.h> @@ -145,7 +142,7 @@ const GrGLInterface* GrGLDefaultInterface() { #endif interface->fBindFragDataLocationIndexed = NULL; - interface->fBindingsExported = (GrGLBinding)(kES2_GrGLBinding | kES1_GrGLBinding); + interface->fBindingsExported = kES2_GrGLBinding; } glInterface.get()->ref(); return glInterface.get(); |