• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #ifndef ANDROID_HWC_LAYER_H
18 #define ANDROID_HWC_LAYER_H
19 
20 #include <vector>
21 
22 #include "Common.h"
23 #include "FencedBuffer.h"
24 
25 namespace aidl::android::hardware::graphics::composer3::impl {
26 
27 class Layer {
28  public:
29   explicit Layer();
30 
31   Layer(const Layer&) = delete;
32   Layer& operator=(const Layer&) = delete;
33 
34   Layer(Layer&&) = default;
35   Layer& operator=(Layer&&) = default;
36 
getId()37   int64_t getId() const { return mId; }
38 
39   HWC3::Error setCursorPosition(const common::Point& cursorPosition);
40   common::Point getCursorPosition() const;
41 
42   HWC3::Error setBuffer(buffer_handle_t buffer,
43                         const ndk::ScopedFileDescriptor& fence);
44   FencedBuffer& getBuffer();
45   buffer_handle_t waitAndGetBuffer();
46 
47   HWC3::Error setSurfaceDamage(
48       const std::vector<std::optional<common::Rect>>& damage);
49 
50   HWC3::Error setBlendMode(common::BlendMode mode);
51   common::BlendMode getBlendMode() const;
52 
53   HWC3::Error setColor(Color color);
54   Color getColor() const;
55 
56   HWC3::Error setCompositionType(Composition composition);
57   Composition getCompositionType() const;
58 
59   HWC3::Error setDataspace(common::Dataspace dataspace);
60   common::Dataspace getDataspace() const;
61 
62   HWC3::Error setDisplayFrame(common::Rect frame);
63   common::Rect getDisplayFrame() const;
64 
65   HWC3::Error setPlaneAlpha(float alpha);
66   float getPlaneAlpha() const;
67 
68   HWC3::Error setSidebandStream(buffer_handle_t stream);
69 
70   HWC3::Error setSourceCrop(common::FRect crop);
71   common::FRect getSourceCrop() const;
72   common::Rect getSourceCropInt() const;
73 
74   HWC3::Error setTransform(common::Transform transform);
75   common::Transform getTransform() const;
76 
77   HWC3::Error setVisibleRegion(
78       const std::vector<std::optional<common::Rect>>& visible);
79   std::size_t getNumVisibleRegions() const;
80 
81   HWC3::Error setZOrder(int32_t z);
82   int32_t getZOrder() const;
83 
84   HWC3::Error setPerFrameMetadata(
85       const std::vector<std::optional<PerFrameMetadata>>& perFrameMetadata);
86 
87   HWC3::Error setColorTransform(const std::vector<float>& colorTransform);
88   const std::optional<std::array<float, 16>>& getColorTransform() const;
89 
90   HWC3::Error setBrightness(float brightness);
91   float getBrightness() const;
92 
93   HWC3::Error setPerFrameMetadataBlobs(
94       const std::vector<std::optional<PerFrameMetadataBlob>>& perFrameMetadata);
95 
96  private:
97   const int64_t mId;
98   common::Point mCursorPosition;
99   FencedBuffer mBuffer;
100   common::BlendMode mBlendMode = common::BlendMode::NONE;
101   Color mColor = {0, 0, 0, 0};
102   Composition mCompositionType = Composition::INVALID;
103   common::Dataspace mDataspace = common::Dataspace::UNKNOWN;
104   common::Rect mDisplayFrame = {0, 0, -1, -1};
105   float mPlaneAlpha = 0.0f;
106   common::FRect mSourceCrop = {0.0f, 0.0f, -1.0f, -1.0f};
107   common::Transform mTransform = common::Transform{0};
108   std::vector<common::Rect> mVisibleRegion;
109   int32_t mZOrder = 0;
110   std::optional<std::array<float, 16>> mColorTransform;
111   float mBrightness = 1.0f;
112 };
113 
114 }  // namespace aidl::android::hardware::graphics::composer3::impl
115 
116 #endif