blob: 0dab8726828d87285ed84d50fd69f8d84137897f [file] [log] [blame]
Mathias Agopian3f844832013-08-07 21:24:32 -07001/*
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;
Mathias Agopianff2ed702013-09-01 21:36:12 -070032 mPremultipliedAlpha = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070033 mOpaque = true;
Mathias Agopian49457ac2013-08-14 18:20:17 -070034 mTextureEnabled = false;
Mathias Agopianff2ed702013-09-01 21:36:12 -070035 mColorMatrixEnabled = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070036
Mathias Agopian3f844832013-08-07 21:24:32 -070037 memset(mColor, 0, sizeof(mColor));
Mathias Agopian3f844832013-08-07 21:24:32 -070038}
39
40Description::~Description() {
41}
42
43void Description::setPlaneAlpha(GLclampf planeAlpha) {
44 if (planeAlpha != mPlaneAlpha) {
45 mUniformsDirty = true;
46 mPlaneAlpha = planeAlpha;
47 }
48}
49
50void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
51 if (premultipliedAlpha != mPremultipliedAlpha) {
52 mPremultipliedAlpha = premultipliedAlpha;
53 }
54}
55
56void Description::setOpaque(bool opaque) {
57 if (opaque != mOpaque) {
58 mOpaque = opaque;
59 }
60}
61
Mathias Agopian49457ac2013-08-14 18:20:17 -070062void Description::setTexture(const Texture& texture) {
63 mTexture = texture;
64 mTextureEnabled = true;
65 mUniformsDirty = true;
Mathias Agopian3f844832013-08-07 21:24:32 -070066}
67
68void Description::disableTexture() {
Mathias Agopian49457ac2013-08-14 18:20:17 -070069 mTextureEnabled = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070070}
71
72void 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
Mathias Agopiana8c386f2013-08-26 20:42:07 -070080void Description::setProjectionMatrix(const mat4& mtx) {
81 mProjectionMatrix = mtx;
Mathias Agopian3f844832013-08-07 21:24:32 -070082 mUniformsDirty = true;
83}
84
Mathias Agopianff2ed702013-09-01 21:36:12 -070085void Description::setColorMatrix(const mat4& mtx) {
86 const mat4 identity;
87 mColorMatrix = mtx;
88 mColorMatrixEnabled = (mtx != identity);
89}
90
Dan Stozaf0087992014-10-20 15:46:09 -070091const mat4& Description::getColorMatrix() const {
92 return mColorMatrix;
93}
94
Mathias Agopianff2ed702013-09-01 21:36:12 -070095
Mathias Agopian3f844832013-08-07 21:24:32 -070096} /* namespace android */