1 /* 2 * Copyright (C) 2015 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_DRM_HWCOMPOSER_H_ 18 #define ANDROID_DRM_HWCOMPOSER_H_ 19 20 #include <hardware/hardware.h> 21 #include <hardware/hwcomposer.h> 22 23 #include <cstdbool> 24 #include <cstdint> 25 #include <vector> 26 27 #include "drm/DrmFbImporter.h" 28 #include "drmhwcgralloc.h" 29 #include "utils/UniqueFd.h" 30 31 namespace android { 32 33 class DrmFbIdHandle; 34 35 enum class DrmHwcColorSpace : int32_t { 36 kUndefined, 37 kItuRec601, 38 kItuRec709, 39 kItuRec2020, 40 }; 41 42 enum class DrmHwcSampleRange : int32_t { 43 kUndefined, 44 kFullRange, 45 kLimitedRange, 46 }; 47 48 enum DrmHwcTransform : uint32_t { 49 kIdentity = 0, 50 kFlipH = 1 << 0, 51 kFlipV = 1 << 1, 52 kRotate90 = 1 << 2, 53 kRotate180 = 1 << 3, 54 kRotate270 = 1 << 4, 55 }; 56 57 enum class DrmHwcBlending : int32_t { 58 kNone, 59 kPreMult, 60 kCoverage, 61 }; 62 63 struct DrmHwcLayer { 64 buffer_handle_t sf_handle = nullptr; 65 hwc_drm_bo_t buffer_info{}; 66 std::shared_ptr<DrmFbIdHandle> fb_id_handle; 67 68 int gralloc_buffer_usage = 0; 69 DrmHwcTransform transform{}; 70 DrmHwcBlending blending = DrmHwcBlending::kNone; 71 uint16_t alpha = UINT16_MAX; 72 hwc_frect_t source_crop; 73 hwc_rect_t display_frame; 74 DrmHwcColorSpace color_space; 75 DrmHwcSampleRange sample_range; 76 77 UniqueFd acquire_fence; 78 79 int ImportBuffer(DrmDevice *drm_device); 80 IsProtectedDrmHwcLayer81 bool IsProtected() const { 82 return (gralloc_buffer_usage & GRALLOC_USAGE_PROTECTED) == 83 GRALLOC_USAGE_PROTECTED; 84 } 85 }; 86 87 } // namespace android 88 89 #endif 90