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 #ifndef HWC_LAYER_H
17 #define HWC_LAYER_H
18 
19 #include <hardware/hwcomposer.h>
20 #include <DisplayPlane.h>
21 
22 
23 namespace android {
24 namespace intel {
25 
26 class HwcLayer {
27 public:
28     enum {
29         // LAYER_FB layers are marked as HWC_FRAMEBUFFER.
30         // And a LAYER_FB can become HWC_OVERLAY layers during
31         // revisiting layer list.
32         LAYER_FB = 0,
33         // LAYER_FORCE_FB layers are marked as HWC_FRAMEBUFFER.
34         // And a LAYER_FORCE_FB can never become HWC_OVERLAY layers during
35         // revisiting layer list.
36         LAYER_FORCE_FB,
37         // LAYER_OVERLAY layers are marked as HWC_OVERLAY
38         LAYER_OVERLAY,
39         // LAYER_SKIPPED layers are marked as HWC_OVERLAY with no plane attached
40         LAYER_SKIPPED,
41         // LAYER_FRAMEBUFFER_TARGET layers are marked as HWC_FRAMEBUFFER_TARGET
42         LAYER_FRAMEBUFFER_TARGET,
43         // LAYER_SIDEBAND layers have alternate path bypassing HWC after setup
44         LAYER_SIDEBAND,
45         // LAYER_CURSOR_OVERLAY layers support hardware cursor planes
46         LAYER_CURSOR_OVERLAY,
47     };
48 
49     enum {
50         LAYER_PRIORITY_OVERLAY = 0x60000000UL,
51         LAYER_PRIORITY_PROTECTED = 0x70000000UL,
52         LAYER_PRIORITY_SIZE_OFFSET = 4,
53     };
54 public:
55     HwcLayer(int index, hwc_layer_1_t *layer);
56     virtual ~HwcLayer();
57 
58     // plane operations
59     bool attachPlane(DisplayPlane *plane, int device);
60     DisplayPlane* detachPlane();
61 
62     void setType(uint32_t type);
63     uint32_t getType() const;
64     int32_t getCompositionType() const;
65     void setCompositionType(int32_t type);
66 
67     int getIndex() const;
68     int getZOrder() const;
69     uint32_t getFormat() const;
70     uint32_t getBufferWidth() const;
71     uint32_t getBufferHeight() const;
72     const stride_t& getBufferStride() const;
73     uint32_t getUsage() const;
74     uint32_t getHandle() const;
75     uint32_t getTransform() const;
76     bool isProtected() const;
77     hwc_layer_1_t* getLayer() const;
78     DisplayPlane* getPlane() const;
79 
80     void setPriority(uint32_t priority);
81     uint32_t getPriority() const;
82 
83     bool update(hwc_layer_1_t *layer);
84     void postFlip();
85     bool isUpdated();
86 
87 public:
88     // temporary solution for plane assignment
89     bool mPlaneCandidate;
90 
91 private:
92     void setupAttributes();
93 
94 private:
95     const int mIndex;
96     int mZOrder;
97     int mDevice;
98     hwc_layer_1_t *mLayer;
99     DisplayPlane *mPlane;
100     uint32_t mFormat;
101     uint32_t mWidth;
102     uint32_t mHeight;
103     stride_t mStride;
104     uint32_t mUsage;
105     uint32_t mHandle;
106     bool mIsProtected;
107     uint32_t mType;
108     uint32_t mPriority;
109     uint32_t mTransform;
110 
111     // for smart composition
112     hwc_frect_t mSourceCropf;
113     hwc_rect_t mDisplayFrame;
114     bool mUpdated;
115 };
116 
117 
118 } // namespace intel
119 } // namespace android
120 
121 
122 #endif /* HWC_LAYER_H */
123