• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #include <android/hardware/graphics/allocator/4.0/IAllocator.h>
8 #include <android/hardware/graphics/mapper/4.0/IMapper.h>
9 
10 #include "cros_gralloc/cros_gralloc_driver.h"
11 #include "cros_gralloc/cros_gralloc_helpers.h"
12 #include "cros_gralloc/gralloc4/CrosGralloc4Metadata.h"
13 
14 class CrosGralloc4Allocator : public android::hardware::graphics::allocator::V4_0::IAllocator {
15   public:
16     CrosGralloc4Allocator() = default;
17 
18     android::hardware::Return<void> allocate(const android::hardware::hidl_vec<uint8_t>& descriptor,
19                                              uint32_t count, allocate_cb hidl_cb) override;
20 
21     android::hardware::graphics::mapper::V4_0::Error init();
22 
23   private:
24     android::hardware::graphics::mapper::V4_0::Error initializeMetadata(
25             cros_gralloc_handle_t crosHandle,
26             const struct cros_gralloc_buffer_descriptor& crosDescriptor);
27 
28     android::hardware::graphics::mapper::V4_0::Error allocate(
29             const android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo&
30                     description,
31             uint32_t* outStride, android::hardware::hidl_handle* outHandle);
32 
33     cros_gralloc_driver* mDriver = nullptr;
34 };
35