The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_SF_ISURFACE_H |
| 18 | #define ANDROID_SF_ISURFACE_H |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <utils/Errors.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | #include <utils/RefBase.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 25 | |
| 26 | #include <binder/IInterface.h> |
| 27 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | #include <ui/PixelFormat.h> |
| 29 | |
| 30 | #include <hardware/hardware.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 31 | #include <hardware/gralloc.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
| 33 | namespace android { |
| 34 | |
| 35 | typedef int32_t SurfaceID; |
| 36 | |
| 37 | class IMemoryHeap; |
| 38 | class OverlayRef; |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 39 | class GraphicBuffer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | |
| 41 | class ISurface : public IInterface |
| 42 | { |
| 43 | protected: |
| 44 | enum { |
| 45 | REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION, |
| 46 | UNREGISTER_BUFFERS, |
| 47 | POST_BUFFER, // one-way transaction |
| 48 | CREATE_OVERLAY, |
Mathias Agopian | 9779b22 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 49 | REQUEST_BUFFER, |
Mathias Agopian | 59751db | 2010-05-07 15:58:44 -0700 | [diff] [blame^] | 50 | SET_BUFFER_COUNT, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | public: |
| 54 | DECLARE_META_INTERFACE(Surface); |
| 55 | |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 56 | virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, int usage) = 0; |
Mathias Agopian | 59751db | 2010-05-07 15:58:44 -0700 | [diff] [blame^] | 57 | virtual status_t setBufferCount(int bufferCount) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | |
| 59 | class BufferHeap { |
| 60 | public: |
| 61 | enum { |
Chih-Chung Chang | ac127dc | 2010-01-22 16:30:39 -0800 | [diff] [blame] | 62 | /* rotate source image */ |
| 63 | ROT_0 = 0, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | ROT_90 = HAL_TRANSFORM_ROT_90, |
Chih-Chung Chang | ac127dc | 2010-01-22 16:30:39 -0800 | [diff] [blame] | 65 | ROT_180 = HAL_TRANSFORM_ROT_180, |
| 66 | ROT_270 = HAL_TRANSFORM_ROT_270, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | }; |
| 68 | BufferHeap(); |
| 69 | |
| 70 | BufferHeap(uint32_t w, uint32_t h, |
| 71 | int32_t hor_stride, int32_t ver_stride, |
| 72 | PixelFormat format, const sp<IMemoryHeap>& heap); |
| 73 | |
| 74 | BufferHeap(uint32_t w, uint32_t h, |
| 75 | int32_t hor_stride, int32_t ver_stride, |
| 76 | PixelFormat format, uint32_t transform, uint32_t flags, |
| 77 | const sp<IMemoryHeap>& heap); |
| 78 | |
| 79 | ~BufferHeap(); |
| 80 | |
| 81 | uint32_t w; |
| 82 | uint32_t h; |
| 83 | int32_t hor_stride; |
| 84 | int32_t ver_stride; |
| 85 | PixelFormat format; |
| 86 | uint32_t transform; |
| 87 | uint32_t flags; |
| 88 | sp<IMemoryHeap> heap; |
| 89 | }; |
| 90 | |
| 91 | virtual status_t registerBuffers(const BufferHeap& buffers) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | virtual void postBuffer(ssize_t offset) = 0; // one-way |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | virtual void unregisterBuffers() = 0; |
| 94 | |
| 95 | virtual sp<OverlayRef> createOverlay( |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 96 | uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | // ---------------------------------------------------------------------------- |
| 100 | |
| 101 | class BnSurface : public BnInterface<ISurface> |
| 102 | { |
| 103 | public: |
| 104 | virtual status_t onTransact( uint32_t code, |
| 105 | const Parcel& data, |
| 106 | Parcel* reply, |
| 107 | uint32_t flags = 0); |
| 108 | }; |
| 109 | |
| 110 | // ---------------------------------------------------------------------------- |
| 111 | |
| 112 | }; // namespace android |
| 113 | |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 114 | #endif // ANDROID_SF_ISURFACE_H |