blob: ab69881e23c6e0d4c383190080786e731c8c0c71
1 | /* |
2 | // Copyright (c) 2014 Intel Corporation |
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 | // This file is modified by Amlogic, Inc. 2017.01.17. |
17 | */ |
18 | |
19 | #ifndef HWC_LAYER_H |
20 | #define HWC_LAYER_H |
21 | |
22 | #include <hardware/hwcomposer2.h> |
23 | #include <utils/threads.h> |
24 | #include <Dump.h> |
25 | #include <utils/Vector.h> |
26 | #include <Utils.h> |
27 | #include <HwcFenceControl.h> |
28 | |
29 | namespace android { |
30 | namespace amlogic { |
31 | |
32 | class HwcLayer { |
33 | public: |
34 | HwcLayer(hwc2_display_t& dpy); |
35 | virtual ~HwcLayer(); |
36 | |
37 | // HWC2 Layer functions |
38 | int32_t setBuffer(buffer_handle_t buffer, int32_t acquireFence); |
39 | int32_t setSurfaceDamage(hwc_region_t damage); |
40 | |
41 | // HWC2 Layer state functions |
42 | int32_t setBlendMode(int32_t mode); |
43 | int32_t setColor(hwc_color_t color); |
44 | int32_t setDataspace(int32_t dataspace); |
45 | int32_t setDisplayFrame(hwc_rect_t frame); |
46 | int32_t setPlaneAlpha(float alpha); |
47 | int32_t setSidebandStream(const native_handle_t* stream); |
48 | int32_t setSourceCrop(hwc_frect_t crop); |
49 | int32_t setTransform(int32_t transform); |
50 | int32_t setVisibleRegion(hwc_region_t visible); |
51 | int32_t setZ(uint32_t z); |
52 | uint32_t getZ() const { return mZ; } |
53 | |
54 | int32_t setCompositionType(int32_t type); |
55 | int32_t getCompositionType() const { return mCompositionType; } |
56 | |
57 | // get HWC2 Layer state functions |
58 | buffer_handle_t getBufferHandle() const { return mBufferHnd; } |
59 | const native_handle_t* getSidebandStream() const { return mSidebandStream; } |
60 | int32_t getAcquireFence() const { return mAcquireFence; } |
61 | int32_t getDuppedAcquireFence() { return HwcFenceControl::dupFence(mAcquireFence); } |
62 | hwc_region_t getSurfaceDamage() { return mDamageRegion; }; |
63 | int32_t getBlendMode() { return mBlendMode; }; |
64 | hwc_color_t getColor() { return mColor; }; |
65 | int32_t getDataspace() { return mDataSpace; }; |
66 | hwc_rect_t getDisplayFrame() { return mDisplayFrame;}; |
67 | float getPlaneAlpha() { return mPlaneAlpha; }; |
68 | hwc_frect_t getSourceCrop() { return mSourceCrop; }; |
69 | int32_t getTransform() { return mTransform; }; |
70 | hwc_region_t getVisibleRegion() { return mVisibleRegion; }; |
71 | |
72 | bool initialize(); |
73 | void deinitialize(); |
74 | void dump(Dump& d); |
75 | |
76 | void resetAcquireFence(); |
77 | |
78 | bool isCropped(); |
79 | bool isScaled(); |
80 | bool isOffset(); |
81 | bool isBlended(); |
82 | bool haveColor(); |
83 | bool havePlaneAlpha(); |
84 | bool haveDataspace(); |
85 | void reverseScaledFrame(const float& scaleX, const float& scaleY); |
86 | void presentOverlay(bool bPresent); |
87 | |
88 | private: |
89 | void resetLayerBuffer(); |
90 | |
91 | private: |
92 | hwc2_display_t mDisplayId; |
93 | int32_t mBlendMode; |
94 | hwc_color_t mColor; |
95 | int32_t mCompositionType; |
96 | int32_t mAcquireFence; |
97 | int32_t mDataSpace; |
98 | float mPlaneAlpha; |
99 | int32_t mTransform; |
100 | int32_t mLastTransform; |
101 | uint32_t mZ; |
102 | hwc_frect_t mSourceCrop; |
103 | hwc_rect_t mDisplayFrame; |
104 | hwc_rect_t mLastDisplayFrame; |
105 | hwc_region_t mDamageRegion; |
106 | hwc_region_t mVisibleRegion; |
107 | |
108 | |
109 | union { |
110 | buffer_handle_t mBufferHnd; |
111 | |
112 | /* When compositionType is HWC_SIDEBAND, this is the handle |
113 | * of the sideband video stream to compose. */ |
114 | const native_handle_t* mSidebandStream; |
115 | }; |
116 | |
117 | // for store overlay layer's state. |
118 | char mLastVal[32]; |
119 | char mLastAxis[32]; |
120 | char mLastMode[32]; |
121 | char mLastFreescale[32]; |
122 | char mLastWindowaxis[50]; |
123 | |
124 | // lock |
125 | Mutex mLock; |
126 | bool mInitialized; |
127 | bool mScaleReversed; |
128 | }; |
129 | |
130 | } // namespace amlogic |
131 | } // namespace android |
132 | |
133 | |
134 | #endif /* HWC_LAYER_H */ |
135 |