1 /* 2 * Copyright (C) 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 <android-base/unique_fd.h> 19 #include <binder/Parcel.h> 20 #include <binder/Parcelable.h> 21 #include <vector> 22 23 namespace android::gui { 24 25 struct DisplayLuts : public Parcelable { 26 public: 27 struct Entry : public Parcelable { EntryDisplayLuts::Entry28 Entry() {}; EntryDisplayLuts::Entry29 Entry(int32_t lutDimension, int32_t lutSize, int32_t lutSamplingKey) 30 : dimension(lutDimension), size(lutSize), samplingKey(lutSamplingKey) {} 31 int32_t dimension; 32 int32_t size; 33 int32_t samplingKey; 34 35 status_t writeToParcel(android::Parcel* parcel) const override; 36 status_t readFromParcel(const android::Parcel* parcel) override; 37 }; 38 DisplayLutsDisplayLuts39 DisplayLuts() {} 40 DisplayLutsDisplayLuts41 DisplayLuts(base::unique_fd lutfd, std::vector<int32_t> lutoffsets, 42 std::vector<int32_t> lutdimensions, std::vector<int32_t> lutsizes, 43 std::vector<int32_t> lutsamplingKeys) { 44 fd = std::move(lutfd); 45 offsets = lutoffsets; 46 lutProperties.reserve(offsets.size()); 47 for (size_t i = 0; i < lutoffsets.size(); i++) { 48 Entry entry{lutdimensions[i], lutsizes[i], lutsamplingKeys[i]}; 49 lutProperties.emplace_back(entry); 50 } 51 } 52 53 status_t writeToParcel(android::Parcel* parcel) const override; 54 status_t readFromParcel(const android::Parcel* parcel) override; 55 getLutFileDescriptorDisplayLuts56 const base::unique_fd& getLutFileDescriptor() const { return fd; } 57 58 std::vector<Entry> lutProperties; 59 std::vector<int32_t> offsets; 60 61 private: 62 base::unique_fd fd; 63 }; // struct DisplayLuts 64 65 } // namespace android::gui