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 | |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 29 | Description::Description() { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 30 | mPlaneAlpha = 1.0f; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 31 | mPremultipliedAlpha = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 32 | mOpaque = true; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 33 | mTextureEnabled = false; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 34 | mColorMatrixEnabled = false; |
Greg Kaiser | 4ca7a3f | 2018-01-05 13:44:44 -0800 | [diff] [blame] | 35 | mIsWideGamut = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 36 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 37 | memset(mColor, 0, sizeof(mColor)); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | Description::~Description() { |
| 41 | } |
| 42 | |
| 43 | void Description::setPlaneAlpha(GLclampf planeAlpha) { |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 44 | mPlaneAlpha = planeAlpha; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void Description::setPremultipliedAlpha(bool premultipliedAlpha) { |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 48 | mPremultipliedAlpha = premultipliedAlpha; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void Description::setOpaque(bool opaque) { |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 52 | mOpaque = opaque; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 55 | void Description::setTexture(const Texture& texture) { |
| 56 | mTexture = texture; |
| 57 | mTextureEnabled = true; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void Description::disableTexture() { |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 61 | mTextureEnabled = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void Description::setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { |
| 65 | mColor[0] = red; |
| 66 | mColor[1] = green; |
| 67 | mColor[2] = blue; |
| 68 | mColor[3] = alpha; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 71 | void Description::setProjectionMatrix(const mat4& mtx) { |
| 72 | mProjectionMatrix = mtx; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 75 | void Description::setColorMatrix(const mat4& mtx) { |
| 76 | const mat4 identity; |
| 77 | mColorMatrix = mtx; |
| 78 | mColorMatrixEnabled = (mtx != identity); |
| 79 | } |
| 80 | |
Dan Stoza | f008799 | 2014-10-20 15:46:09 -0700 | [diff] [blame] | 81 | const mat4& Description::getColorMatrix() const { |
| 82 | return mColorMatrix; |
| 83 | } |
| 84 | |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 85 | void Description::setWideGamut(bool wideGamut) { |
| 86 | mIsWideGamut = wideGamut; |
| 87 | } |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 88 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 89 | } /* namespace android */ |