[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / compositor / overlay_candidate_validator_ozone.cc
blob90db8d8ac3f91816c18700a9530bf01cf648110f
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"
9 namespace content {
11 static ui::SurfaceFactoryOzone::BufferFormat GetOzoneFormat(
12 cc::ResourceFormat overlay_format) {
13 switch (overlay_format) {
14 case cc::RGBA_8888:
15 return ui::SurfaceFactoryOzone::RGBA_8888;
16 case cc::RGBA_4444:
17 case cc::BGRA_8888:
18 case cc::ALPHA_8:
19 case cc::LUMINANCE_8:
20 case cc::RGB_565:
21 case cc::ETC1:
22 case cc::RED_8:
23 break;
25 NOTREACHED();
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