blob: 6099548aafd71c057da705cc78b698b30e5c7327 [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>
Mathias Agopian8b765b72009-04-10 20:34:46 -070022
Mathias Agopian076b1cc2009-04-10 14:24:30 -070023#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
Mathias Agopian3330b202009-10-05 17:07:12 -070036class GraphicBufferMapper : public Singleton<GraphicBufferMapper>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070037{
38public:
Mathias Agopian3330b202009-10-05 17:07:12 -070039 static inline GraphicBufferMapper& get() { return getInstance(); }
Mathias Agopian0926f502009-05-04 14:17:04 -070040
41 status_t registerBuffer(buffer_handle_t handle);
42
43 status_t unregisterBuffer(buffer_handle_t handle);
Dan Stoza303b9a52014-11-17 12:03:59 -080044
Mathias Agopian0926f502009-05-04 14:17:04 -070045 status_t lock(buffer_handle_t handle,
Dan Stoza303b9a52014-11-17 12:03:59 -080046 uint32_t usage, const Rect& bounds, void** vaddr);
Mathias Agopian0926f502009-05-04 14:17:04 -070047
Eino-Ville Talvalac43946b2013-05-04 18:07:43 -070048 status_t lockYCbCr(buffer_handle_t handle,
Dan Stoza303b9a52014-11-17 12:03:59 -080049 uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
Eino-Ville Talvalac43946b2013-05-04 18:07:43 -070050
Mathias Agopian076b1cc2009-04-10 14:24:30 -070051 status_t unlock(buffer_handle_t handle);
Francis Hart8f396012014-04-01 15:30:53 +030052
53 status_t lockAsync(buffer_handle_t handle,
Dan Stoza303b9a52014-11-17 12:03:59 -080054 uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
Francis Hart8f396012014-04-01 15:30:53 +030055
56 status_t lockAsyncYCbCr(buffer_handle_t handle,
Dan Stoza303b9a52014-11-17 12:03:59 -080057 uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
58 int fenceFd);
Francis Hart8f396012014-04-01 15:30:53 +030059
60 status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
Dan Stoza303b9a52014-11-17 12:03:59 -080061
Mathias Agopian8b765b72009-04-10 20:34:46 -070062 // dumps information about the mapping of this handle
63 void dump(buffer_handle_t handle);
64
Mathias Agopian076b1cc2009-04-10 14:24:30 -070065private:
Mathias Agopian3330b202009-10-05 17:07:12 -070066 friend class Singleton<GraphicBufferMapper>;
67 GraphicBufferMapper();
Mathias Agopian076b1cc2009-04-10 14:24:30 -070068 gralloc_module_t const *mAllocMod;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070069};
70
71// ---------------------------------------------------------------------------
72
73}; // namespace android
74
75#endif // ANDROID_UI_BUFFER_MAPPER_H
76