1 /* 2 * Copyright 2018 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 <stdint.h> 20 #include <ui/GraphicTypes.h> 21 #include <optional> 22 #include <vector> 23 24 #include <system/graphics.h> 25 #include <utils/Flattenable.h> 26 27 namespace android { 28 29 struct HdrMetadata : public LightFlattenable<HdrMetadata> { 30 enum Type : uint32_t { 31 SMPTE2086 = 1 << 0, 32 CTA861_3 = 1 << 1, 33 HDR10PLUS = 1 << 2, 34 }; 35 36 uint32_t validTypes{0}; 37 38 android_smpte2086_metadata smpte2086{}; 39 android_cta861_3_metadata cta8613{}; 40 std::vector<uint8_t> hdr10plus{}; 41 42 // LightFlattenable isFixedSizeHdrMetadata43 bool isFixedSize() const { return false; } 44 size_t getFlattenedSize() const; 45 status_t flatten(void* buffer, size_t size) const; 46 status_t unflatten(void const* buffer, size_t size); 47 getSmpte2086HdrMetadata48 std::optional<ui::Smpte2086> getSmpte2086() const { 49 if (validTypes & Type::SMPTE2086) { 50 return ui::translate(smpte2086); 51 } 52 return {}; 53 } 54 getCta8613HdrMetadata55 std::optional<ui::Cta861_3> getCta8613() const { 56 if (validTypes & Type::CTA861_3) { 57 return ui::translate(cta8613); 58 } 59 return {}; 60 } 61 getHdr10PlusHdrMetadata62 std::optional<std::vector<uint8_t>> getHdr10Plus() const { 63 if (validTypes & Type::HDR10PLUS) { 64 return hdr10plus; 65 } 66 return {}; 67 } 68 69 bool operator==(const HdrMetadata& rhs) const; 70 bool operator!=(const HdrMetadata& rhs) const { return !(*this == rhs); } 71 }; 72 73 } // namespace android 74