summaryrefslogtreecommitdiff
path: root/hwc2/common/base/HwcLayer.h (plain)
blob: 2c378adb1d6bb7cb805ceabbc5a2d9b7c500087a
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
29namespace android {
30namespace amlogic {
31
32class 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
87#if WITH_LIBPLAYER_MODULE
88 void presentOverlay(bool bPresent);
89#endif
90
91 private:
92 void resetLayerBuffer();
93
94 private:
95 hwc2_display_t mDisplayId;
96 int32_t mBlendMode;
97 hwc_color_t mColor;
98 int32_t mCompositionType;
99 int32_t mAcquireFence;
100 int32_t mDataSpace;
101 float mPlaneAlpha;
102 int32_t mTransform;
103 int32_t mLastTransform;
104 uint32_t mZ;
105 hwc_frect_t mSourceCrop;
106 hwc_rect_t mDisplayFrame;
107 hwc_rect_t mLastDisplayFrame;
108 hwc_region_t mDamageRegion;
109 hwc_region_t mVisibleRegion;
110
111
112 union {
113 buffer_handle_t mBufferHnd;
114
115 /* When compositionType is HWC_SIDEBAND, this is the handle
116 * of the sideband video stream to compose. */
117 const native_handle_t* mSidebandStream;
118 };
119
120#if WITH_LIBPLAYER_MODULE
121 // for store overlay layer's state.
122 char mLastVal[32];
123 char mLastAxis[32];
124 char mLastMode[32];
125 char mLastFreescale[32];
126 char mLastWindowaxis[50];
127#endif
128 // lock
129 Mutex mLock;
130 bool mInitialized;
131 bool mScaleReversed;
132};
133
134} // namespace amlogic
135} // namespace android
136
137
138#endif /* HWC_LAYER_H */
139