1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include "ui/gfx/gpu_fence.h"
#include "ui/ozone/platform/drm/gpu/drm_framebuffer.h"
namespace ui {
namespace {
std::unique_ptr<gfx::GpuFence> CloneGpuFence(
const std::unique_ptr<gfx::GpuFence>& gpu_fence) {
if (!gpu_fence)
return nullptr;
return std::make_unique<gfx::GpuFence>(
gpu_fence->GetGpuFenceHandle().Clone());
}
} // namespace
DrmOverlayPlane::DrmOverlayPlane(const scoped_refptr<DrmFramebuffer>& buffer,
std::unique_ptr<gfx::GpuFence> gpu_fence)
: buffer(buffer),
plane_transform(gfx::OVERLAY_TRANSFORM_NONE),
display_bounds(gfx::Point(), buffer->size()),
crop_rect(0, 0, 1, 1),
enable_blend(false),
gpu_fence(std::move(gpu_fence)) {}
DrmOverlayPlane::DrmOverlayPlane(const scoped_refptr<DrmFramebuffer>& buffer,
int z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect,
bool enable_blend,
std::unique_ptr<gfx::GpuFence> gpu_fence)
: buffer(buffer),
z_order(z_order),
plane_transform(plane_transform),
display_bounds(display_bounds),
crop_rect(crop_rect),
enable_blend(enable_blend),
gpu_fence(std::move(gpu_fence)) {}
DrmOverlayPlane::DrmOverlayPlane(DrmOverlayPlane&& other) = default;
DrmOverlayPlane& DrmOverlayPlane::operator=(DrmOverlayPlane&& other) = default;
DrmOverlayPlane::~DrmOverlayPlane() {}
// static
DrmOverlayPlane DrmOverlayPlane::Error() {
return DrmOverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID,
gfx::Rect(), gfx::RectF(), /* enable_blend */ true,
/* gpu_fence */ nullptr);
}
bool DrmOverlayPlane::operator<(const DrmOverlayPlane& plane) const {
return std::tie(z_order, display_bounds, crop_rect, plane_transform) <
std::tie(plane.z_order, plane.display_bounds, plane.crop_rect,
plane.plane_transform);
}
// static
const DrmOverlayPlane* DrmOverlayPlane::GetPrimaryPlane(
const DrmOverlayPlaneList& overlays) {
for (size_t i = 0; i < overlays.size(); ++i) {
if (overlays[i].z_order == 0)
return &overlays[i];
}
return nullptr;
}
DrmOverlayPlane DrmOverlayPlane::Clone() const {
return DrmOverlayPlane(buffer, z_order, plane_transform, display_bounds,
crop_rect, enable_blend, CloneGpuFence(gpu_fence));
}
// static
std::vector<DrmOverlayPlane> DrmOverlayPlane::Clone(
const std::vector<DrmOverlayPlane>& planes) {
std::vector<DrmOverlayPlane> cloned_planes;
cloned_planes.reserve(planes.size());
for (auto& plane : planes)
cloned_planes.push_back(plane.Clone());
return cloned_planes;
}
} // namespace ui
|