| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/mus/client_surface_embedder.h" | 5 #include "ui/aura/mus/client_surface_embedder.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface_reference_factory.h" | 7 #include "cc/surfaces/surface_reference_factory.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/gfx/geometry/dip_util.h" | 9 #include "ui/gfx/geometry/dip_util.h" |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 gfx::Size fallback_surface_size_in_dip; | 69 gfx::Size fallback_surface_size_in_dip; |
| 70 const cc::SurfaceInfo* fallback_surface_info = | 70 const cc::SurfaceInfo* fallback_surface_info = |
| 71 surface_layer_->GetFallbackSurfaceInfo(); | 71 surface_layer_->GetFallbackSurfaceInfo(); |
| 72 if (fallback_surface_info) { | 72 if (fallback_surface_info) { |
| 73 float fallback_device_scale_factor = | 73 float fallback_device_scale_factor = |
| 74 fallback_surface_info->device_scale_factor(); | 74 fallback_surface_info->device_scale_factor(); |
| 75 fallback_surface_size_in_dip = gfx::ConvertSizeToDIP( | 75 fallback_surface_size_in_dip = gfx::ConvertSizeToDIP( |
| 76 fallback_device_scale_factor, fallback_surface_info->size_in_pixels()); | 76 fallback_device_scale_factor, fallback_surface_info->size_in_pixels()); |
| 77 } | 77 } |
| 78 gfx::Rect window_bounds(window_->bounds()); | 78 gfx::Rect window_bounds(window_->bounds()); |
| 79 if (fallback_surface_size_in_dip.width() < window_bounds.width()) { | 79 if (!window_->transparent() && |
| 80 fallback_surface_size_in_dip.width() < window_bounds.width()) { |
| 80 right_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR); | 81 right_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR); |
| 81 // TODO(fsamuel): Use the embedded client's background color. | 82 // TODO(fsamuel): Use the embedded client's background color. |
| 82 right_gutter_->SetColor(SK_ColorWHITE); | 83 right_gutter_->SetColor(SK_ColorWHITE); |
| 83 int width = window_bounds.width() - fallback_surface_size_in_dip.width(); | 84 int width = window_bounds.width() - fallback_surface_size_in_dip.width(); |
| 84 // The right gutter also includes the bottom-right corner, if necessary. | 85 // The right gutter also includes the bottom-right corner, if necessary. |
| 85 int height = window_bounds.height() - client_area_insets_.height(); | 86 int height = window_bounds.height() - client_area_insets_.height(); |
| 86 right_gutter_->SetBounds(gfx::Rect( | 87 right_gutter_->SetBounds(gfx::Rect( |
| 87 client_area_insets_.left() + fallback_surface_size_in_dip.width(), | 88 client_area_insets_.left() + fallback_surface_size_in_dip.width(), |
| 88 client_area_insets_.top(), width, height)); | 89 client_area_insets_.top(), width, height)); |
| 89 window_->layer()->Add(right_gutter_.get()); | 90 window_->layer()->Add(right_gutter_.get()); |
| 90 } else { | 91 } else { |
| 91 right_gutter_.reset(); | 92 right_gutter_.reset(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 // Only create a bottom gutter if a fallback surface is available. Otherwise, | 95 // Only create a bottom gutter if a fallback surface is available. Otherwise, |
| 95 // the right gutter will fill the whole window until a fallback is available. | 96 // the right gutter will fill the whole window until a fallback is available. |
| 96 if (!fallback_surface_size_in_dip.IsEmpty() && | 97 if (!window_->transparent() && !fallback_surface_size_in_dip.IsEmpty() && |
| 97 fallback_surface_size_in_dip.height() < window_bounds.height()) { | 98 fallback_surface_size_in_dip.height() < window_bounds.height()) { |
| 98 bottom_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR); | 99 bottom_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR); |
| 99 // TODO(fsamuel): Use the embedded client's background color. | 100 // TODO(fsamuel): Use the embedded client's background color. |
| 100 bottom_gutter_->SetColor(SK_ColorWHITE); | 101 bottom_gutter_->SetColor(SK_ColorWHITE); |
| 101 int width = fallback_surface_size_in_dip.width(); | 102 int width = fallback_surface_size_in_dip.width(); |
| 102 int height = window_bounds.height() - fallback_surface_size_in_dip.height(); | 103 int height = window_bounds.height() - fallback_surface_size_in_dip.height(); |
| 103 bottom_gutter_->SetBounds( | 104 bottom_gutter_->SetBounds( |
| 104 gfx::Rect(0, fallback_surface_size_in_dip.height(), width, height)); | 105 gfx::Rect(0, fallback_surface_size_in_dip.height(), width, height)); |
| 105 window_->layer()->Add(bottom_gutter_.get()); | 106 window_->layer()->Add(bottom_gutter_.get()); |
| 106 } else { | 107 } else { |
| 107 bottom_gutter_.reset(); | 108 bottom_gutter_.reset(); |
| 108 } | 109 } |
| 109 window_->layer()->StackAtTop(surface_layer_.get()); | 110 window_->layer()->StackAtTop(surface_layer_.get()); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace aura | 113 } // namespace aura |
| OLD | NEW |