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