Mathias Agopian | 81dd9e9 | 2009-05-05 18:11:11 -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_UI_PRIVATE_SURFACE_BUFFER_H |
| 18 | #define ANDROID_UI_PRIVATE_SURFACE_BUFFER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <utils/RefBase.h> |
| 24 | |
| 25 | #include <ui/egl/android_natives.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | class BufferMapper; |
| 32 | class Rect; |
| 33 | class Surface; |
| 34 | class SurfaceBuffer; |
| 35 | |
| 36 | // --------------------------------------------------------------------------- |
| 37 | |
| 38 | class SurfaceBuffer |
| 39 | : public EGLNativeBase< |
| 40 | android_native_buffer_t, |
| 41 | SurfaceBuffer, |
| 42 | LightRefBase<SurfaceBuffer> > |
| 43 | { |
| 44 | public: |
| 45 | status_t lock(uint32_t usage, void** vaddr); |
| 46 | status_t lock(uint32_t usage, const Rect& rect, void** vaddr); |
| 47 | status_t unlock(); |
| 48 | |
| 49 | protected: |
| 50 | SurfaceBuffer(); |
| 51 | SurfaceBuffer(const Parcel& reply); |
| 52 | virtual ~SurfaceBuffer(); |
| 53 | bool mOwner; |
| 54 | |
| 55 | inline const BufferMapper& getBufferMapper() const { return mBufferMapper; } |
| 56 | inline BufferMapper& getBufferMapper() { return mBufferMapper; } |
| 57 | |
| 58 | private: |
| 59 | friend class Surface; |
| 60 | friend class BpSurface; |
| 61 | friend class BnSurface; |
| 62 | friend class LightRefBase<SurfaceBuffer>; |
| 63 | |
| 64 | SurfaceBuffer& operator = (const SurfaceBuffer& rhs); |
| 65 | const SurfaceBuffer& operator = (const SurfaceBuffer& rhs) const; |
| 66 | |
| 67 | static status_t writeToParcel(Parcel* reply, |
| 68 | android_native_buffer_t const* buffer); |
| 69 | |
| 70 | BufferMapper& mBufferMapper; |
| 71 | }; |
| 72 | |
| 73 | }; // namespace android |
| 74 | |
| 75 | #endif // ANDROID_UI_PRIVATE_SURFACE_BUFFER_H |
| 76 | |