Description.cpp 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 <stdint.h> 18#include <string.h> 19 20#include <utils/TypeHelpers.h> 21 22#include <GLES2/gl2.h> 23#include <GLES2/gl2ext.h> 24 25#include "Description.h" 26 27namespace android { 28 29Description::Description() : 30 mUniformsDirty(true) { 31 mPlaneAlpha = 1.0f; 32 mPremultipliedAlpha = true; 33 mOpaque = true; 34 mTextureEnabled = false; 35 36 memset(mColor, 0, sizeof(mColor)); 37} 38 39Description::~Description() { 40} 41 42void Description::setPlaneAlpha(GLclampf planeAlpha) { 43 if (planeAlpha != mPlaneAlpha) { 44 mUniformsDirty = true; 45 mPlaneAlpha = planeAlpha; 46 } 47} 48 49void Description::setPremultipliedAlpha(bool premultipliedAlpha) { 50 if (premultipliedAlpha != mPremultipliedAlpha) { 51 mPremultipliedAlpha = premultipliedAlpha; 52 } 53} 54 55void Description::setOpaque(bool opaque) { 56 if (opaque != mOpaque) { 57 mOpaque = opaque; 58 } 59} 60 61void Description::setTexture(const Texture& texture) { 62 mTexture = texture; 63 mTextureEnabled = true; 64 mUniformsDirty = true; 65} 66 67void Description::disableTexture() { 68 mTextureEnabled = false; 69} 70 71void Description::setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { 72 mColor[0] = red; 73 mColor[1] = green; 74 mColor[2] = blue; 75 mColor[3] = alpha; 76 mUniformsDirty = true; 77} 78 79void Description::setProjectionMatrix(const mat4& mtx) { 80 mProjectionMatrix = mtx; 81 mUniformsDirty = true; 82} 83 84} /* namespace android */ 85