blob: 9ba2f7b6fd1cdeddb4a5053b51f4f5555842591c [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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>
Mathias Agopian07952722009-05-19 19:08:10 -070024#include <binder/IInterface.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025#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
33namespace android {
34
35class IMemory;
36class IMemoryHeap;
37
38// ----------------------------------------------------------------------------
39
40class OverlayRef : public LightRefBase<OverlayRef>
41{
42public:
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
49private:
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
68class Overlay : public virtual RefBase
69{
70public:
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 /* returns the address of a given buffer if supported, NULL otherwise. */
86 void* getBufferAddress(overlay_buffer_t buffer);
87
88 /* get physical informations about the overlay */
89 uint32_t getWidth() const;
90 uint32_t getHeight() const;
91 int32_t getFormat() const;
92 int32_t getWidthStride() const;
93 int32_t getHeightStride() const;
94 int32_t getBufferCount() const;
95 status_t getStatus() const;
96
97private:
98 virtual ~Overlay();
99
100 sp<OverlayRef> mOverlayRef;
101 overlay_data_device_t *mOverlayData;
102 status_t mStatus;
103};
104
105// ----------------------------------------------------------------------------
106
107}; // namespace android
108
109#endif // ANDROID_OVERLAY_H