OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/surface.h" | 5 #include "components/exo/surface.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
11 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
12 #include "cc/resources/single_release_callback.h" | 14 #include "cc/resources/single_release_callback.h" |
13 #include "components/exo/buffer.h" | 15 #include "components/exo/buffer.h" |
14 #include "components/exo/surface_delegate.h" | 16 #include "components/exo/surface_delegate.h" |
15 #include "components/exo/surface_observer.h" | 17 #include "components/exo/surface_observer.h" |
16 #include "ui/aura/window_delegate.h" | 18 #include "ui/aura/window_delegate.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 cc::TextureMailbox texture_mailbox; | 264 cc::TextureMailbox texture_mailbox; |
263 scoped_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; | 265 scoped_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; |
264 if (current_buffer_) { | 266 if (current_buffer_) { |
265 texture_mailbox_release_callback = | 267 texture_mailbox_release_callback = |
266 current_buffer_->ProduceTextureMailbox(&texture_mailbox); | 268 current_buffer_->ProduceTextureMailbox(&texture_mailbox); |
267 } | 269 } |
268 | 270 |
269 if (texture_mailbox_release_callback) { | 271 if (texture_mailbox_release_callback) { |
270 // Update layer with the new contents. | 272 // Update layer with the new contents. |
271 layer()->SetTextureMailbox(texture_mailbox, | 273 layer()->SetTextureMailbox(texture_mailbox, |
272 texture_mailbox_release_callback.Pass(), | 274 std::move(texture_mailbox_release_callback), |
273 texture_mailbox.size_in_pixels()); | 275 texture_mailbox.size_in_pixels()); |
274 layer()->SetTextureFlipped(false); | 276 layer()->SetTextureFlipped(false); |
275 layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), | 277 layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), |
276 texture_mailbox.size_in_pixels())); | 278 texture_mailbox.size_in_pixels())); |
277 layer()->SetFillsBoundsOpaquely(pending_opaque_region_.contains( | 279 layer()->SetFillsBoundsOpaquely(pending_opaque_region_.contains( |
278 gfx::RectToSkIRect(gfx::Rect(texture_mailbox.size_in_pixels())))); | 280 gfx::RectToSkIRect(gfx::Rect(texture_mailbox.size_in_pixels())))); |
279 } else { | 281 } else { |
280 // Show solid color content if no buffer is attached or we failed | 282 // Show solid color content if no buffer is attached or we failed |
281 // to produce a texture mailbox for the currently attached buffer. | 283 // to produce a texture mailbox for the currently attached buffer. |
282 layer()->SetShowSolidColorContent(); | 284 layer()->SetShowSolidColorContent(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // Early out if no contents is currently assigned to the surface. | 397 // Early out if no contents is currently assigned to the surface. |
396 if (!current_buffer_) | 398 if (!current_buffer_) |
397 return; | 399 return; |
398 | 400 |
399 // Update contents by producing a new texture mailbox for the current buffer. | 401 // Update contents by producing a new texture mailbox for the current buffer. |
400 cc::TextureMailbox texture_mailbox; | 402 cc::TextureMailbox texture_mailbox; |
401 scoped_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback = | 403 scoped_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback = |
402 current_buffer_->ProduceTextureMailbox(&texture_mailbox); | 404 current_buffer_->ProduceTextureMailbox(&texture_mailbox); |
403 if (texture_mailbox_release_callback) { | 405 if (texture_mailbox_release_callback) { |
404 layer()->SetTextureMailbox(texture_mailbox, | 406 layer()->SetTextureMailbox(texture_mailbox, |
405 texture_mailbox_release_callback.Pass(), | 407 std::move(texture_mailbox_release_callback), |
406 texture_mailbox.size_in_pixels()); | 408 texture_mailbox.size_in_pixels()); |
407 layer()->SetTextureFlipped(false); | 409 layer()->SetTextureFlipped(false); |
408 layer()->SchedulePaint(gfx::Rect(texture_mailbox.size_in_pixels())); | 410 layer()->SchedulePaint(gfx::Rect(texture_mailbox.size_in_pixels())); |
409 } | 411 } |
410 } | 412 } |
411 | 413 |
412 void Surface::OnCompositingAborted(ui::Compositor* compositor) { | 414 void Surface::OnCompositingAborted(ui::Compositor* compositor) { |
413 // The contents of this surface might be lost if compositing aborted because | 415 // The contents of this surface might be lost if compositing aborted because |
414 // of a lost graphics context. We recover from this by updating the contents | 416 // of a lost graphics context. We recover from this by updating the contents |
415 // of the surface next time the compositor successfully ends compositing. | 417 // of the surface next time the compositor successfully ends compositing. |
416 update_contents_after_successful_compositing_ = true; | 418 update_contents_after_successful_compositing_ = true; |
417 } | 419 } |
418 | 420 |
419 void Surface::OnCompositingShuttingDown(ui::Compositor* compositor) { | 421 void Surface::OnCompositingShuttingDown(ui::Compositor* compositor) { |
420 compositor->RemoveObserver(this); | 422 compositor->RemoveObserver(this); |
421 compositor_ = nullptr; | 423 compositor_ = nullptr; |
422 } | 424 } |
423 | 425 |
424 } // namespace exo | 426 } // namespace exo |
OLD | NEW |