• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
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 
17 #ifndef ANDROID_OVERLAY_H
18 #define ANDROID_OVERLAY_H
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 
23 #include <utils/Errors.h>
24 #include <binder/IInterface.h>
25 #include <utils/RefBase.h>
26 #include <utils/threads.h>
27 
28 #include <ui/PixelFormat.h>
29 #include <ui/IOverlay.h>
30 
31 #include <hardware/overlay.h>
32 
33 namespace android {
34 
35 class IMemory;
36 class IMemoryHeap;
37 
38 // ----------------------------------------------------------------------------
39 
40 class OverlayRef : public LightRefBase<OverlayRef>
41 {
42 public:
43     OverlayRef(overlay_handle_t, const sp<IOverlay>&,
44             uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs);
45 
46     static sp<OverlayRef> readFromParcel(const Parcel& data);
47     static status_t writeToParcel(Parcel* reply, const sp<OverlayRef>& o);
48 
49 private:
50     friend class LightRefBase<OverlayRef>;
51     friend class Overlay;
52 
53     OverlayRef();
54     virtual ~OverlayRef();
55 
56     overlay_handle_t mOverlayHandle;
57     sp<IOverlay> mOverlayChannel;
58     uint32_t mWidth;
59     uint32_t mHeight;
60     int32_t  mFormat;
61     int32_t  mWidthStride;
62     int32_t  mHeightStride;
63     bool mOwnHandle;
64 };
65 
66 // ----------------------------------------------------------------------------
67 
68 class Overlay : public virtual RefBase
69 {
70 public:
71     Overlay(const sp<OverlayRef>& overlayRef);
72 
73     /* destroys this overlay */
74     void destroy();
75 
76     /* get the HAL handle for this overlay */
77     overlay_handle_t getHandleRef() const;
78 
79     /* blocks until an overlay buffer is available and return that buffer. */
80     status_t dequeueBuffer(overlay_buffer_t* buffer);
81 
82     /* release the overlay buffer and post it */
83     status_t queueBuffer(overlay_buffer_t buffer);
84 
85     /* change the width and height of the overlay */
86     status_t resizeInput(uint32_t width, uint32_t height);
87 
88     status_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;
89 
90     status_t getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;
91 
92     /* set the buffer attributes */
93     status_t setParameter(int param, int value);
94 
95     /* returns the address of a given buffer if supported, NULL otherwise. */
96     void* getBufferAddress(overlay_buffer_t buffer);
97 
98     /* get physical informations about the overlay */
99     uint32_t getWidth() const;
100     uint32_t getHeight() const;
101     int32_t getFormat() const;
102     int32_t getWidthStride() const;
103     int32_t getHeightStride() const;
104     int32_t getBufferCount() const;
105     status_t getStatus() const;
106 
107 private:
108     virtual ~Overlay();
109 
110     sp<OverlayRef> mOverlayRef;
111     overlay_data_device_t *mOverlayData;
112     status_t mStatus;
113 };
114 
115 // ----------------------------------------------------------------------------
116 
117 }; // namespace android
118 
119 #endif // ANDROID_OVERLAY_H
120