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 #ifndef SF_RENDER_ENGINE_DESCRIPTION_H_ 18 #define SF_RENDER_ENGINE_DESCRIPTION_H_ 19 20 #include <renderengine/Texture.h> 21 #include <ui/GraphicTypes.h> 22 23 namespace android { 24 namespace renderengine { 25 26 /* 27 * This is the structure that holds the state of the rendering engine. 28 * This class is used to generate a corresponding GLSL program and set the 29 * appropriate uniform. 30 */ 31 struct Description { 32 enum class TransferFunction : int { 33 LINEAR, 34 SRGB, 35 ST2084, 36 HLG, // Hybrid Log-Gamma for HDR. 37 }; 38 39 static TransferFunction dataSpaceToTransferFunction(ui::Dataspace dataSpace); 40 41 Description() = default; 42 ~Description() = default; 43 44 bool hasInputTransformMatrix() const; 45 bool hasOutputTransformMatrix() const; 46 bool hasColorMatrix() const; 47 bool hasDisplayColorMatrix() const; 48 49 // whether textures are premultiplied 50 bool isPremultipliedAlpha = false; 51 // whether this layer is marked as opaque 52 bool isOpaque = true; 53 54 // corner radius of the layer 55 float cornerRadius = 0; 56 57 // Size of the rounded rectangle we are cropping to 58 half2 cropSize; 59 60 // Texture this layer uses 61 Texture texture; 62 bool textureEnabled = false; 63 64 // color used when texturing is disabled or when setting alpha. 65 half4 color; 66 67 // true if the sampled pixel values are in Y410/BT2020 rather than RGBA 68 bool isY410BT2020 = false; 69 70 // transfer functions for the input/output 71 TransferFunction inputTransferFunction = TransferFunction::LINEAR; 72 TransferFunction outputTransferFunction = TransferFunction::LINEAR; 73 74 float displayMaxLuminance; 75 float maxMasteringLuminance; 76 float maxContentLuminance; 77 78 // projection matrix 79 mat4 projectionMatrix; 80 81 // The color matrix will be applied in linear space right before OETF. 82 mat4 colorMatrix; 83 // The display color matrix will be applied in gamma space after OETF 84 mat4 displayColorMatrix; 85 mat4 inputTransformMatrix; 86 mat4 outputTransformMatrix; 87 88 // True if this layer will draw a shadow. 89 bool drawShadows = false; 90 }; 91 92 } // namespace renderengine 93 } // namespace android 94 95 #endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ 96