1 /*
2  * Copyright 2020 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 #pragma once
18 
19 #include <math/mat4.h>
20 
21 #include <optional>
22 
23 #include <shaders/shaders.h>
24 #include "SkRuntimeEffect.h"
25 #include "SkShader.h"
26 #include "ui/GraphicTypes.h"
27 
28 namespace android {
29 namespace renderengine {
30 namespace skia {
31 
32 sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEffect);
33 
34 // Generates a shader resulting from applying the a linear effect created from
35 // LinearEffectArgs::buildEffect to an inputShader.
36 // Optionally, a color transform may also be provided, which combines with the
37 // matrix transforming from linear XYZ to linear RGB immediately before OETF.
38 // We also provide additional HDR metadata upon creating the shader:
39 // * The max display luminance is the max luminance of the physical display in nits
40 // * The current luminance of the physical display in nits
41 // * The max luminance is provided as the max luminance for the buffer, either from the SMPTE 2086
42 // or as the max light level from the CTA 861.3 standard.
43 // * An AHardwareBuffer for implementations that support gralloc4 metadata for
44 // communicating any HDR metadata.
45 // * A RenderIntent that communicates the downstream renderintent for a physical display, for image
46 // quality compensation.
47 sk_sp<SkShader> createLinearEffectShader(
48         sk_sp<SkShader> inputShader, const shaders::LinearEffect& linearEffect,
49         sk_sp<SkRuntimeEffect> runtimeEffect, const mat4& colorTransform, float maxDisplayLuminance,
50         float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
51         aidl::android::hardware::graphics::composer3::RenderIntent renderIntent);
52 } // namespace skia
53 } // namespace renderengine
54 } // namespace android
55