• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <ui/Gralloc1.h>
24 
25 #include <utils/Singleton.h>
26 
27 namespace android {
28 
29 // ---------------------------------------------------------------------------
30 
31 class Rect;
32 
33 class GraphicBufferMapper : public Singleton<GraphicBufferMapper>
34 {
35 public:
get()36     static inline GraphicBufferMapper& get() { return getInstance(); }
37 
38     status_t registerBuffer(buffer_handle_t handle);
39     status_t registerBuffer(const GraphicBuffer* buffer);
40 
41     status_t unregisterBuffer(buffer_handle_t handle);
42 
43     status_t lock(buffer_handle_t handle,
44             uint32_t usage, const Rect& bounds, void** vaddr);
45 
46     status_t lockYCbCr(buffer_handle_t handle,
47             uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
48 
49     status_t unlock(buffer_handle_t handle);
50 
51     status_t lockAsync(buffer_handle_t handle,
52             uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
53 
54     status_t lockAsyncYCbCr(buffer_handle_t handle,
55             uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
56             int fenceFd);
57 
58     status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
59 
60 private:
61     friend class Singleton<GraphicBufferMapper>;
62 
63     GraphicBufferMapper();
64 
65     std::unique_ptr<Gralloc1::Loader> mLoader;
66     std::unique_ptr<Gralloc1::Device> mDevice;
67 };
68 
69 // ---------------------------------------------------------------------------
70 
71 }; // namespace android
72 
73 #endif // ANDROID_UI_BUFFER_MAPPER_H
74 
75