blob: f24780f3aa14c8ddb8ebf497eaefe97329730524 [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>
26#include <ui/PixelFormat.h>
27
28#include <hardware/overlay.h>
29
30namespace android {
31
32class IOverlay;
33class IMemory;
34class IMemoryHeap;
35
36class Overlay : public virtual RefBase
37{
38public:
39 Overlay(overlay_t* overlay,
40 const sp<IOverlay>& o, const sp<IMemoryHeap>& heap);
41
42 /* destroys this overlay */
43 void destroy();
44
45 /* post/swaps buffers */
46 status_t swapBuffers();
47
48 /* get the HAL handle for this overlay */
49 overlay_handle_t const* getHandleRef() const;
50
51 /* returns the offset of the current buffer */
52 size_t getBufferOffset() const;
53
54 /* returns a heap to this overlay. this may not be supported. */
55 sp<IMemoryHeap> getHeap() const;
56
57 /* get physical informations about the overlay */
58 uint32_t getWidth() const;
59 uint32_t getHeight() const;
60 int32_t getFormat() const;
61 int32_t getWidthStride() const;
62 int32_t getHeightStride() const;
63
64 static sp<Overlay> readFromParcel(const Parcel& data);
65 static status_t writeToParcel(Parcel* reply, const sp<Overlay>& o);
66
67private:
68 Overlay(overlay_handle_t*, const sp<IOverlay>&, const sp<IMemoryHeap>&,
69 uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs);
70
71 virtual ~Overlay();
72
73 sp<IOverlay> mOverlay;
74 sp<IMemoryHeap> mHeap;
75 size_t mCurrentBufferOffset;
76 overlay_handle_t const *mOverlayHandle;
77 uint32_t mWidth;
78 uint32_t mHeight;
79 int32_t mFormat;
80 int32_t mWidthStride;
81 int32_t mHeightStride;
82};
83
84// ----------------------------------------------------------------------------
85
86}; // namespace android
87
88#endif // ANDROID_OVERLAY_H