| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 16 #include "cc/layers/nine_patch_layer.h" | 17 #include "cc/layers/nine_patch_layer.h" |
| 17 #include "cc/layers/picture_layer.h" | 18 #include "cc/layers/picture_layer.h" |
| 18 #include "cc/layers/solid_color_layer.h" | 19 #include "cc/layers/solid_color_layer.h" |
| 19 #include "cc/layers/surface_layer.h" | 20 #include "cc/layers/surface_layer.h" |
| 20 #include "cc/layers/texture_layer.h" | 21 #include "cc/layers/texture_layer.h" |
| 21 #include "cc/output/copy_output_request.h" | 22 #include "cc/output/copy_output_request.h" |
| 22 #include "cc/output/filter_operation.h" | 23 #include "cc/output/filter_operation.h" |
| 23 #include "cc/output/filter_operations.h" | 24 #include "cc/output/filter_operations.h" |
| 24 #include "cc/playback/display_item_list_settings.h" | 25 #include "cc/playback/display_item_list_settings.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 | 350 |
| 350 void Layer::SetBackgroundZoom(float zoom, int inset) { | 351 void Layer::SetBackgroundZoom(float zoom, int inset) { |
| 351 zoom_ = zoom; | 352 zoom_ = zoom; |
| 352 zoom_inset_ = inset; | 353 zoom_inset_ = inset; |
| 353 | 354 |
| 354 SetLayerBackgroundFilters(); | 355 SetLayerBackgroundFilters(); |
| 355 } | 356 } |
| 356 | 357 |
| 357 void Layer::SetAlphaShape(scoped_ptr<SkRegion> region) { | 358 void Layer::SetAlphaShape(std::unique_ptr<SkRegion> region) { |
| 358 alpha_shape_ = std::move(region); | 359 alpha_shape_ = std::move(region); |
| 359 | 360 |
| 360 SetLayerFilters(); | 361 SetLayerFilters(); |
| 361 } | 362 } |
| 362 | 363 |
| 363 void Layer::SetLayerFilters() { | 364 void Layer::SetLayerFilters() { |
| 364 cc::FilterOperations filters; | 365 cc::FilterOperations filters; |
| 365 if (layer_saturation_) { | 366 if (layer_saturation_) { |
| 366 filters.Append(cc::FilterOperation::CreateSaturateFilter( | 367 filters.Append(cc::FilterOperation::CreateSaturateFilter( |
| 367 layer_saturation_)); | 368 layer_saturation_)); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 522 } |
| 522 | 523 |
| 523 void Layer::SwitchCCLayerForTest() { | 524 void Layer::SwitchCCLayerForTest() { |
| 524 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this); | 525 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this); |
| 525 SwitchToLayer(new_layer); | 526 SwitchToLayer(new_layer); |
| 526 content_layer_ = new_layer; | 527 content_layer_ = new_layer; |
| 527 } | 528 } |
| 528 | 529 |
| 529 void Layer::SetTextureMailbox( | 530 void Layer::SetTextureMailbox( |
| 530 const cc::TextureMailbox& mailbox, | 531 const cc::TextureMailbox& mailbox, |
| 531 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 532 std::unique_ptr<cc::SingleReleaseCallback> release_callback, |
| 532 gfx::Size texture_size_in_dip) { | 533 gfx::Size texture_size_in_dip) { |
| 533 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); | 534 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); |
| 534 DCHECK(mailbox.IsValid()); | 535 DCHECK(mailbox.IsValid()); |
| 535 DCHECK(release_callback); | 536 DCHECK(release_callback); |
| 536 if (!texture_layer_.get()) { | 537 if (!texture_layer_.get()) { |
| 537 scoped_refptr<cc::TextureLayer> new_layer = | 538 scoped_refptr<cc::TextureLayer> new_layer = |
| 538 cc::TextureLayer::CreateForMailbox(this); | 539 cc::TextureLayer::CreateForMailbox(this); |
| 539 new_layer->SetFlipped(true); | 540 new_layer->SetFlipped(true); |
| 540 SwitchToLayer(new_layer); | 541 SwitchToLayer(new_layer); |
| 541 texture_layer_ = new_layer; | 542 texture_layer_ = new_layer; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); | 717 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 717 } | 718 } |
| 718 | 719 |
| 719 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 720 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| 720 DCHECK(surface_layer_.get()); | 721 DCHECK(surface_layer_.get()); |
| 721 if (!delegate_) | 722 if (!delegate_) |
| 722 return; | 723 return; |
| 723 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); | 724 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); |
| 724 } | 725 } |
| 725 | 726 |
| 726 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { | 727 void Layer::RequestCopyOfOutput( |
| 728 std::unique_ptr<cc::CopyOutputRequest> request) { |
| 727 cc_layer_->RequestCopyOfOutput(std::move(request)); | 729 cc_layer_->RequestCopyOfOutput(std::move(request)); |
| 728 } | 730 } |
| 729 | 731 |
| 730 gfx::Rect Layer::PaintableRegion() { | 732 gfx::Rect Layer::PaintableRegion() { |
| 731 return gfx::Rect(size()); | 733 return gfx::Rect(size()); |
| 732 } | 734 } |
| 733 | 735 |
| 734 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( | 736 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( |
| 735 ContentLayerClient::PaintingControlSetting painting_control) { | 737 ContentLayerClient::PaintingControlSetting painting_control) { |
| 736 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); | 738 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 753 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } | 755 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |
| 754 | 756 |
| 755 size_t Layer::GetApproximateUnsharedMemoryUsage() const { | 757 size_t Layer::GetApproximateUnsharedMemoryUsage() const { |
| 756 // Most of the "picture memory" is shared with the cc::DisplayItemList, so | 758 // Most of the "picture memory" is shared with the cc::DisplayItemList, so |
| 757 // there's nothing significant to report here. | 759 // there's nothing significant to report here. |
| 758 return 0; | 760 return 0; |
| 759 } | 761 } |
| 760 | 762 |
| 761 bool Layer::PrepareTextureMailbox( | 763 bool Layer::PrepareTextureMailbox( |
| 762 cc::TextureMailbox* mailbox, | 764 cc::TextureMailbox* mailbox, |
| 763 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 765 std::unique_ptr<cc::SingleReleaseCallback>* release_callback, |
| 764 bool use_shared_memory) { | 766 bool use_shared_memory) { |
| 765 if (!mailbox_release_callback_) | 767 if (!mailbox_release_callback_) |
| 766 return false; | 768 return false; |
| 767 *mailbox = mailbox_; | 769 *mailbox = mailbox_; |
| 768 *release_callback = std::move(mailbox_release_callback_); | 770 *release_callback = std::move(mailbox_release_callback_); |
| 769 return true; | 771 return true; |
| 770 } | 772 } |
| 771 | 773 |
| 772 void Layer::SetForceRenderSurface(bool force) { | 774 void Layer::SetForceRenderSurface(bool force) { |
| 773 if (force_render_surface_ == force) | 775 if (force_render_surface_ == force) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 784 void AppendAsTraceFormat(std::string* out) const override { | 786 void AppendAsTraceFormat(std::string* out) const override { |
| 785 base::DictionaryValue dictionary; | 787 base::DictionaryValue dictionary; |
| 786 dictionary.SetString("layer_name", name_); | 788 dictionary.SetString("layer_name", name_); |
| 787 base::JSONWriter::Write(dictionary, out); | 789 base::JSONWriter::Write(dictionary, out); |
| 788 } | 790 } |
| 789 | 791 |
| 790 private: | 792 private: |
| 791 std::string name_; | 793 std::string name_; |
| 792 }; | 794 }; |
| 793 | 795 |
| 794 scoped_ptr<base::trace_event::ConvertableToTraceFormat> Layer::TakeDebugInfo( | 796 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 795 cc::Layer* layer) { | 797 Layer::TakeDebugInfo(cc::Layer* layer) { |
| 796 return make_scoped_ptr(new LayerDebugInfo(name_)); | 798 return base::WrapUnique(new LayerDebugInfo(name_)); |
| 797 } | 799 } |
| 798 | 800 |
| 799 void Layer::CollectAnimators( | 801 void Layer::CollectAnimators( |
| 800 std::vector<scoped_refptr<LayerAnimator>>* animators) { | 802 std::vector<scoped_refptr<LayerAnimator>>* animators) { |
| 801 if (animator_ && animator_->is_animating()) | 803 if (animator_ && animator_->is_animating()) |
| 802 animators->push_back(animator_); | 804 animators->push_back(animator_); |
| 803 for (auto* child : children_) | 805 for (auto* child : children_) |
| 804 child->CollectAnimators(animators); | 806 child->CollectAnimators(animators); |
| 805 } | 807 } |
| 806 | 808 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 if (animator_) { | 1027 if (animator_) { |
| 1026 animator_->ResetCompositor(compositor); | 1028 animator_->ResetCompositor(compositor); |
| 1027 animator_->RemoveFromCollection(collection); | 1029 animator_->RemoveFromCollection(collection); |
| 1028 } | 1030 } |
| 1029 | 1031 |
| 1030 for (auto* child : children_) | 1032 for (auto* child : children_) |
| 1031 child->ResetCompositorForAnimatorsInTree(compositor); | 1033 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1032 } | 1034 } |
| 1033 | 1035 |
| 1034 } // namespace ui | 1036 } // namespace ui |
| OLD | NEW |