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 { |
Chia-I Wu | 7e65bc0 | 2018-01-11 14:31:38 -0800 | [diff] [blame] | 35 | public: |
| 36 | Description() = default; |
| 37 | ~Description() = default; |
| 38 | |
| 39 | void setPremultipliedAlpha(bool premultipliedAlpha); |
| 40 | void setOpaque(bool opaque); |
| 41 | void setTexture(const Texture& texture); |
| 42 | void disableTexture(); |
| 43 | void setColor(const half4& color); |
| 44 | void setProjectionMatrix(const mat4& mtx); |
| 45 | void setColorMatrix(const mat4& mtx); |
| 46 | const mat4& getColorMatrix() const; |
| 47 | |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 48 | void setY410BT2020(bool enable); |
| 49 | |
Chia-I Wu | 7e65bc0 | 2018-01-11 14:31:38 -0800 | [diff] [blame] | 50 | enum class TransferFunction : int { |
| 51 | LINEAR, |
| 52 | SRGB, |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 53 | ST2084, |
Peiyong Lin | a3fb7d6 | 2018-04-11 17:41:47 -0700 | [diff] [blame] | 54 | HLG, // Hybrid Log-Gamma for HDR. |
Chia-I Wu | 7e65bc0 | 2018-01-11 14:31:38 -0800 | [diff] [blame] | 55 | }; |
| 56 | void setInputTransferFunction(TransferFunction transferFunction); |
| 57 | void setOutputTransferFunction(TransferFunction transferFunction); |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame^] | 58 | void setDisplayMaxLuminance(const float maxLuminance); |
Chia-I Wu | 7e65bc0 | 2018-01-11 14:31:38 -0800 | [diff] [blame] | 59 | |
| 60 | private: |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 61 | friend class Program; |
| 62 | friend class ProgramCache; |
| 63 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 64 | // whether textures are premultiplied |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 65 | bool mPremultipliedAlpha = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 66 | // whether this layer is marked as opaque |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 67 | bool mOpaque = true; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 68 | |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 69 | // Texture this layer uses |
| 70 | Texture mTexture; |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 71 | bool mTextureEnabled = false; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 72 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 73 | // color used when texturing is disabled or when setting alpha. |
| 74 | half4 mColor; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 75 | // projection matrix |
Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 76 | mat4 mProjectionMatrix; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 77 | |
Greg Kaiser | 25429cb | 2018-01-05 14:34:22 -0800 | [diff] [blame] | 78 | bool mColorMatrixEnabled = false; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 79 | mat4 mColorMatrix; |
| 80 | |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 81 | // true if the sampled pixel values are in Y410/BT2020 rather than RGBA |
| 82 | bool mY410BT2020 = false; |
| 83 | |
Chia-I Wu | 7e65bc0 | 2018-01-11 14:31:38 -0800 | [diff] [blame] | 84 | // transfer functions for the input/output |
| 85 | TransferFunction mInputTransferFunction = TransferFunction::LINEAR; |
| 86 | TransferFunction mOutputTransferFunction = TransferFunction::LINEAR; |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame^] | 87 | |
| 88 | float mDisplayMaxLuminance; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | } /* namespace android */ |
| 92 | |
| 93 | #endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ |