GraphicBufferMapper.h revision 8f3960179c56767e5077be8337792bd4e244b7d7
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_BUFFER_MAPPER_H
18#define ANDROID_UI_BUFFER_MAPPER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
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 GraphicBufferMapper : public Singleton<GraphicBufferMapper>
37{
38public:
39    static inline GraphicBufferMapper& get() { return getInstance(); }
40
41    status_t registerBuffer(buffer_handle_t handle);
42
43    status_t unregisterBuffer(buffer_handle_t handle);
44
45    status_t lock(buffer_handle_t handle,
46            int usage, const Rect& bounds, void** vaddr);
47
48    status_t lockYCbCr(buffer_handle_t handle,
49            int usage, const Rect& bounds, android_ycbcr *ycbcr);
50
51    status_t unlock(buffer_handle_t handle);
52
53    status_t lockAsync(buffer_handle_t handle,
54            int usage, const Rect& bounds, void** vaddr, int fenceFd);
55
56    status_t lockAsyncYCbCr(buffer_handle_t handle,
57            int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd);
58
59    status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
60
61    // dumps information about the mapping of this handle
62    void dump(buffer_handle_t handle);
63
64private:
65    friend class Singleton<GraphicBufferMapper>;
66    GraphicBufferMapper();
67    gralloc_module_t const *mAllocMod;
68};
69
70// ---------------------------------------------------------------------------
71
72}; // namespace android
73
74#endif // ANDROID_UI_BUFFER_MAPPER_H
75
76