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_SF_ISURFACE_H 18 #define ANDROID_SF_ISURFACE_H 19 20 #include <stdint.h> 21 #include <sys/types.h> 22 23 #include <utils/Errors.h> 24 #include <utils/RefBase.h> 25 26 #include <binder/IInterface.h> 27 28 #include <ui/PixelFormat.h> 29 30 #include <hardware/hardware.h> 31 #include <hardware/gralloc.h> 32 33 namespace android { 34 35 typedef int32_t SurfaceID; 36 37 class IMemoryHeap; 38 class OverlayRef; 39 class GraphicBuffer; 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, 49 REQUEST_BUFFER, 50 }; 51 52 public: 53 DECLARE_META_INTERFACE(Surface); 54 55 virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, int usage) = 0; 56 57 class BufferHeap { 58 public: 59 enum { 60 /* rotate source image */ 61 ROT_0 = 0, 62 ROT_90 = HAL_TRANSFORM_ROT_90, 63 ROT_180 = HAL_TRANSFORM_ROT_180, 64 ROT_270 = HAL_TRANSFORM_ROT_270, 65 }; 66 BufferHeap(); 67 68 BufferHeap(uint32_t w, uint32_t h, 69 int32_t hor_stride, int32_t ver_stride, 70 PixelFormat format, const sp<IMemoryHeap>& heap); 71 72 BufferHeap(uint32_t w, uint32_t h, 73 int32_t hor_stride, int32_t ver_stride, 74 PixelFormat format, uint32_t transform, uint32_t flags, 75 const sp<IMemoryHeap>& heap); 76 77 ~BufferHeap(); 78 79 uint32_t w; 80 uint32_t h; 81 int32_t hor_stride; 82 int32_t ver_stride; 83 PixelFormat format; 84 uint32_t transform; 85 uint32_t flags; 86 sp<IMemoryHeap> heap; 87 }; 88 89 virtual status_t registerBuffers(const BufferHeap& buffers) = 0; 90 virtual void postBuffer(ssize_t offset) = 0; // one-way 91 virtual void unregisterBuffers() = 0; 92 93 virtual sp<OverlayRef> createOverlay( 94 uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0; 95 }; 96 97 // ---------------------------------------------------------------------------- 98 99 class BnSurface : public BnInterface<ISurface> 100 { 101 public: 102 virtual status_t onTransact( uint32_t code, 103 const Parcel& data, 104 Parcel* reply, 105 uint32_t flags = 0); 106 }; 107 108 // ---------------------------------------------------------------------------- 109 110 }; // namespace android 111 112 #endif // ANDROID_SF_ISURFACE_H 113