blob: c7f181c7e56c4eaa8ec1ebb97728d5ee25a0a2aa [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_ISURFACE_H
18#define ANDROID_ISURFACE_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 <ui/PixelFormat.h>
27
28#include <hardware/hardware.h>
Mathias Agopian1473f462009-04-10 14:24:30 -070029#include <hardware/gralloc.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030
31namespace android {
32
33typedef int32_t SurfaceID;
34
35class IMemoryHeap;
36class OverlayRef;
Mathias Agopian6950e422009-10-05 17:07:12 -070037class GraphicBuffer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038
39class ISurface : public IInterface
40{
41protected:
42 enum {
43 REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
44 UNREGISTER_BUFFERS,
45 POST_BUFFER, // one-way transaction
46 CREATE_OVERLAY,
Mathias Agopian9779b2212009-09-07 16:32:45 -070047 REQUEST_BUFFER,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048 };
49
50public:
51 DECLARE_META_INTERFACE(Surface);
52
Mathias Agopian6950e422009-10-05 17:07:12 -070053 virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, int usage) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054
55 class BufferHeap {
56 public:
57 enum {
Chih-Chung Changac127dc2010-01-22 16:30:39 -080058 /* rotate source image */
59 ROT_0 = 0,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 ROT_90 = HAL_TRANSFORM_ROT_90,
Chih-Chung Changac127dc2010-01-22 16:30:39 -080061 ROT_180 = HAL_TRANSFORM_ROT_180,
62 ROT_270 = HAL_TRANSFORM_ROT_270,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 };
64 BufferHeap();
65
66 BufferHeap(uint32_t w, uint32_t h,
67 int32_t hor_stride, int32_t ver_stride,
68 PixelFormat format, const sp<IMemoryHeap>& heap);
69
70 BufferHeap(uint32_t w, uint32_t h,
71 int32_t hor_stride, int32_t ver_stride,
72 PixelFormat format, uint32_t transform, uint32_t flags,
73 const sp<IMemoryHeap>& heap);
74
75 ~BufferHeap();
76
77 uint32_t w;
78 uint32_t h;
79 int32_t hor_stride;
80 int32_t ver_stride;
81 PixelFormat format;
82 uint32_t transform;
83 uint32_t flags;
84 sp<IMemoryHeap> heap;
85 };
86
87 virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 virtual void postBuffer(ssize_t offset) = 0; // one-way
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 virtual void unregisterBuffers() = 0;
90
91 virtual sp<OverlayRef> createOverlay(
Chih-Chung Change1ceec22010-01-21 17:31:06 -080092 uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093};
94
95// ----------------------------------------------------------------------------
96
97class BnSurface : public BnInterface<ISurface>
98{
99public:
100 virtual status_t onTransact( uint32_t code,
101 const Parcel& data,
102 Parcel* reply,
103 uint32_t flags = 0);
104};
105
106// ----------------------------------------------------------------------------
107
108}; // namespace android
109
110#endif // ANDROID_ISURFACE_H