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