blob: b0325c67dbb8d0a6174a26eccbfbc1735c191025 [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;
32 mPremultipliedAlpha = true;
33 mOpaque = true;
Mathias Agopian49457ac2013-08-14 18:20:17 -070034 mTextureEnabled = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070035
Mathias Agopian3f844832013-08-07 21:24:32 -070036 memset(mColor, 0, sizeof(mColor));
Mathias Agopian3f844832013-08-07 21:24:32 -070037}
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
Mathias Agopian49457ac2013-08-14 18:20:17 -070061void Description::setTexture(const Texture& texture) {
62 mTexture = texture;
63 mTextureEnabled = true;
64 mUniformsDirty = true;
Mathias Agopian3f844832013-08-07 21:24:32 -070065}
66
67void Description::disableTexture() {
Mathias Agopian49457ac2013-08-14 18:20:17 -070068 mTextureEnabled = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070069}
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
Mathias Agopiana8c386f2013-08-26 20:42:07 -070079void Description::setProjectionMatrix(const mat4& mtx) {
80 mProjectionMatrix = mtx;
Mathias Agopian3f844832013-08-07 21:24:32 -070081 mUniformsDirty = true;
82}
83
Mathias Agopian3f844832013-08-07 21:24:32 -070084} /* namespace android */