Chromium Code Reviews| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 | 381 |
| 382 DCHECK(ListContainsEntry(pending_sub_surfaces_, sub_surface)); | 382 DCHECK(ListContainsEntry(pending_sub_surfaces_, sub_surface)); |
| 383 pending_sub_surfaces_.splice( | 383 pending_sub_surfaces_.splice( |
| 384 sibling_it, pending_sub_surfaces_, | 384 sibling_it, pending_sub_surfaces_, |
| 385 FindListEntry(pending_sub_surfaces_, sub_surface)); | 385 FindListEntry(pending_sub_surfaces_, sub_surface)); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void Surface::SetViewport(const gfx::Size& viewport) { | 388 void Surface::SetViewport(const gfx::Size& viewport) { |
| 389 TRACE_EVENT1("exo", "Surface::SetViewport", "viewport", viewport.ToString()); | 389 TRACE_EVENT1("exo", "Surface::SetViewport", "viewport", viewport.ToString()); |
| 390 | 390 |
| 391 if (pending_viewport_ == viewport) | |
| 392 return; | |
| 393 | |
| 391 pending_viewport_ = viewport; | 394 pending_viewport_ = viewport; |
| 395 changed_viewport_or_crop_ = true; | |
| 392 } | 396 } |
| 393 | 397 |
| 394 void Surface::SetCrop(const gfx::RectF& crop) { | 398 void Surface::SetCrop(const gfx::RectF& crop) { |
| 395 TRACE_EVENT1("exo", "Surface::SetCrop", "crop", crop.ToString()); | 399 TRACE_EVENT1("exo", "Surface::SetCrop", "crop", crop.ToString()); |
| 396 | 400 |
| 401 if (pending_crop_ == crop) | |
| 402 return; | |
| 403 | |
| 397 pending_crop_ = crop; | 404 pending_crop_ = crop; |
| 405 changed_viewport_or_crop_ = true; | |
| 398 } | 406 } |
| 399 | 407 |
| 400 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { | 408 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { |
| 401 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput", | 409 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput", |
| 402 "only_visible_on_secure_output", only_visible_on_secure_output); | 410 "only_visible_on_secure_output", only_visible_on_secure_output); |
| 403 | 411 |
| 404 pending_only_visible_on_secure_output_ = only_visible_on_secure_output; | 412 pending_only_visible_on_secure_output_ = only_visible_on_secure_output; |
| 405 } | 413 } |
| 406 | 414 |
| 407 void Surface::SetBlendMode(SkXfermode::Mode blend_mode) { | 415 void Surface::SetBlendMode(SkXfermode::Mode blend_mode) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // fills-bounds-opaquely. | 513 // fills-bounds-opaquely. |
| 506 layer()->SetFillsBoundsOpaquely( | 514 layer()->SetFillsBoundsOpaquely( |
| 507 pending_blend_mode_ == SkXfermode::kSrc_Mode || | 515 pending_blend_mode_ == SkXfermode::kSrc_Mode || |
| 508 pending_opaque_region_.contains( | 516 pending_opaque_region_.contains( |
| 509 gfx::RectToSkIRect(gfx::Rect(layer()->size())))); | 517 gfx::RectToSkIRect(gfx::Rect(layer()->size())))); |
| 510 } | 518 } |
| 511 | 519 |
| 512 void Surface::CommitSurfaceContents() { | 520 void Surface::CommitSurfaceContents() { |
| 513 // We update contents if Attach() has been called since last commit. | 521 // We update contents if Attach() has been called since last commit. |
| 514 if (has_pending_contents_) { | 522 if (has_pending_contents_) { |
| 515 has_pending_contents_ = false; | |
| 516 | |
| 517 current_buffer_ = pending_buffer_; | 523 current_buffer_ = pending_buffer_; |
| 518 pending_buffer_.reset(); | 524 pending_buffer_.reset(); |
| 525 } | |
| 526 | |
| 527 if (has_pending_contents_ || changed_viewport_or_crop_) { | |
| 528 has_pending_contents_ = false; | |
| 529 changed_viewport_or_crop_ = false; | |
| 519 | 530 |
| 520 bool secure_output_only = pending_only_visible_on_secure_output_; | 531 bool secure_output_only = pending_only_visible_on_secure_output_; |
| 521 pending_only_visible_on_secure_output_ = false; | 532 pending_only_visible_on_secure_output_ = false; |
| 522 | 533 |
| 523 cc::TextureMailbox texture_mailbox; | 534 cc::TextureMailbox texture_mailbox; |
| 524 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; | 535 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; |
| 525 if (current_buffer_) { | 536 if (current_buffer_) { |
| 526 texture_mailbox_release_callback = current_buffer_->ProduceTextureMailbox( | 537 texture_mailbox_release_callback = current_buffer_->ProduceTextureMailbox( |
|
reveman
2016/06/02 21:48:29
It's considered a client error to commit the same
| |
| 527 &texture_mailbox, secure_output_only, false); | 538 &texture_mailbox, secure_output_only, false); |
| 528 } | 539 } |
| 529 | 540 |
| 530 cc::SurfaceId old_surface_id = surface_id_; | 541 cc::SurfaceId old_surface_id = surface_id_; |
| 531 surface_id_ = factory_owner_->id_allocator_->GenerateId(); | 542 surface_id_ = factory_owner_->id_allocator_->GenerateId(); |
| 532 factory_owner_->surface_factory_->Create(surface_id_); | 543 factory_owner_->surface_factory_->Create(surface_id_); |
| 533 | 544 |
| 534 gfx::Size buffer_size = texture_mailbox.size_in_pixels(); | 545 gfx::Size buffer_size = texture_mailbox.size_in_pixels(); |
| 535 gfx::SizeF scaled_buffer_size( | 546 gfx::SizeF scaled_buffer_size( |
| 536 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / pending_buffer_scale_)); | 547 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / pending_buffer_scale_)); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 void Surface::WillDraw(cc::SurfaceId id) { | 875 void Surface::WillDraw(cc::SurfaceId id) { |
| 865 while (!active_frame_callbacks_.empty()) { | 876 while (!active_frame_callbacks_.empty()) { |
| 866 active_frame_callbacks_.front().Run(base::TimeTicks::Now()); | 877 active_frame_callbacks_.front().Run(base::TimeTicks::Now()); |
| 867 active_frame_callbacks_.pop_front(); | 878 active_frame_callbacks_.pop_front(); |
| 868 } | 879 } |
| 869 } | 880 } |
| 870 | 881 |
| 871 bool Surface::use_surface_layer_ = false; | 882 bool Surface::use_surface_layer_ = false; |
| 872 | 883 |
| 873 } // namespace exo | 884 } // namespace exo |
| OLD | NEW |