blob: 452afdf8205e1dc2ef18dfd408fc6eee308ec5f1 [file] [log] [blame]
Chia-I Wu79d13ff2017-03-31 12:48:11 -07001/*
2 * Copyright 2016 The Android Open Source Project
3 * * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H
17#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H
18
19#include "GrallocMapper.h"
20
21#include <hardware/gralloc1.h>
22
23namespace android {
24namespace hardware {
25namespace graphics {
26namespace mapper {
27namespace V2_0 {
28namespace implementation {
29
30class Gralloc1Mapper : public GrallocMapper {
31 public:
32 Gralloc1Mapper(const hw_module_t* module);
33 ~Gralloc1Mapper();
34
35 private:
36 void initCapabilities();
37
38 template <typename T>
39 void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
40 void initDispatch();
41
42 static Error toError(int32_t error);
43 static bool toYCbCrLayout(const android_flex_layout& flex,
44 YCbCrLayout* outLayout);
45 static gralloc1_rect_t asGralloc1Rect(const IMapper::Rect& rect);
46
47 Error registerBuffer(buffer_handle_t bufferHandle) override;
48 void unregisterBuffer(buffer_handle_t bufferHandle) override;
49 Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
50 const IMapper::Rect& accessRegion, int fenceFd,
51 void** outData) override;
52 Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
53 const IMapper::Rect& accessRegion, int fenceFd,
54 YCbCrLayout* outLayout) override;
55 Error unlockBuffer(buffer_handle_t bufferHandle, int* outFenceFd) override;
56
57 gralloc1_device_t* mDevice;
58
59 struct {
60 GRALLOC1_PFN_RETAIN retain;
61 GRALLOC1_PFN_RELEASE release;
62 GRALLOC1_PFN_GET_NUM_FLEX_PLANES getNumFlexPlanes;
63 GRALLOC1_PFN_LOCK lock;
64 GRALLOC1_PFN_LOCK_FLEX lockFlex;
65 GRALLOC1_PFN_UNLOCK unlock;
66 } mDispatch;
67};
68
69} // namespace implementation
70} // namespace V2_0
71} // namespace mapper
72} // namespace graphics
73} // namespace hardware
74} // namespace android
75
76#endif // ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H