Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: ui/compositor/layer.cc

Issue 1101103004: Revert of ui: Clean up damaged rects and clear them after painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 nine_patch_layer_->SetBorder(border); 650 nine_patch_layer_->SetBorder(border);
651 } 651 }
652 652
653 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } 653 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); }
654 654
655 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { 655 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
656 if ((type_ == LAYER_SOLID_COLOR && !texture_layer_.get()) || 656 if ((type_ == LAYER_SOLID_COLOR && !texture_layer_.get()) ||
657 type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid())) 657 type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid()))
658 return false; 658 return false;
659 659
660 damaged_region_.Union(invalid_rect); 660 damaged_region_.op(invalid_rect.x(),
661 invalid_rect.y(),
662 invalid_rect.right(),
663 invalid_rect.bottom(),
664 SkRegion::kUnion_Op);
661 ScheduleDraw(); 665 ScheduleDraw();
662 return true; 666 return true;
663 } 667 }
664 668
665 void Layer::ScheduleDraw() { 669 void Layer::ScheduleDraw() {
666 Compositor* compositor = GetCompositor(); 670 Compositor* compositor = GetCompositor();
667 if (compositor) 671 if (compositor)
668 compositor->ScheduleDraw(); 672 compositor->ScheduleDraw();
669 } 673 }
670 674
671 void Layer::SendDamagedRects() { 675 void Layer::SendDamagedRects() {
672 if (damaged_region_.IsEmpty()) 676 if ((delegate_ || mailbox_.IsValid()) && !damaged_region_.isEmpty()) {
673 return; 677 for (SkRegion::Iterator iter(damaged_region_); !iter.done(); iter.next()) {
674 if (!delegate_ && !mailbox_.IsValid()) 678 const SkIRect& sk_damaged = iter.rect();
675 return; 679 gfx::Rect damaged(
676 680 sk_damaged.x(),
677 for (cc::Region::Iterator iter(damaged_region_); iter.has_rect(); iter.next()) 681 sk_damaged.y(),
678 cc_layer_->SetNeedsDisplayRect(iter.rect()); 682 sk_damaged.width(),
679 } 683 sk_damaged.height());
680 684 cc_layer_->SetNeedsDisplayRect(damaged);
681 void Layer::ClearDamagedRects() { 685 }
682 damaged_region_.Clear(); 686 damaged_region_.setEmpty();
687 }
688 for (size_t i = 0; i < children_.size(); ++i)
689 children_[i]->SendDamagedRects();
683 } 690 }
684 691
685 void Layer::CompleteAllAnimations() { 692 void Layer::CompleteAllAnimations() {
686 typedef std::vector<scoped_refptr<LayerAnimator> > LayerAnimatorVector; 693 typedef std::vector<scoped_refptr<LayerAnimator> > LayerAnimatorVector;
687 LayerAnimatorVector animators; 694 LayerAnimatorVector animators;
688 CollectAnimators(&animators); 695 CollectAnimators(&animators);
689 for (LayerAnimatorVector::const_iterator it = animators.begin(); 696 for (LayerAnimatorVector::const_iterator it = animators.begin();
690 it != animators.end(); 697 it != animators.end();
691 ++it) { 698 ++it) {
692 (*it)->StopAnimating(); 699 (*it)->StopAnimating();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 738
732 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { 739 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) {
733 cc_layer_->RequestCopyOfOutput(request.Pass()); 740 cc_layer_->RequestCopyOfOutput(request.Pass());
734 } 741 }
735 742
736 void Layer::PaintContents( 743 void Layer::PaintContents(
737 SkCanvas* sk_canvas, 744 SkCanvas* sk_canvas,
738 const gfx::Rect& clip, 745 const gfx::Rect& clip,
739 ContentLayerClient::PaintingControlSetting painting_control) { 746 ContentLayerClient::PaintingControlSetting painting_control) {
740 TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_); 747 TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_);
741 ClearDamagedRects();
742 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( 748 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
743 sk_canvas, device_scale_factor_)); 749 sk_canvas, device_scale_factor_));
744 if (delegate_) 750 if (delegate_)
745 delegate_->OnPaintLayer(PaintContext(canvas.get(), clip)); 751 delegate_->OnPaintLayer(PaintContext(canvas.get(), clip));
746 } 752 }
747 753
748 void Layer::PaintContentsToDisplayList( 754 void Layer::PaintContentsToDisplayList(
749 cc::DisplayItemList* display_list, 755 cc::DisplayItemList* display_list,
750 const gfx::Rect& clip, 756 const gfx::Rect& clip,
751 ContentLayerClient::PaintingControlSetting painting_control) { 757 ContentLayerClient::PaintingControlSetting painting_control) {
752 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); 758 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_);
753 ClearDamagedRects(); 759 if (delegate_) {
754 if (!delegate_) 760 // TODO(danakj): Save the invalidation on the layer and pass that down
755 return; 761 // instead of the |clip| here. That will break everything until View
756 // TODO(danakj): Save the invalidation on the layer and pass that down 762 // early-outs emit cached display items instead of nothing.
757 // instead of the |clip| here. That will break everything until View 763 gfx::Rect invalidation = clip;
758 // early-outs emit cached display items instead of nothing. 764 DCHECK(clip.Contains(invalidation));
759 gfx::Rect invalidation = clip; 765 delegate_->OnPaintLayer(
760 DCHECK(clip.Contains(invalidation)); 766 PaintContext(display_list, device_scale_factor_, clip, invalidation));
761 delegate_->OnPaintLayer( 767 }
762 PaintContext(display_list, device_scale_factor_, clip, invalidation));
763 } 768 }
764 769
765 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } 770 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; }
766 771
767 bool Layer::PrepareTextureMailbox( 772 bool Layer::PrepareTextureMailbox(
768 cc::TextureMailbox* mailbox, 773 cc::TextureMailbox* mailbox,
769 scoped_ptr<cc::SingleReleaseCallback>* release_callback, 774 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
770 bool use_shared_memory) { 775 bool use_shared_memory) {
771 if (!mailbox_release_callback_) 776 if (!mailbox_release_callback_)
772 return false; 777 return false;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 children_.end(), 1091 children_.end(),
1087 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), 1092 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection),
1088 collection)); 1093 collection));
1089 } 1094 }
1090 1095
1091 bool Layer::IsAnimating() const { 1096 bool Layer::IsAnimating() const {
1092 return animator_.get() && animator_->is_animating(); 1097 return animator_.get() && animator_->is_animating();
1093 } 1098 }
1094 1099
1095 } // namespace ui 1100 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698