Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 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 = true; |
| 33 | mOpaque = true; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame^] | 34 | mTextureEnabled = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 35 | |
| 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 Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | Description::~Description() { |
| 42 | } |
| 43 | |
| 44 | void Description::setPlaneAlpha(GLclampf planeAlpha) { |
| 45 | if (planeAlpha != mPlaneAlpha) { |
| 46 | mUniformsDirty = true; |
| 47 | mPlaneAlpha = planeAlpha; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void Description::setPremultipliedAlpha(bool premultipliedAlpha) { |
| 52 | if (premultipliedAlpha != mPremultipliedAlpha) { |
| 53 | mPremultipliedAlpha = premultipliedAlpha; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | void Description::setOpaque(bool opaque) { |
| 58 | if (opaque != mOpaque) { |
| 59 | mOpaque = opaque; |
| 60 | } |
| 61 | } |
| 62 | |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame^] | 63 | void Description::setTexture(const Texture& texture) { |
| 64 | mTexture = texture; |
| 65 | mTextureEnabled = true; |
| 66 | mUniformsDirty = true; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void Description::disableTexture() { |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame^] | 70 | mTextureEnabled = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void 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 | |
| 81 | void Description::setProjectionMatrix(GLfloat const* mtx) { |
| 82 | memcpy(mProjectionMatrix, mtx, sizeof(mProjectionMatrix)); |
| 83 | mUniformsDirty = true; |
| 84 | } |
| 85 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 86 | } /* namespace android */ |