blob: 8e404b29257b52b4f0892147b5d2f26d63a47c0a [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
36 const GLfloat m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
37 memset(mColor, 0, sizeof(mColor));
38 memcpy(mProjectionMatrix, m, sizeof(mProjectionMatrix));
Mathias Agopian3f844832013-08-07 21:24:32 -070039}
40
41Description::~Description() {
42}
43
44void Description::setPlaneAlpha(GLclampf planeAlpha) {
45 if (planeAlpha != mPlaneAlpha) {
46 mUniformsDirty = true;
47 mPlaneAlpha = planeAlpha;
48 }
49}
50
51void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
52 if (premultipliedAlpha != mPremultipliedAlpha) {
53 mPremultipliedAlpha = premultipliedAlpha;
54 }
55}
56
57void Description::setOpaque(bool opaque) {
58 if (opaque != mOpaque) {
59 mOpaque = opaque;
60 }
61}
62
Mathias Agopian49457ac2013-08-14 18:20:17 -070063void Description::setTexture(const Texture& texture) {
64 mTexture = texture;
65 mTextureEnabled = true;
66 mUniformsDirty = true;
Mathias Agopian3f844832013-08-07 21:24:32 -070067}
68
69void Description::disableTexture() {
Mathias Agopian49457ac2013-08-14 18:20:17 -070070 mTextureEnabled = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070071}
72
73void Description::setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
74 mColor[0] = red;
75 mColor[1] = green;
76 mColor[2] = blue;
77 mColor[3] = alpha;
78 mUniformsDirty = true;
79}
80
81void Description::setProjectionMatrix(GLfloat const* mtx) {
82 memcpy(mProjectionMatrix, mtx, sizeof(mProjectionMatrix));
83 mUniformsDirty = true;
84}
85
Mathias Agopian3f844832013-08-07 21:24:32 -070086} /* namespace android */