Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2013 The Android Open Source Project |
| 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 | #include <GLES2/gl2.h> |
| 18 | |
| 19 | #ifndef SF_RENDER_ENGINE_DESCRIPTION_H_ |
| 20 | #define SF_RENDER_ENGINE_DESCRIPTION_H_ |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class Program; |
| 25 | |
| 26 | /* |
| 27 | * This holds the state of the rendering engine. This class is used |
| 28 | * to generate a corresponding GLSL program and set the appropriate |
| 29 | * uniform. |
| 30 | * |
| 31 | * Program and ProgramCache are friends and access the state directly |
| 32 | */ |
| 33 | class Description { |
| 34 | friend class Program; |
| 35 | friend class ProgramCache; |
| 36 | |
| 37 | // value of the plane-alpha, between 0 and 1 |
| 38 | GLclampf mPlaneAlpha; |
| 39 | // whether textures are premultiplied |
| 40 | bool mPremultipliedAlpha; |
| 41 | // whether this layer is marked as opaque |
| 42 | bool mOpaque; |
| 43 | // texture target, TEXTURE_2D or TEXTURE_EXTERNAL |
| 44 | GLenum mTextureTarget; |
| 45 | |
| 46 | // name of the texture |
| 47 | GLuint mTextureName; |
| 48 | // color used when texturing is disabled |
| 49 | GLclampf mColor[4]; |
| 50 | // projection matrix |
| 51 | GLfloat mProjectionMatrix[16]; |
| 52 | // texture matrix |
| 53 | GLfloat mTextureMatrix[16]; |
| 54 | |
| 55 | public: |
| 56 | Description(); |
| 57 | ~Description(); |
| 58 | |
| 59 | void setPlaneAlpha(GLclampf planeAlpha); |
| 60 | void setPremultipliedAlpha(bool premultipliedAlpha); |
| 61 | void setOpaque(bool opaque); |
| 62 | void setTextureName(GLenum target, GLuint tname); |
| 63 | void disableTexture(); |
| 64 | void setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); |
| 65 | void setProjectionMatrix(GLfloat const* mtx); |
| 66 | void setTextureMatrix(GLfloat const* mtx); |
| 67 | |
| 68 | private: |
| 69 | bool mUniformsDirty; |
| 70 | }; |
| 71 | |
| 72 | } /* namespace android */ |
| 73 | |
| 74 | #endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ |