The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [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> |
| 24 | #include <utils/IInterface.h> |
| 25 | #include <utils/RefBase.h> |
| 26 | #include <ui/PixelFormat.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | typedef int32_t SurfaceID; |
| 31 | |
| 32 | class IMemoryHeap; |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 33 | class OverlayRef; |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | |
| 35 | class ISurface : public IInterface |
| 36 | { |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 37 | protected: |
| 38 | enum { |
| 39 | REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION, |
| 40 | UNREGISTER_BUFFERS, |
| 41 | POST_BUFFER, // one-way transaction |
| 42 | CREATE_OVERLAY, |
| 43 | }; |
| 44 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 45 | public: |
| 46 | DECLARE_META_INTERFACE(Surface); |
| 47 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 48 | |
| 49 | class BufferHeap { |
| 50 | public: |
| 51 | enum { |
| 52 | /* flip source image horizontally */ |
| 53 | FLIP_H = 0x01, |
| 54 | /* flip source image vertically */ |
| 55 | FLIP_V = 0x02, |
| 56 | /* rotate source image 90 degrees */ |
| 57 | ROT_90 = 0x04, |
| 58 | /* rotate source image 180 degrees */ |
| 59 | ROT_180 = 0x03, |
| 60 | /* rotate source image 270 degrees */ |
| 61 | ROT_270 = 0x07, |
| 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 Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 87 | |
| 88 | virtual void postBuffer(ssize_t offset) = 0; // one-way |
| 89 | |
| 90 | virtual void unregisterBuffers() = 0; |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 91 | |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 92 | virtual sp<OverlayRef> createOverlay( |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 93 | uint32_t w, uint32_t h, int32_t format) = 0; |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | // ---------------------------------------------------------------------------- |
| 97 | |
| 98 | class BnSurface : public BnInterface<ISurface> |
| 99 | { |
| 100 | public: |
| 101 | virtual status_t onTransact( uint32_t code, |
| 102 | const Parcel& data, |
| 103 | Parcel* reply, |
| 104 | uint32_t flags = 0); |
| 105 | }; |
| 106 | |
| 107 | // ---------------------------------------------------------------------------- |
| 108 | |
| 109 | }; // namespace android |
| 110 | |
| 111 | #endif // ANDROID_ISURFACE_H |