1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/compositor/overlay_candidate_validator_ozone.h"
7 #include "ui/ozone/public/overlay_candidates_ozone.h"
11 static ui::SurfaceFactoryOzone::BufferFormat
GetOzoneFormat(
12 cc::ResourceFormat overlay_format
) {
13 switch (overlay_format
) {
15 return ui::SurfaceFactoryOzone::RGBA_8888
;
26 return ui::SurfaceFactoryOzone::UNKNOWN
;
29 OverlayCandidateValidatorOzone::OverlayCandidateValidatorOzone(
30 gfx::AcceleratedWidget widget
,
31 ui::OverlayCandidatesOzone
* overlay_candidates
)
32 : widget_(widget
), overlay_candidates_(overlay_candidates
) {
35 OverlayCandidateValidatorOzone::~OverlayCandidateValidatorOzone() {}
37 void OverlayCandidateValidatorOzone::CheckOverlaySupport(
38 cc::OverlayCandidateList
* surfaces
) {
39 DCHECK_GE(2U, surfaces
->size());
40 ui::OverlayCandidatesOzone::OverlaySurfaceCandidateList ozone_surface_list
;
41 ozone_surface_list
.resize(surfaces
->size());
43 for (size_t i
= 0; i
< surfaces
->size(); i
++) {
44 ozone_surface_list
.at(i
).transform
= surfaces
->at(i
).transform
;
45 ozone_surface_list
.at(i
).format
= GetOzoneFormat(surfaces
->at(i
).format
);
46 ozone_surface_list
.at(i
).display_rect
= surfaces
->at(i
).display_rect
;
47 ozone_surface_list
.at(i
).crop_rect
= surfaces
->at(i
).uv_rect
;
48 ozone_surface_list
.at(i
).plane_z_order
= surfaces
->at(i
).plane_z_order
;
51 overlay_candidates_
->CheckOverlaySupport(&ozone_surface_list
);
52 DCHECK_EQ(surfaces
->size(), ozone_surface_list
.size());
54 for (size_t i
= 0; i
< surfaces
->size(); i
++) {
55 surfaces
->at(i
).overlay_handled
= ozone_surface_list
.at(i
).overlay_handled
;
59 } // namespace content