OSDN Git Service

Track GemHandles and FB separately.
[android-x86/external-IA-Hardware-Composer.git] / os / android / gralloc1bufferhandler.h
1 /*
2  * Copyright (C) 2016 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 OS_ANDROID_Gralloc1BufferHandler_H_
18 #define OS_ANDROID_Gralloc1BufferHandler_H_
19
20 #include <nativebufferhandler.h>
21
22 #include <hardware/gralloc1.h>
23
24 #include <i915_private_android_types.h>
25
26 namespace hwcomposer {
27
28 class GpuDevice;
29
30 class Gralloc1BufferHandler : public NativeBufferHandler {
31  public:
32   explicit Gralloc1BufferHandler(uint32_t fd);
33   ~Gralloc1BufferHandler() override;
34
35   bool Init();
36
37   bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle,
38                     uint32_t layer_type) const override;
39   bool ReleaseBuffer(HWCNativeHandle handle) const override;
40   void DestroyHandle(HWCNativeHandle handle) const override;
41   bool ImportBuffer(HWCNativeHandle handle) const override;
42   void CopyHandle(HWCNativeHandle source,
43                   HWCNativeHandle *target) const override;
44   uint32_t GetTotalPlanes(HWCNativeHandle handle) const override;
45   void *Map(HWCNativeHandle handle, uint32_t x, uint32_t y, uint32_t width,
46             uint32_t height, uint32_t *stride, void **map_data,
47             size_t plane) const override;
48   int32_t UnMap(HWCNativeHandle handle, void *map_data) const override;
49
50   uint32_t GetFd() const override {
51     return fd_;
52   }
53
54  private:
55   uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
56   uint32_t fd_;
57   const hw_module_t *gralloc_;
58   hw_device_t *device_;
59   GRALLOC1_PFN_RETAIN register_;
60   GRALLOC1_PFN_RELEASE release_;
61   GRALLOC1_PFN_GET_DIMENSIONS dimensions_;
62   GRALLOC1_PFN_LOCK lock_;
63   GRALLOC1_PFN_UNLOCK unlock_;
64   GRALLOC1_PFN_CREATE_DESCRIPTOR create_descriptor_;
65   GRALLOC1_PFN_DESTROY_DESCRIPTOR destroy_descriptor_;
66   GRALLOC1_PFN_SET_CONSUMER_USAGE set_consumer_usage_;
67   GRALLOC1_PFN_SET_DIMENSIONS set_dimensions_;
68   GRALLOC1_PFN_SET_FORMAT set_format_;
69   GRALLOC1_PFN_SET_PRODUCER_USAGE set_producer_usage_;
70   GRALLOC1_PFN_ALLOCATE allocate_;
71 };
72
73 }  // namespace hwcomposer
74 #endif  // OS_ANDROID_Gralloc1BufferHandler_H_