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
;
25 return ui::SurfaceFactoryOzone::UNKNOWN
;
28 OverlayCandidateValidatorOzone::OverlayCandidateValidatorOzone(
29 gfx::AcceleratedWidget widget
,
30 ui::OverlayCandidatesOzone
* overlay_candidates
)
31 : widget_(widget
), overlay_candidates_(overlay_candidates
) {
34 OverlayCandidateValidatorOzone::~OverlayCandidateValidatorOzone() {}
36 void OverlayCandidateValidatorOzone::CheckOverlaySupport(
37 cc::OverlayCandidateList
* surfaces
) {
38 DCHECK_GE(2U, surfaces
->size());
39 ui::OverlayCandidatesOzone::OverlaySurfaceCandidateList ozone_surface_list
;
40 ozone_surface_list
.resize(surfaces
->size());
42 for (size_t i
= 0; i
< surfaces
->size(); i
++) {
43 ozone_surface_list
.at(i
).transform
= surfaces
->at(i
).transform
;
44 ozone_surface_list
.at(i
).format
= GetOzoneFormat(surfaces
->at(i
).format
);
45 ozone_surface_list
.at(i
).display_rect
= surfaces
->at(i
).display_rect
;
46 ozone_surface_list
.at(i
).crop_rect
= surfaces
->at(i
).uv_rect
;
47 ozone_surface_list
.at(i
).plane_z_order
= surfaces
->at(i
).plane_z_order
;
50 overlay_candidates_
->CheckOverlaySupport(&ozone_surface_list
);
51 DCHECK_EQ(surfaces
->size(), ozone_surface_list
.size());
53 for (size_t i
= 0; i
< surfaces
->size(); i
++) {
54 surfaces
->at(i
).overlay_handled
= ozone_surface_list
.at(i
).overlay_handled
;
58 } // namespace content