blob: 5b81ea616dc950d627274ce12e66a14a4c1320ab [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 +000029 virtual void resetContext();
30
31protected:
32 // overrides from GrGpu
bsalomon@google.comffca4002011-02-22 20:34:01 +000033 virtual bool flushGraphicsState(GrPrimitiveType type);
bsalomon@google.com1c13c962011-02-14 16:51:21 +000034 virtual void setupGeometry(int* startVertex,
35 int* startIndex,
36 int vertexCount,
37 int indexCount);
reed@google.comac10a2d2010-12-22 21:39:39 +000038
39private:
40 void resetContextHelper();
41
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000042 // Helpers to make code more readable
43 const GrMatrix& getHWSamplerMatrix(int stage) const {
44 return fHWDrawState.fSamplerStates[stage].getMatrix();
45 }
46 const void recordHWSamplerMatrix(int stage, const GrMatrix& matrix) {
47 fHWDrawState.fSamplerStates[stage].setMatrix(matrix);
48 }
49
reed@google.comac10a2d2010-12-22 21:39:39 +000050 // when the texture is GL_RGBA we set the GL_COMBINE texture
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000051 // environment rgb operand 0 to be GL_COLOR to modulate each incoming
bsalomon@google.com1c13c962011-02-14 16:51:21 +000052 // R,G, & B by the texture's R, G, & B. When the texture is alpha-only we
53 // 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 +000054 // modulated by the texture's A.
reed@google.comac10a2d2010-12-22 21:39:39 +000055 enum TextureEnvRGBOperands {
56 kAlpha_TextureEnvRGBOperand,
57 kColor_TextureEnvRGBOperand,
58 };
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000059 TextureEnvRGBOperands fHWRGBOperand0[kNumStages];
reed@google.comac10a2d2010-12-22 21:39:39 +000060
61 void flushProjectionMatrix();
62
63 // are the currently bound vertex buffers/arrays laid
64 // out for text or other drawing.
65 bool fTextVerts;
66
67 // On GL we have to build the base vertex offset into the
68 // glVertexPointer/glTexCoordPointer/etc
69 int fBaseVertex;
70
reed@google.comac10a2d2010-12-22 21:39:39 +000071 typedef GrGpuGL INHERITED;
72};
73
74#endif