blob: 06eaf351251d07ecc3d8ae73f939049560bec245 [file] [log] [blame]
Mathias Agopian3f844832013-08-07 21:24:32 -07001/*
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 Agopian49457ac2013-08-14 18:20:17 -070018#include "Texture.h"
Mathias Agopian3f844832013-08-07 21:24:32 -070019
20#ifndef SF_RENDER_ENGINE_DESCRIPTION_H_
21#define SF_RENDER_ENGINE_DESCRIPTION_H_
22
23namespace android {
24
25class 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 */
34class Description {
Chia-I Wu7e65bc02018-01-11 14:31:38 -080035public:
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);
Peiyong Lin76dd77a2018-05-09 15:35:33 -070045 void setSaturationMatrix(const mat4& mtx);
Chia-I Wu7e65bc02018-01-11 14:31:38 -080046 void setColorMatrix(const mat4& mtx);
Peiyong Lina296b0c2018-04-30 16:55:29 -070047 void setInputTransformMatrix(const mat3& matrix);
48 void setOutputTransformMatrix(const mat4& matrix);
49 bool hasInputTransformMatrix() const;
50 bool hasOutputTransformMatrix() const;
51 bool hasColorMatrix() const;
Peiyong Lin76dd77a2018-05-09 15:35:33 -070052 bool hasSaturationMatrix() const;
Chia-I Wu7e65bc02018-01-11 14:31:38 -080053 const mat4& getColorMatrix() const;
54
Chia-I Wu131d3762018-01-11 14:35:27 -080055 void setY410BT2020(bool enable);
56
Chia-I Wu7e65bc02018-01-11 14:31:38 -080057 enum class TransferFunction : int {
58 LINEAR,
59 SRGB,
Chia-I Wu131d3762018-01-11 14:35:27 -080060 ST2084,
Peiyong Lina3fb7d62018-04-11 17:41:47 -070061 HLG, // Hybrid Log-Gamma for HDR.
Chia-I Wu7e65bc02018-01-11 14:31:38 -080062 };
63 void setInputTransferFunction(TransferFunction transferFunction);
64 void setOutputTransferFunction(TransferFunction transferFunction);
Peiyong Linfb069302018-04-25 14:34:31 -070065 void setDisplayMaxLuminance(const float maxLuminance);
Chia-I Wu7e65bc02018-01-11 14:31:38 -080066
67private:
Mathias Agopian3f844832013-08-07 21:24:32 -070068 friend class Program;
69 friend class ProgramCache;
70
Mathias Agopian3f844832013-08-07 21:24:32 -070071 // whether textures are premultiplied
Greg Kaiser25429cb2018-01-05 14:34:22 -080072 bool mPremultipliedAlpha = false;
Mathias Agopian3f844832013-08-07 21:24:32 -070073 // whether this layer is marked as opaque
Greg Kaiser25429cb2018-01-05 14:34:22 -080074 bool mOpaque = true;
Mathias Agopian3f844832013-08-07 21:24:32 -070075
Mathias Agopian49457ac2013-08-14 18:20:17 -070076 // Texture this layer uses
77 Texture mTexture;
Greg Kaiser25429cb2018-01-05 14:34:22 -080078 bool mTextureEnabled = false;
Mathias Agopian49457ac2013-08-14 18:20:17 -070079
chaviw13fdc492017-06-27 12:40:18 -070080 // color used when texturing is disabled or when setting alpha.
81 half4 mColor;
Mathias Agopianff2ed702013-09-01 21:36:12 -070082
Chia-I Wu131d3762018-01-11 14:35:27 -080083 // true if the sampled pixel values are in Y410/BT2020 rather than RGBA
84 bool mY410BT2020 = false;
85
Chia-I Wu7e65bc02018-01-11 14:31:38 -080086 // transfer functions for the input/output
87 TransferFunction mInputTransferFunction = TransferFunction::LINEAR;
88 TransferFunction mOutputTransferFunction = TransferFunction::LINEAR;
Peiyong Linfb069302018-04-25 14:34:31 -070089
90 float mDisplayMaxLuminance;
Peiyong Lina296b0c2018-04-30 16:55:29 -070091
92 // projection matrix
93 mat4 mProjectionMatrix;
94 mat4 mColorMatrix;
Peiyong Lin76dd77a2018-05-09 15:35:33 -070095 mat4 mSaturationMatrix;
Peiyong Lina296b0c2018-04-30 16:55:29 -070096 mat3 mInputTransformMatrix;
97 mat4 mOutputTransformMatrix;
Mathias Agopian3f844832013-08-07 21:24:32 -070098};
99
100} /* namespace android */
101
102#endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */