summaryrefslogtreecommitdiff
path: root/libs/renderengine/include/renderengine/private/Description.h
blob: a62161a8a8b8e0bcf5337fcc07c33dadcb89a64a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SF_RENDER_ENGINE_DESCRIPTION_H_
#define SF_RENDER_ENGINE_DESCRIPTION_H_

#include <renderengine/Texture.h>
#include <ui/GraphicTypes.h>

namespace android {
namespace renderengine {

/*
 * This is the structure that holds the state of the rendering engine.
 * This class is used to generate a corresponding GLSL program and set the
 * appropriate uniform.
 */
struct Description {
    enum class TransferFunction : int {
        LINEAR,
        SRGB,
        ST2084,
        HLG, // Hybrid Log-Gamma for HDR.
    };

    static TransferFunction dataSpaceToTransferFunction(ui::Dataspace dataSpace);

    Description() = default;
    ~Description() = default;

    bool hasInputTransformMatrix() const;
    bool hasOutputTransformMatrix() const;
    bool hasColorMatrix() const;

    // whether textures are premultiplied
    bool isPremultipliedAlpha = false;
    // whether this layer is marked as opaque
    bool isOpaque = true;

    // corner radius of the layer
    float cornerRadius = 0;

    // Size of the rounded rectangle we are cropping to
    half2 cropSize;

    // Texture this layer uses
    Texture texture;
    bool textureEnabled = false;

    // color used when texturing is disabled or when setting alpha.
    half4 color;

    // true if the sampled pixel values are in Y410/BT2020 rather than RGBA
    bool isY410BT2020 = false;

    // transfer functions for the input/output
    TransferFunction inputTransferFunction = TransferFunction::LINEAR;
    TransferFunction outputTransferFunction = TransferFunction::LINEAR;

    float displayMaxLuminance;
    float maxMasteringLuminance;
    float maxContentLuminance;

    // projection matrix
    mat4 projectionMatrix;

    // The color matrix will be applied in linear space right before OETF.
    mat4 colorMatrix;
    mat4 inputTransformMatrix;
    mat4 outputTransformMatrix;

    // True if this layer will draw a shadow.
    bool drawShadows = false;
};

} // namespace renderengine
} // namespace android

#endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */