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 #include <renderengine/private/Description.h>
18 
19 #include <stdint.h>
20 
21 #include <utils/TypeHelpers.h>
22 
23 namespace android {
24 namespace renderengine {
25 
dataSpaceToTransferFunction(ui::Dataspace dataSpace)26 Description::TransferFunction Description::dataSpaceToTransferFunction(ui::Dataspace dataSpace) {
27     ui::Dataspace transfer = static_cast<ui::Dataspace>(dataSpace & ui::Dataspace::TRANSFER_MASK);
28     switch (transfer) {
29         case ui::Dataspace::TRANSFER_ST2084:
30             return Description::TransferFunction::ST2084;
31         case ui::Dataspace::TRANSFER_HLG:
32             return Description::TransferFunction::HLG;
33         case ui::Dataspace::TRANSFER_LINEAR:
34             return Description::TransferFunction::LINEAR;
35         default:
36             return Description::TransferFunction::SRGB;
37     }
38 }
39 
hasInputTransformMatrix() const40 bool Description::hasInputTransformMatrix() const {
41     const mat4 identity;
42     return inputTransformMatrix != identity;
43 }
44 
hasOutputTransformMatrix() const45 bool Description::hasOutputTransformMatrix() const {
46     const mat4 identity;
47     return outputTransformMatrix != identity;
48 }
49 
hasColorMatrix() const50 bool Description::hasColorMatrix() const {
51     const mat4 identity;
52     return colorMatrix != identity;
53 }
54 
55 } // namespace renderengine
56 } // namespace android
57