blob: 18e7950bc39b54b58e5095990f3ada3952e57d12 [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
Mathias Agopian9cce3252010-02-09 17:46:37 -080017#ifndef ANDROID_SF_ISURFACE_H
18#define ANDROID_SF_ISURFACE_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024#include <utils/RefBase.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080025
26#include <binder/IInterface.h>
27
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028#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 Agopian3330b202009-10-05 17:07:12 -070039class GraphicBuffer;
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 Agopiancbb288b2009-09-07 16:32:45 -070049 REQUEST_BUFFER,
Mathias Agopianb5b7f262010-05-07 15:58:44 -070050 SET_BUFFER_COUNT,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051 };
52
53public:
54 DECLARE_META_INTERFACE(Surface);
55
Mathias Agopiana138f892010-05-21 17:24:35 -070056 virtual sp<GraphicBuffer> requestBuffer(int bufferIdx,
57 uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
Mathias Agopianb5b7f262010-05-07 15:58:44 -070058 virtual status_t setBufferCount(int bufferCount) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059
60 class BufferHeap {
61 public:
62 enum {
Chih-Chung Chang5994a332010-01-22 16:30:39 -080063 /* rotate source image */
64 ROT_0 = 0,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 ROT_90 = HAL_TRANSFORM_ROT_90,
Chih-Chung Chang5994a332010-01-22 16:30:39 -080066 ROT_180 = HAL_TRANSFORM_ROT_180,
67 ROT_270 = HAL_TRANSFORM_ROT_270,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080068 };
69 BufferHeap();
70
71 BufferHeap(uint32_t w, uint32_t h,
72 int32_t hor_stride, int32_t ver_stride,
73 PixelFormat format, const sp<IMemoryHeap>& heap);
74
75 BufferHeap(uint32_t w, uint32_t h,
76 int32_t hor_stride, int32_t ver_stride,
77 PixelFormat format, uint32_t transform, uint32_t flags,
78 const sp<IMemoryHeap>& heap);
79
80 ~BufferHeap();
81
82 uint32_t w;
83 uint32_t h;
84 int32_t hor_stride;
85 int32_t ver_stride;
86 PixelFormat format;
87 uint32_t transform;
88 uint32_t flags;
89 sp<IMemoryHeap> heap;
90 };
91
92 virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080093 virtual void postBuffer(ssize_t offset) = 0; // one-way
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080094 virtual void unregisterBuffers() = 0;
95
96 virtual sp<OverlayRef> createOverlay(
Chih-Chung Chang52e72002010-01-21 17:31:06 -080097 uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080098};
99
100// ----------------------------------------------------------------------------
101
102class BnSurface : public BnInterface<ISurface>
103{
104public:
105 virtual status_t onTransact( uint32_t code,
106 const Parcel& data,
107 Parcel* reply,
108 uint32_t flags = 0);
109};
110
111// ----------------------------------------------------------------------------
112
113}; // namespace android
114
Mathias Agopian9cce3252010-02-09 17:46:37 -0800115#endif // ANDROID_SF_ISURFACE_H