blob: 73e517b5275ac8783ecae442a7582e5987e417c3 [file] [log] [blame]
Mathias Agopian7189c002009-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 Agopian58a79f42009-05-05 18:21:32 -070025#include <private/ui/android_natives_priv.h>
Mathias Agopian7189c002009-05-05 18:11:11 -070026
27namespace android {
28
29// ---------------------------------------------------------------------------
30
31class BufferMapper;
Mathias Agopian7e2a9372009-06-09 21:38:08 -070032class Parcel;
Mathias Agopian7189c002009-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
Mathias Agopiancbb288b2009-09-07 16:32:45 -070050 void setIndex(int index);
51 int getIndex() const;
52
Mathias Agopian7189c002009-05-05 18:11:11 -070053protected:
54 SurfaceBuffer();
55 SurfaceBuffer(const Parcel& reply);
56 virtual ~SurfaceBuffer();
57 bool mOwner;
58
59 inline const BufferMapper& getBufferMapper() const { return mBufferMapper; }
60 inline BufferMapper& getBufferMapper() { return mBufferMapper; }
61
62private:
63 friend class Surface;
64 friend class BpSurface;
65 friend class BnSurface;
66 friend class LightRefBase<SurfaceBuffer>;
67
68 SurfaceBuffer& operator = (const SurfaceBuffer& rhs);
69 const SurfaceBuffer& operator = (const SurfaceBuffer& rhs) const;
70
71 static status_t writeToParcel(Parcel* reply,
72 android_native_buffer_t const* buffer);
73
74 BufferMapper& mBufferMapper;
Mathias Agopiancbb288b2009-09-07 16:32:45 -070075 int mIndex;
Mathias Agopian7189c002009-05-05 18:11:11 -070076};
77
78}; // namespace android
79
80#endif // ANDROID_UI_PRIVATE_SURFACE_BUFFER_H
81