Index: components/exo/surface.cc |
diff --git a/components/exo/surface.cc b/components/exo/surface.cc |
index ab4cf7b60c9256fe7fec22ef40e6c162558a8ad8..e027bfa40f80b19899638b4b06669c8305311215 100644 |
--- a/components/exo/surface.cc |
+++ b/components/exo/surface.cc |
@@ -484,13 +484,16 @@ void Surface::CommitSurfaceHierarchy() { |
if (old_surface_id != surface_id_) { |
float contents_surface_to_layer_scale = 1.0; |
+ // The bounds must be updated before switching to the new surface, because |
+ // the layer may be mirrored, in which case a surface change causes the |
+ // mirror layer to update its surface using the latest bounds. |
+ window_->layer()->SetBounds( |
+ gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
window_->layer()->SetShowSurface( |
surface_id_, |
base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), |
base::Bind(&RequireCallback, base::Unretained(surface_manager_)), |
content_size_, contents_surface_to_layer_scale, content_size_); |
- window_->layer()->SetBounds( |
- gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
window_->layer()->SetFillsBoundsOpaquely( |
state_.blend_mode == SkXfermode::kSrc_Mode || |
state_.opaque_region.contains( |
@@ -610,13 +613,13 @@ std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const { |
// ui::LayerOwnerDelegate overrides: |
void Surface::OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) { |
- if (!current_buffer_.buffer()) |
- return; |
- |
- // TODO(reveman): Give the client a chance to provide new contents. |
SetSurfaceLayerContents(new_layer); |
} |
+void Surface::OnLayerMirrored(ui::Layer* mirror) { |
+ SetSurfaceLayerContents(mirror); |
+} |
+ |
void Surface::WillDraw(const cc::SurfaceId& id) { |
while (!active_frame_callbacks_.empty()) { |
active_frame_callbacks_.front().Run(base::TimeTicks::Now()); |
@@ -692,12 +695,13 @@ void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { |
} |
void Surface::SetSurfaceLayerContents(ui::Layer* layer) { |
- if (surface_id_.is_null()) |
+ if (!current_buffer_.buffer() || surface_id_.is_null()) |
return; |
gfx::Size layer_size = layer->bounds().size(); |
float contents_surface_to_layer_scale = 1.0f; |
+ // TODO(reveman): Give the client a chance to provide new contents. |
layer->SetShowSurface( |
surface_id_, |
base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), |