xref: /aosp_15_r20/frameworks/native/libs/renderengine/skia/filters/GainmapFactory.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright 2024 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 #pragma once
17 
18 #include <SkRuntimeEffect.h>
19 #include <SkShader.h>
20 
21 namespace android {
22 namespace renderengine {
23 namespace skia {
24 
25 /**
26  * Generates a shader for computing a gainmap, given an SDR base image and its idealized HDR
27  * rendition. The shader follows the procedure in the UltraHDR spec:
28  * https://developer.android.com/media/platform/hdr-image-format#gain_map-generation, but makes some
29  * simplifying assumptions about metadata typical for RenderEngine's usage.
30  */
31 class GainmapFactory {
32 public:
33     GainmapFactory();
34     // Generates the gainmap shader. The hdrSdrRatio is the max_content_boost in the UltraHDR
35     // specification.
36     sk_sp<SkShader> createSkShader(const sk_sp<SkShader>& sdr, const sk_sp<SkShader>& hdr,
37                                    float hdrSdrRatio);
38 
39 private:
40     sk_sp<SkRuntimeEffect> mEffect;
41 };
42 } // namespace skia
43 } // namespace renderengine
44 } // namespace android
45