blob: 1a788720dbcd4fe47901edc9986f293ec1766031 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-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_ISURFACE_H
18#define ANDROID_ISURFACE_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopian076b1cc2009-04-10 14:24:30 -070023#include <EGL/android_natives.h>
24
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025#include <utils/Errors.h>
26#include <utils/IInterface.h>
27#include <utils/RefBase.h>
28#include <ui/PixelFormat.h>
29
30#include <hardware/hardware.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070031#include <hardware/gralloc.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
33namespace android {
34
35typedef int32_t SurfaceID;
36
37class IMemoryHeap;
38class OverlayRef;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070039class SurfaceBuffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040
41class ISurface : public IInterface
42{
43protected:
44 enum {
45 REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
46 UNREGISTER_BUFFERS,
47 POST_BUFFER, // one-way transaction
48 CREATE_OVERLAY,
Mathias Agopian076b1cc2009-04-10 14:24:30 -070049 GET_BUFFER,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080050 };
51
52public:
53 DECLARE_META_INTERFACE(Surface);
54
Mathias Agopian076b1cc2009-04-10 14:24:30 -070055 virtual sp<SurfaceBuffer> getBuffer() = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080056
57 class BufferHeap {
58 public:
59 enum {
60 /* rotate source image 90 degrees */
61 ROT_90 = HAL_TRANSFORM_ROT_90,
62 };
63 BufferHeap();
64
65 BufferHeap(uint32_t w, uint32_t h,
66 int32_t hor_stride, int32_t ver_stride,
67 PixelFormat format, const sp<IMemoryHeap>& heap);
68
69 BufferHeap(uint32_t w, uint32_t h,
70 int32_t hor_stride, int32_t ver_stride,
71 PixelFormat format, uint32_t transform, uint32_t flags,
72 const sp<IMemoryHeap>& heap);
73
74 ~BufferHeap();
75
76 uint32_t w;
77 uint32_t h;
78 int32_t hor_stride;
79 int32_t ver_stride;
80 PixelFormat format;
81 uint32_t transform;
82 uint32_t flags;
83 sp<IMemoryHeap> heap;
84 };
85
86 virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080087 virtual void postBuffer(ssize_t offset) = 0; // one-way
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080088 virtual void unregisterBuffers() = 0;
89
90 virtual sp<OverlayRef> createOverlay(
91 uint32_t w, uint32_t h, int32_t format) = 0;
92};
93
94// ----------------------------------------------------------------------------
95
96class BnSurface : public BnInterface<ISurface>
97{
98public:
99 virtual status_t onTransact( uint32_t code,
100 const Parcel& data,
101 Parcel* reply,
102 uint32_t flags = 0);
103};
104
105// ----------------------------------------------------------------------------
106
107}; // namespace android
108
109#endif // ANDROID_ISURFACE_H