blob: bf684060218a67d04bcdf8058be0399cd0f73cfd [file] [log] [blame]
Mathias Agopian81dd9e92009-05-05 18:11:11 -07001/*
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
Mathias Agopian376f5612009-05-05 18:21:32 -070025#include <private/ui/android_natives_priv.h>
Mathias Agopian81dd9e92009-05-05 18:11:11 -070026
27namespace android {
28
29// ---------------------------------------------------------------------------
30
31class BufferMapper;
Mathias Agopian79021f42009-06-09 21:38:08 -070032class Parcel;
Mathias Agopian81dd9e92009-05-05 18:11:11 -070033class Rect;
34class Surface;
35class SurfaceBuffer;
36
37// ---------------------------------------------------------------------------
38
39class SurfaceBuffer
40 : public EGLNativeBase<
41 android_native_buffer_t,
42 SurfaceBuffer,
43 LightRefBase<SurfaceBuffer> >
44{
45public:
46 status_t lock(uint32_t usage, void** vaddr);
47 status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
48 status_t unlock();
49
50protected:
51 SurfaceBuffer();
52 SurfaceBuffer(const Parcel& reply);
53 virtual ~SurfaceBuffer();
54 bool mOwner;
55
56 inline const BufferMapper& getBufferMapper() const { return mBufferMapper; }
57 inline BufferMapper& getBufferMapper() { return mBufferMapper; }
58
59private:
60 friend class Surface;
61 friend class BpSurface;
62 friend class BnSurface;
63 friend class LightRefBase<SurfaceBuffer>;
64
65 SurfaceBuffer& operator = (const SurfaceBuffer& rhs);
66 const SurfaceBuffer& operator = (const SurfaceBuffer& rhs) const;
67
68 static status_t writeToParcel(Parcel* reply,
69 android_native_buffer_t const* buffer);
70
71 BufferMapper& mBufferMapper;
72};
73
74}; // namespace android
75
76#endif // ANDROID_UI_PRIVATE_SURFACE_BUFFER_H
77