Chromium Code Reviews| Index: components/exo/shell_surface.cc |
| diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc |
| index d93e6c717f64bf0c8805c77777c344d53006ca53..0127406abcc495f767968f0dded8cb0d90e49050 100644 |
| --- a/components/exo/shell_surface.cc |
| +++ b/components/exo/shell_surface.cc |
| @@ -623,6 +623,11 @@ void ShellSurface::SetScale(double scale) { |
| TRACE_EVENT1("exo", "ShellSurface::SetScale", "scale", scale); |
| if (scale <= 0.0) { |
| + // TODO(oshima): This uses negative value to tell if android is |
| + // NYC, which sends pixel bounds for shadow. Remove this once NYC |
| + // transition is complete. |
| + pixel_shadow_bounds_ = true; |
| + pending_scale_ = -scale; |
|
oshima
2017/02/02 00:05:55
I'm using negative scale during the transition. If
|
| DLOG(WARNING) << "Surface scale must be greater than 0"; |
| return; |
| } |
| @@ -1414,10 +1419,18 @@ void ShellSurface::UpdateShadow() { |
| shadow_underlay_->Hide(); |
| } else { |
| wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); |
| - |
| - gfx::Rect shadow_content_bounds = shadow_content_bounds_; |
| - if (shadow_content_bounds.IsEmpty()) |
| - shadow_content_bounds = window->bounds(); |
| + gfx::Rect shadow_content_bounds = |
| + gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_); |
| + gfx::Rect shadow_underlay_bounds = shadow_content_bounds_; |
| + if (shadow_underlay_bounds.IsEmpty()) |
| + shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); |
| + |
| + if (!pixel_shadow_bounds_) { |
| + shadow_content_bounds = shadow_content_bounds_; |
| + if (shadow_content_bounds.IsEmpty()) { |
| + shadow_content_bounds = window->bounds(); |
| + } |
| + } |
| // TODO(oshima): Adjust the coordinates from client screen to |
| // chromeos screen when multi displays are supported. |
| @@ -1440,8 +1453,16 @@ void ShellSurface::UpdateShadow() { |
| shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); |
| shadow_underlay_->layer()->SetColor(SK_ColorBLACK); |
| DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); |
| - window->AddChild(shadow_underlay_); |
| - window->StackChildAtBottom(shadow_underlay_); |
| + if (!pixel_shadow_bounds_) { |
| + window->AddChild(shadow_underlay_); |
| + window->StackChildAtBottom(shadow_underlay_); |
| + } else { |
| + surface_->window()->AddChild(shadow_underlay_); |
| + } |
| + } |
| + |
| + if (pixel_shadow_bounds_) { |
| + surface_->window()->StackChildAtBottom(shadow_underlay_); |
| } |
| bool underlay_capture_events = |
| @@ -1459,14 +1480,20 @@ void ShellSurface::UpdateShadow() { |
| if ((widget_->IsFullscreen() || underlay_capture_events) && |
| ash::wm::GetWindowState(window)->allow_set_bounds_in_maximized() && |
| window->layer()->GetTargetTransform().IsIdentity()) { |
| - gfx::Point origin; |
| - origin -= window->bounds().origin().OffsetFromOrigin(); |
| - shadow_bounds.set_origin(origin); |
| - shadow_bounds.set_size(window->parent()->bounds().size()); |
| + if (!pixel_shadow_bounds_) { |
| + gfx::Point origin; |
| + origin -= window->bounds().origin().OffsetFromOrigin(); |
| + shadow_bounds.set_origin(origin); |
| + shadow_bounds.set_size(window->parent()->bounds().size()); |
| + } else { |
| + shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); |
| + } |
| shadow_underlay_opacity = 1.0f; |
| } |
| - gfx::Rect shadow_underlay_bounds = shadow_bounds; |
| + if (!pixel_shadow_bounds_) { |
| + shadow_underlay_bounds = shadow_bounds; |
| + } |
| // Constrain the underlay bounds to the client area in case shell surface |
| // frame is enabled. |
| @@ -1498,7 +1525,12 @@ void ShellSurface::UpdateShadow() { |
| shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); |
| shadow_overlay_->layer()->Add(shadow->layer()); |
| window->AddChild(shadow_overlay_); |
| - window->StackChildAbove(shadow_overlay_, shadow_underlay_); |
| + |
| + if (!pixel_shadow_bounds_) { |
| + window->StackChildAbove(shadow_overlay_, shadow_underlay_); |
| + } else { |
| + window->StackChildBelow(shadow_overlay_, surface_->window()); |
| + } |
| shadow_overlay_->Show(); |
| } |
| shadow_overlay_->SetBounds(shadow_bounds); |