Home | History | Annotate | Download | only in RenderEngine
      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 
     27 namespace android {
     28 
     29 Description::Description() :
     30     mUniformsDirty(true) {
     31     mPlaneAlpha = 1.0f;
     32     mPremultipliedAlpha = false;
     33     mOpaque = true;
     34     mTextureEnabled = false;
     35     mColorMatrixEnabled = false;
     36 
     37     memset(mColor, 0, sizeof(mColor));
     38 }
     39 
     40 Description::~Description() {
     41 }
     42 
     43 void Description::setPlaneAlpha(GLclampf planeAlpha) {
     44     if (planeAlpha != mPlaneAlpha) {
     45         mUniformsDirty = true;
     46         mPlaneAlpha = planeAlpha;
     47     }
     48 }
     49 
     50 void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
     51     if (premultipliedAlpha != mPremultipliedAlpha) {
     52         mPremultipliedAlpha = premultipliedAlpha;
     53     }
     54 }
     55 
     56 void Description::setOpaque(bool opaque) {
     57     if (opaque != mOpaque) {
     58         mOpaque = opaque;
     59     }
     60 }
     61 
     62 void Description::setTexture(const Texture& texture) {
     63     mTexture = texture;
     64     mTextureEnabled = true;
     65     mUniformsDirty = true;
     66 }
     67 
     68 void Description::disableTexture() {
     69     mTextureEnabled = false;
     70 }
     71 
     72 void Description::setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
     73     mColor[0] = red;
     74     mColor[1] = green;
     75     mColor[2] = blue;
     76     mColor[3] = alpha;
     77     mUniformsDirty = true;
     78 }
     79 
     80 void Description::setProjectionMatrix(const mat4& mtx) {
     81     mProjectionMatrix = mtx;
     82     mUniformsDirty = true;
     83 }
     84 
     85 void Description::setColorMatrix(const mat4& mtx) {
     86     const mat4 identity;
     87     mColorMatrix = mtx;
     88     mColorMatrixEnabled = (mtx != identity);
     89 }
     90 
     91 
     92 } /* namespace android */
     93