blob: 077b6e2a38e18fc2df5cd3bfd647a634307a21d5 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
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
24class GrGpuGLFixed : public GrGpuGL {
25public:
26 GrGpuGLFixed();
27 virtual ~GrGpuGLFixed();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000028
reed@google.comac10a2d2010-12-22 21:39:39 +000029protected:
30 // overrides from GrGpu
bsalomon@google.comffca4002011-02-22 20:34:01 +000031 virtual bool flushGraphicsState(GrPrimitiveType type);
bsalomon@google.com1c13c962011-02-14 16:51:21 +000032 virtual void setupGeometry(int* startVertex,
33 int* startIndex,
34 int vertexCount,
35 int indexCount);
reed@google.comac10a2d2010-12-22 21:39:39 +000036
37private:
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000038 virtual void resetContext();
reed@google.comac10a2d2010-12-22 21:39:39 +000039
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000040 // Helpers to make code more readable
41 const GrMatrix& getHWSamplerMatrix(int stage) const {
42 return fHWDrawState.fSamplerStates[stage].getMatrix();
43 }
44 const void recordHWSamplerMatrix(int stage, const GrMatrix& matrix) {
45 fHWDrawState.fSamplerStates[stage].setMatrix(matrix);
46 }
47
reed@google.comac10a2d2010-12-22 21:39:39 +000048 // when the texture is GL_RGBA we set the GL_COMBINE texture
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000049 // environment rgb operand 0 to be GL_COLOR to modulate each incoming
bsalomon@google.com1c13c962011-02-14 16:51:21 +000050 // 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
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000052 // modulated by the texture's A.
reed@google.comac10a2d2010-12-22 21:39:39 +000053 enum TextureEnvRGBOperands {
54 kAlpha_TextureEnvRGBOperand,
55 kColor_TextureEnvRGBOperand,
56 };
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000057 TextureEnvRGBOperands fHWRGBOperand0[kNumStages];
reed@google.comac10a2d2010-12-22 21:39:39 +000058
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
reed@google.comac10a2d2010-12-22 21:39:39 +000069 typedef GrGpuGL INHERITED;
70};
71
72#endif