The Android Open Source Project | edbf3b6 | 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 | |
| 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 Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IInterface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | #include <utils/RefBase.h> |
| 26 | #include <ui/PixelFormat.h> |
| 27 | |
| 28 | #include <hardware/hardware.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 29 | #include <hardware/gralloc.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | typedef int32_t SurfaceID; |
| 34 | |
| 35 | class IMemoryHeap; |
| 36 | class OverlayRef; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 37 | class SurfaceBuffer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | class ISurface : public IInterface |
| 40 | { |
| 41 | protected: |
| 42 | enum { |
| 43 | REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION, |
| 44 | UNREGISTER_BUFFERS, |
| 45 | POST_BUFFER, // one-way transaction |
| 46 | CREATE_OVERLAY, |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 47 | GET_BUFFER, |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | public: |
| 51 | DECLARE_META_INTERFACE(Surface); |
| 52 | |
Mathias Agopian | 5221271 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 53 | virtual sp<SurfaceBuffer> getBuffer(int usage) = 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | |
| 55 | class BufferHeap { |
| 56 | public: |
| 57 | enum { |
| 58 | /* rotate source image 90 degrees */ |
| 59 | ROT_90 = HAL_TRANSFORM_ROT_90, |
| 60 | }; |
| 61 | BufferHeap(); |
| 62 | |
| 63 | BufferHeap(uint32_t w, uint32_t h, |
| 64 | int32_t hor_stride, int32_t ver_stride, |
| 65 | PixelFormat format, const sp<IMemoryHeap>& heap); |
| 66 | |
| 67 | BufferHeap(uint32_t w, uint32_t h, |
| 68 | int32_t hor_stride, int32_t ver_stride, |
| 69 | PixelFormat format, uint32_t transform, uint32_t flags, |
| 70 | const sp<IMemoryHeap>& heap); |
| 71 | |
| 72 | ~BufferHeap(); |
| 73 | |
| 74 | uint32_t w; |
| 75 | uint32_t h; |
| 76 | int32_t hor_stride; |
| 77 | int32_t ver_stride; |
| 78 | PixelFormat format; |
| 79 | uint32_t transform; |
| 80 | uint32_t flags; |
| 81 | sp<IMemoryHeap> heap; |
| 82 | }; |
| 83 | |
| 84 | virtual status_t registerBuffers(const BufferHeap& buffers) = 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | virtual void postBuffer(ssize_t offset) = 0; // one-way |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | virtual void unregisterBuffers() = 0; |
| 87 | |
| 88 | virtual sp<OverlayRef> createOverlay( |
| 89 | uint32_t w, uint32_t h, int32_t format) = 0; |
| 90 | }; |
| 91 | |
| 92 | // ---------------------------------------------------------------------------- |
| 93 | |
| 94 | class BnSurface : public BnInterface<ISurface> |
| 95 | { |
| 96 | public: |
| 97 | virtual status_t onTransact( uint32_t code, |
| 98 | const Parcel& data, |
| 99 | Parcel* reply, |
| 100 | uint32_t flags = 0); |
| 101 | }; |
| 102 | |
| 103 | // ---------------------------------------------------------------------------- |
| 104 | |
| 105 | }; // namespace android |
| 106 | |
| 107 | #endif // ANDROID_ISURFACE_H |