Description.h revision a8c386f1c36e916c1df18d41a22104d655a89817
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#include "Texture.h" 19 20#ifndef SF_RENDER_ENGINE_DESCRIPTION_H_ 21#define SF_RENDER_ENGINE_DESCRIPTION_H_ 22 23namespace android { 24 25class Program; 26 27/* 28 * This holds the state of the rendering engine. This class is used 29 * to generate a corresponding GLSL program and set the appropriate 30 * uniform. 31 * 32 * Program and ProgramCache are friends and access the state directly 33 */ 34class Description { 35 friend class Program; 36 friend class ProgramCache; 37 38 // value of the plane-alpha, between 0 and 1 39 GLclampf mPlaneAlpha; 40 // whether textures are premultiplied 41 bool mPremultipliedAlpha; 42 // whether this layer is marked as opaque 43 bool mOpaque; 44 45 // Texture this layer uses 46 Texture mTexture; 47 bool mTextureEnabled; 48 49 // color used when texturing is disabled 50 GLclampf mColor[4]; 51 // projection matrix 52 mat4 mProjectionMatrix; 53 54public: 55 Description(); 56 ~Description(); 57 58 void setPlaneAlpha(GLclampf planeAlpha); 59 void setPremultipliedAlpha(bool premultipliedAlpha); 60 void setOpaque(bool opaque); 61 void setTexture(const Texture& texture); 62 void disableTexture(); 63 void setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); 64 void setProjectionMatrix(const mat4& mtx); 65 66private: 67 bool mUniformsDirty; 68}; 69 70} /* namespace android */ 71 72#endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ 73