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 <GLES2/gl2.h> |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 18 | #include "Texture.h" |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 19 | |
| 20 | #ifndef SF_RENDER_ENGINE_DESCRIPTION_H_ |
| 21 | #define SF_RENDER_ENGINE_DESCRIPTION_H_ |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | class Program; |
| 26 | |
| 27 | /* |
| 28 | * This holds the state of the rendering engine. This class is used |
| 29 | * to generate a corresponding GLSL program and set the appropriate |
| 30 | * uniform. |
| 31 | * |
| 32 | * Program and ProgramCache are friends and access the state directly |
| 33 | */ |
| 34 | class Description { |
| 35 | friend class Program; |
| 36 | friend class ProgramCache; |
| 37 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 38 | // whether textures are premultiplied |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 39 | bool mPremultipliedAlpha = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 40 | // whether this layer is marked as opaque |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 41 | bool mOpaque = true; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 42 | |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 43 | // Texture this layer uses |
| 44 | Texture mTexture; |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 45 | bool mTextureEnabled = false; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 46 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 47 | // color used when texturing is disabled or when setting alpha. |
| 48 | half4 mColor; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 49 | // projection matrix |
Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 50 | mat4 mProjectionMatrix; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 51 | |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 52 | bool mColorMatrixEnabled = false; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 53 | mat4 mColorMatrix; |
| 54 | |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 55 | bool mIsWideGamut = false; |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 56 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 57 | public: |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 58 | Description() = default; |
| 59 | ~Description() = default; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 60 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 61 | void setPremultipliedAlpha(bool premultipliedAlpha); |
| 62 | void setOpaque(bool opaque); |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 63 | void setTexture(const Texture& texture); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 64 | void disableTexture(); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 65 | void setColor(const half4& color); |
Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 66 | void setProjectionMatrix(const mat4& mtx); |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 67 | void setColorMatrix(const mat4& mtx); |
Dan Stoza | f008799 | 2014-10-20 15:46:09 -0700 | [diff] [blame] | 68 | const mat4& getColorMatrix() const; |
Romain Guy | 88d37dd | 2017-05-26 17:57:05 -0700 | [diff] [blame] | 69 | void setWideGamut(bool wideGamut); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } /* namespace android */ |
| 73 | |
| 74 | #endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ |