blob: f8454fd73a078246cb801138a1d2171f16e7694d [file] [log] [blame]
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -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>
24#include <utils/IInterface.h>
25#include <utils/RefBase.h>
The Android Open Source Project27629322009-01-09 17:51:23 -080026#include <utils/threads.h>
27
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080028#include <ui/PixelFormat.h>
The Android Open Source Project27629322009-01-09 17:51:23 -080029#include <ui/IOverlay.h>
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080030
31#include <hardware/overlay.h>
32
33namespace android {
34
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080035class IMemory;
36class IMemoryHeap;
37
The Android Open Source Project27629322009-01-09 17:51:23 -080038// ----------------------------------------------------------------------------
39
40class OverlayRef : public LightRefBase<OverlayRef>
41{
42public:
The Android Open Source Project5f78a482009-01-20 14:03:58 -080043 OverlayRef(overlay_handle_t, const sp<IOverlay>&,
The Android Open Source Project27629322009-01-09 17:51:23 -080044 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
The Android Open Source Project5f78a482009-01-20 14:03:58 -080056 overlay_handle_t mOverlayHandle;
The Android Open Source Project8a7a6752009-01-15 16:12:10 -080057 sp<IOverlay> mOverlayChannel;
The Android Open Source Project27629322009-01-09 17:51:23 -080058 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
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080068class Overlay : public virtual RefBase
69{
70public:
The Android Open Source Project27629322009-01-09 17:51:23 -080071 Overlay(const sp<OverlayRef>& overlayRef);
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080072
73 /* destroys this overlay */
74 void destroy();
75
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080076 /* get the HAL handle for this overlay */
The Android Open Source Project5f78a482009-01-20 14:03:58 -080077 overlay_handle_t getHandleRef() const;
The Android Open Source Project27629322009-01-09 17:51:23 -080078
79 /* blocks until an overlay buffer is available and return that buffer. */
The Android Open Source Project8a7a6752009-01-15 16:12:10 -080080 status_t dequeueBuffer(overlay_buffer_t* buffer);
The Android Open Source Project27629322009-01-09 17:51:23 -080081
82 /* release the overlay buffer and post it */
The Android Open Source Project8a7a6752009-01-15 16:12:10 -080083 status_t queueBuffer(overlay_buffer_t buffer);
The Android Open Source Project27629322009-01-09 17:51:23 -080084
85 /* returns the address of a given buffer if supported, NULL otherwise. */
86 void* getBufferAddress(overlay_buffer_t buffer);
87
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080088 /* 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;
The Android Open Source Project27629322009-01-09 17:51:23 -080094 status_t getStatus() const;
95
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080096private:
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080097 virtual ~Overlay();
98
The Android Open Source Project27629322009-01-09 17:51:23 -080099 sp<OverlayRef> mOverlayRef;
100 overlay_data_device_t *mOverlayData;
101 status_t mStatus;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800102};
103
104// ----------------------------------------------------------------------------
105
106}; // namespace android
107
108#endif // ANDROID_OVERLAY_H