• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 android {
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 
37   HWC2::Error setBuffer(buffer_handle_t buffer, int32_t acquireFence);
getBuffer()38   FencedBuffer& getBuffer() { return mBuffer; }
39 
40   buffer_handle_t waitAndGetBuffer();
41 
getId()42   hwc2_layer_t getId() const { return mId; }
43 
44   HWC2::Error setCursorPosition(int32_t x, int32_t y);
45 
46   HWC2::Error setSurfaceDamage(hwc_region_t damage);
47 
48   HWC2::Error setBlendMode(int32_t mode);
49   HWC2::BlendMode getBlendMode() const;
50 
51   HWC2::Error setColor(hwc_color_t color);
52   hwc_color_t getColor() const;
53 
54   HWC2::Error setCompositionTypeEnum(HWC2::Composition type);
55   HWC2::Error setCompositionType(int32_t type);
56   HWC2::Composition getCompositionType() const;
57 
58   HWC2::Error setDataspace(int32_t dataspace);
59 
60   HWC2::Error setDisplayFrame(hwc_rect_t frame);
61   hwc_rect_t getDisplayFrame() const;
62 
63   HWC2::Error setPlaneAlpha(float alpha);
64   float getPlaneAlpha() const;
65 
66   HWC2::Error setSidebandStream(const native_handle_t* stream);
67 
68   HWC2::Error setSourceCrop(hwc_frect_t crop);
69   hwc_frect_t getSourceCrop() const;
70   hwc_rect_t getSourceCropInt() const;
71 
72   HWC2::Error setTransform(int32_t transform);
73   hwc_transform_t getTransform() const;
74 
75   HWC2::Error setVisibleRegion(hwc_region_t visible);
76   std::size_t getNumVisibleRegions() const;
77 
78   HWC2::Error setZ(uint32_t z);
79   uint32_t getZ() const;
80 
81  private:
82   const hwc2_layer_t mId;
83   FencedBuffer mBuffer;
84   std::vector<hwc_rect_t> mSurfaceDamage;
85   HWC2::BlendMode mBlendMode = HWC2::BlendMode::None;
86   hwc_color_t mColor = {0, 0, 0, 0};
87   HWC2::Composition mCompositionType = HWC2::Composition::Invalid;
88   hwc_rect_t mDisplayFrame = {0, 0, -1, -1};
89   float mPlaneAlpha = 0.0f;
90   const native_handle_t* mSidebandStream = nullptr;
91   hwc_frect_t mSourceCrop = {0.0f, 0.0f, -1.0f, -1.0f};
92   HWC2::Transform mTransform = HWC2::Transform::None;
93   std::vector<hwc_rect_t> mVisibleRegion;
94   uint32_t mZ = 0;
95 };
96 
97 }  // namespace android
98 
99 #endif