blob: 5a0d64ba8d47b3f6ef7014f4bf407e40afac3de9 [file] [log] [blame]
Chia-I Wu9ba189d2016-09-22 17:13:08 +08001/*
2 * Copyright 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 ANDROID_UI_GRALLOC_MAPPER_H
18#define ANDROID_UI_GRALLOC_MAPPER_H
19
Chia-I Wu9ba189d2016-09-22 17:13:08 +080020#include <android/hardware/graphics/mapper/2.0/IMapper.h>
21#include <system/window.h>
22
23namespace android {
24
25namespace Gralloc2 {
26
27using hardware::graphics::allocator::V2_0::Error;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080028using hardware::graphics::allocator::V2_0::ProducerUsage;
29using hardware::graphics::allocator::V2_0::ConsumerUsage;
Chia-I Wu5901fda2016-11-17 10:26:37 +080030using hardware::graphics::common::V1_0::PixelFormat;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080031using hardware::graphics::mapper::V2_0::FlexLayout;
32using hardware::graphics::mapper::V2_0::BackingStore;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080033using hardware::graphics::mapper::V2_0::IMapper;
34
35// Mapper is a wrapper to IMapper, a client-side graphics buffer mapper.
36class Mapper {
37public:
38 Mapper();
Chia-I Wu9ba189d2016-09-22 17:13:08 +080039
40 // this will be removed and Mapper will be always valid
41 bool valid() const { return (mMapper != nullptr); }
42
Chia-I Wu31669472016-12-07 14:55:24 +080043 Error retain(buffer_handle_t handle) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080044 void release(buffer_handle_t handle) const;
45
Craig Donner58a1ef22017-02-02 12:40:05 -080046 Error getDimensions(buffer_handle_t handle,
47 uint32_t* outWidth, uint32_t* outHeight) const;
48 Error getFormat(buffer_handle_t handle, int32_t* outFormat) const;
49 Error getLayerCount(buffer_handle_t handle, uint32_t* outLayerCount) const;
50 Error getProducerUsage(buffer_handle_t handle,
51 uint64_t* outProducerUsage) const;
52 Error getConsumerUsage(buffer_handle_t handle,
53 uint64_t* outConsumerUsage) const;
54 Error getBackingStore(buffer_handle_t handle,
55 uint64_t* outBackingStore) const;
Chia-I Wu31669472016-12-07 14:55:24 +080056 Error getStride(buffer_handle_t handle, uint32_t* outStride) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080057
Craig Donner58a1ef22017-02-02 12:40:05 -080058 Error lock(buffer_handle_t handle, uint64_t producerUsage,
59 uint64_t consumerUsage, const IMapper::Rect& accessRegion,
Chia-I Wu31669472016-12-07 14:55:24 +080060 int acquireFence, void** outData) const;
Craig Donner58a1ef22017-02-02 12:40:05 -080061 Error lock(buffer_handle_t handle, uint64_t producerUsage,
62 uint64_t consumerUsage, const IMapper::Rect& accessRegion,
Chia-I Wu31669472016-12-07 14:55:24 +080063 int acquireFence, FlexLayout* outLayout) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080064 int unlock(buffer_handle_t handle) const;
65
66private:
Chia-I Wu31669472016-12-07 14:55:24 +080067 sp<IMapper> mMapper;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080068};
69
70} // namespace Gralloc2
71
72} // namespace android
73
74#endif // ANDROID_UI_GRALLOC_MAPPER_H