blob: 8a33b2eab9a57745faa458efbf64b5327439e62d [file] [log] [blame]
Mathias Agopian076b1cc2009-04-10 14:24:30 -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_BUFFER_MAPPER_H
18#define ANDROID_UI_BUFFER_MAPPER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <utils/threads.h>
23#include <utils/Singleton.h>
24
25#include <hardware/gralloc.h>
26
27
28struct gralloc_module_t;
29
30namespace android {
31
32// ---------------------------------------------------------------------------
33
34class Rect;
35
36class BufferMapper : public Singleton<BufferMapper>
37{
38public:
39 static inline BufferMapper& get() { return getInstance(); }
40 status_t map(buffer_handle_t handle, void** addr);
41 status_t unmap(buffer_handle_t handle);
42 status_t lock(buffer_handle_t handle, int usage, const Rect& bounds);
43 status_t unlock(buffer_handle_t handle);
44
45private:
46 friend class Singleton<BufferMapper>;
47 BufferMapper();
48 mutable Mutex mLock;
49 gralloc_module_t const *mAllocMod;
50};
51
52// ---------------------------------------------------------------------------
53
54}; // namespace android
55
56#endif // ANDROID_UI_BUFFER_MAPPER_H
57