summaryrefslogtreecommitdiff
path: root/hwc2/common/base/HwcLayer.h (plain)
blob: 923248b6c9e5277a432e84c0abf69be23d165cb4
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
86#if WITH_LIBPLAYER_MODULE
87 void presentOverlay();
88#endif
89
90 private:
91 hwc2_display_t mDisplayId;
92 int32_t mBlendMode;
93 hwc_color_t mColor;
94 int32_t mCompositionType;
95 int32_t mAcquireFence;
96 int32_t mDataSpace;
97 float mPlaneAlpha;
98 int32_t mTransform;
99 int32_t mLastTransform;
100 uint32_t mZ;
101 hwc_frect_t mSourceCrop;
102 hwc_rect_t mDisplayFrame;
103 hwc_rect_t mLastDisplayFrame;
104 hwc_region_t mDamageRegion;
105 hwc_region_t mVisibleRegion;
106
107
108 union {
109 buffer_handle_t mBufferHnd;
110
111 /* When compositionType is HWC_SIDEBAND, this is the handle
112 * of the sideband video stream to compose. */
113 const native_handle_t* mSidebandStream;
114 };
115
116#if WITH_LIBPLAYER_MODULE
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#endif
124 // lock
125 Mutex mLock;
126 bool mInitialized;
127};
128
129} // namespace amlogic
130} // namespace android
131
132
133#endif /* HWC_LAYER_H */
134