Home | History | Annotate | Download | only in gl
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 
     11 #ifndef GrGpuGLShaders_DEFINED
     12 #define GrGpuGLShaders_DEFINED
     13 
     14 #include "GrGpuGL.h"
     15 #include "GrGLProgram.h"
     16 
     17 class GrGpuGLProgram;
     18 
     19 // Programmable OpenGL or OpenGL ES 2.0
     20 class GrGpuGLShaders : public GrGpuGL {
     21 public:
     22              GrGpuGLShaders(const GrGLContextInfo& ctxInfo);
     23     virtual ~GrGpuGLShaders();
     24 
     25     virtual void abandonResources();
     26 
     27     bool programUnitTest();
     28 
     29 protected:
     30     // overrides from GrGpu
     31     virtual void onResetContext() SK_OVERRIDE;
     32     virtual bool flushGraphicsState(GrPrimitiveType type);
     33     virtual void setupGeometry(int* startVertex,
     34                                int* startIndex,
     35                                int vertexCount,
     36                                int indexCount);
     37     virtual void postDraw();
     38 
     39 private:
     40 
     41     // for readability of function impls
     42     typedef GrGLProgram::ProgramDesc ProgramDesc;
     43     typedef ProgramDesc::StageDesc   StageDesc;
     44     typedef GrGLProgram::CachedData  CachedData;
     45 
     46     class ProgramCache;
     47 
     48     // Helpers to make code more readable
     49     const GrMatrix& getHWViewMatrix();
     50     void recordHWViewMatrix(const GrMatrix& matrix);
     51     const GrMatrix& getHWSamplerMatrix(int stage);
     52     void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
     53 
     54     // sets the texture matrix uniform for currently bound program
     55     void flushTextureMatrix(int stage);
     56 
     57     // sets the texture domain uniform for currently bound program
     58     void flushTextureDomain(int stage);
     59 
     60     // sets the color specified by GrDrawState::setColor()
     61     void flushColor(GrColor color);
     62 
     63     // sets the color specified by GrDrawState::setCoverage()
     64     void flushCoverage(GrColor color);
     65 
     66     // sets the MVP matrix uniform for currently bound program
     67     void flushViewMatrix();
     68 
     69     // flushes the parameters to two point radial gradient
     70     void flushRadial2(int stage);
     71 
     72     // flushes the parameters for convolution
     73     void flushConvolution(int stage);
     74 
     75     // flushes the normalized texel size
     76     void flushTexelSize(int stage);
     77 
     78     // flushes the edges for edge AA
     79     void flushEdgeAAData();
     80 
     81     // flushes the color matrix
     82     void flushColorMatrix();
     83 
     84     static void DeleteProgram(const GrGLInterface* gl,
     85                               CachedData* programData);
     86 
     87     void buildProgram(GrPrimitiveType typeBlend,
     88                       BlendOptFlags blendOpts,
     89                       GrBlendCoeff dstCoeff);
     90 
     91     ProgramCache*               fProgramCache;
     92     CachedData*                 fProgramData;
     93     GrGLuint                    fHWProgramID;
     94     GrGLProgram                 fCurrentProgram;
     95     // If we get rid of fixed function subclass this should move
     96     // to the GLCaps struct in parent class
     97     GrGLint                     fMaxVertexAttribs;
     98 
     99     typedef GrGpuGL INHERITED;
    100 };
    101 
    102 #endif
    103 
    104