xref: /aosp_15_r20/frameworks/native/libs/renderengine/skia/filters/LutShader.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 <SkBitmap.h>
19 #include <SkImage.h>
20 #include <SkRuntimeEffect.h>
21 
22 #include <aidl/android/hardware/graphics/composer3/LutProperties.h>
23 #include <gui/DisplayLuts.h>
24 #include <ui/GraphicTypes.h>
25 
26 namespace android {
27 namespace renderengine {
28 namespace skia {
29 
30 class LutShader {
31 public:
32     sk_sp<SkShader> lutShader(sk_sp<SkShader>& input, std::shared_ptr<gui::DisplayLuts> displayLuts,
33                               ui::Dataspace srcDataspace, sk_sp<SkColorSpace> outColorSpace);
34 
35 private:
36     sk_sp<SkShader> generateLutShader(sk_sp<SkShader> input, const std::vector<float>& buffers,
37                                       const int32_t offset, const int32_t length,
38                                       const int32_t dimension, const int32_t size,
39                                       const int32_t samplingKey, ui::Dataspace srcDataspace);
40     std::unique_ptr<SkRuntimeShaderBuilder> mBuilder;
41 };
42 
43 } // namespace skia
44 } // namespace renderengine
45 } // namespace android
46