xref: /aosp_15_r20/frameworks/native/libs/ui/include/ui/PictureProfileHandle.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
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 
17 #pragma once
18 
19 #include <stdint.h>
20 #include <array>
21 #include <string>
22 
23 namespace android {
24 
25 /**
26  * An opaque value that uniquely identifies a picture profile, or a set of parameters, which
27  * describes the configuration of a picture processing pipeline that is applied to a graphic buffer
28  * to enhance its quality prior to rendering on the display.
29  */
30 typedef int64_t PictureProfileId;
31 
32 /**
33  * A picture profile handle wraps the picture profile ID for type-safety, and represents an opaque
34  * handle that doesn't have the performance drawbacks of Binders.
35  */
36 class PictureProfileHandle {
37 public:
38     // A profile that represents no picture processing.
39     static const PictureProfileHandle NONE;
40 
PictureProfileHandle()41     PictureProfileHandle() { *this = NONE; }
PictureProfileHandle(PictureProfileId id)42     explicit PictureProfileHandle(PictureProfileId id) : mId(id) {}
43 
getId()44     PictureProfileId const& getId() const { return mId; }
45 
46     inline bool operator==(const PictureProfileHandle& rhs) { return mId == rhs.mId; }
47     inline bool operator!=(const PictureProfileHandle& rhs) { return !(*this == rhs); }
48 
49     // Is the picture profile effectively null, or not-specified?
50     inline bool operator!() const { return mId == NONE.mId; }
51 
52     operator bool() const { return !!*this; }
53 
54     friend ::std::string toString(const PictureProfileHandle& handle);
55 
56 private:
57     PictureProfileId mId;
58 };
59 
60 } // namespace android
61