Home | History | Annotate | Download | only in src
      1 /*
      2     Copyright 2010 Google Inc.
      3 
      4     Licensed under the Apache License, Version 2.0 (the "License");
      5     you may not use this file except in compliance with the License.
      6     You may obtain a copy of the License at
      7 
      8          http://www.apache.org/licenses/LICENSE-2.0
      9 
     10     Unless required by applicable law or agreed to in writing, software
     11     distributed under the License is distributed on an "AS IS" BASIS,
     12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13     See the License for the specific language governing permissions and
     14     limitations under the License.
     15  */
     16 
     17 
     18 #ifndef GrGpuGLFixed_DEFINED
     19 #define GrGpuGLFixed_DEFINED
     20 
     21 #include "GrGpuGL.h"
     22 
     23 // Fixed Pipeline OpenGL or OpenGL ES 1.x
     24 class GrGpuGLFixed : public GrGpuGL {
     25 public:
     26              GrGpuGLFixed();
     27     virtual ~GrGpuGLFixed();
     28 
     29 protected:
     30     // overrides from GrGpu
     31     virtual bool flushGraphicsState(GrPrimitiveType type);
     32     virtual void setupGeometry(int* startVertex,
     33                                int* startIndex,
     34                                int vertexCount,
     35                                int indexCount);
     36 
     37 private:
     38     virtual void resetContext();
     39 
     40     // Helpers to make code more readable
     41     const GrMatrix& getHWSamplerMatrix(int stage) const {
     42         return fHWDrawState.fSamplerStates[stage].getMatrix();
     43     }
     44     void recordHWSamplerMatrix(int stage, const GrMatrix& matrix) {
     45         fHWDrawState.fSamplerStates[stage].setMatrix(matrix);
     46     }
     47 
     48     // when the texture is GL_RGBA we set the GL_COMBINE texture
     49     // environment rgb operand 0 to be GL_COLOR to modulate each incoming
     50     // R,G, & B by the texture's R, G, & B. When the texture is alpha-only we
     51     // set the operand to GL_ALPHA so that the incoming frag's R, G, &B are all
     52     // modulated by the texture's A.
     53     enum TextureEnvRGBOperands {
     54         kAlpha_TextureEnvRGBOperand,
     55         kColor_TextureEnvRGBOperand,
     56     };
     57     TextureEnvRGBOperands fHWRGBOperand0[kNumStages];
     58 
     59     void flushProjectionMatrix();
     60 
     61     // are the currently bound vertex buffers/arrays laid
     62     // out for text or other drawing.
     63     bool fTextVerts;
     64 
     65     // On GL we have to build the base vertex offset into the
     66     // glVertexPointer/glTexCoordPointer/etc
     67     int fBaseVertex;
     68 
     69     typedef GrGpuGL INHERITED;
     70 };
     71 
     72 #endif
     73