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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "cc/base/scoped_ptr_algorithm.h" | 14 #include "cc/base/scoped_ptr_algorithm.h" |
15 #include "cc/layers/content_layer.h" | 15 #include "cc/layers/content_layer.h" |
16 #include "cc/layers/delegated_renderer_layer.h" | 16 #include "cc/layers/delegated_renderer_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/texture_layer.h" | 20 #include "cc/layers/texture_layer.h" |
20 #include "cc/output/copy_output_request.h" | 21 #include "cc/output/copy_output_request.h" |
21 #include "cc/output/delegated_frame_data.h" | 22 #include "cc/output/delegated_frame_data.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/resources/transferable_resource.h" | 25 #include "cc/resources/transferable_resource.h" |
25 #include "ui/compositor/compositor_switches.h" | 26 #include "ui/compositor/compositor_switches.h" |
26 #include "ui/compositor/dip_util.h" | 27 #include "ui/compositor/dip_util.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 content_layer_ = new_layer; | 577 content_layer_ = new_layer; |
577 | 578 |
578 mailbox_ = cc::TextureMailbox(); | 579 mailbox_ = cc::TextureMailbox(); |
579 if (mailbox_release_callback_) { | 580 if (mailbox_release_callback_) { |
580 mailbox_release_callback_->Run(0, false); | 581 mailbox_release_callback_->Run(0, false); |
581 mailbox_release_callback_.reset(); | 582 mailbox_release_callback_.reset(); |
582 } | 583 } |
583 RecomputeDrawsContentAndUVRect(); | 584 RecomputeDrawsContentAndUVRect(); |
584 } | 585 } |
585 | 586 |
587 void Layer::UpdateNinePatchLayer(const SkBitmap& bitmap, | |
588 const gfx::Rect& aperture, | |
589 const gfx::Rect& border) { | |
590 DCHECK(nine_patch_layer_.get()); | |
591 if (!nine_patch_layer_.get()) | |
danakj
2014/07/15 17:53:34
You DCHECK'd this won't happen, so please don't tr
sky
2014/07/15 17:55:18
It would also be nice if you could dcheck on the t
hshi1
2014/07/15 18:16:39
Done.
hshi1
2014/07/15 18:16:39
Done.
| |
592 return; | |
593 | |
594 nine_patch_layer_->SetBitmap(bitmap); | |
595 nine_patch_layer_->SetAperture(aperture); | |
596 nine_patch_layer_->SetBorder(border); | |
597 } | |
598 | |
586 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 599 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
587 | 600 |
588 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 601 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
589 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !mailbox_.IsValid())) | 602 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !mailbox_.IsValid())) |
sky
2014/07/15 17:52:20
Should SchedulePaint do nothing for nine patches t
hshi1
2014/07/15 18:16:39
Done.
| |
590 return false; | 603 return false; |
591 | 604 |
592 damaged_region_.op(invalid_rect.x(), | 605 damaged_region_.op(invalid_rect.x(), |
593 invalid_rect.y(), | 606 invalid_rect.y(), |
594 invalid_rect.right(), | 607 invalid_rect.right(), |
595 invalid_rect.bottom(), | 608 invalid_rect.bottom(), |
596 SkRegion::kUnion_Op); | 609 SkRegion::kUnion_Op); |
597 ScheduleDraw(); | 610 ScheduleDraw(); |
598 return true; | 611 return true; |
599 } | 612 } |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 pending_threaded_animations_.clear(); | 933 pending_threaded_animations_.clear(); |
921 | 934 |
922 for (size_t i = 0; i < children_.size(); ++i) | 935 for (size_t i = 0; i < children_.size(); ++i) |
923 children_[i]->SendPendingThreadedAnimations(); | 936 children_[i]->SendPendingThreadedAnimations(); |
924 } | 937 } |
925 | 938 |
926 void Layer::CreateWebLayer() { | 939 void Layer::CreateWebLayer() { |
927 if (type_ == LAYER_SOLID_COLOR) { | 940 if (type_ == LAYER_SOLID_COLOR) { |
928 solid_color_layer_ = cc::SolidColorLayer::Create(); | 941 solid_color_layer_ = cc::SolidColorLayer::Create(); |
929 cc_layer_ = solid_color_layer_.get(); | 942 cc_layer_ = solid_color_layer_.get(); |
943 } else if (type_ == LAYER_NINE_PATCH) { | |
944 nine_patch_layer_ = cc::NinePatchLayer::Create(); | |
945 cc_layer_ = nine_patch_layer_.get(); | |
930 } else { | 946 } else { |
931 if (Layer::UsingPictureLayer()) | 947 if (Layer::UsingPictureLayer()) |
932 content_layer_ = cc::PictureLayer::Create(this); | 948 content_layer_ = cc::PictureLayer::Create(this); |
933 else | 949 else |
934 content_layer_ = cc::ContentLayer::Create(this); | 950 content_layer_ = cc::ContentLayer::Create(this); |
935 cc_layer_ = content_layer_.get(); | 951 cc_layer_ = content_layer_.get(); |
936 } | 952 } |
937 cc_layer_->SetTransformOrigin(gfx::Point3F()); | 953 cc_layer_->SetTransformOrigin(gfx::Point3F()); |
938 cc_layer_->SetContentsOpaque(true); | 954 cc_layer_->SetContentsOpaque(true); |
939 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 955 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 children_.end(), | 1004 children_.end(), |
989 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1005 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
990 collection)); | 1006 collection)); |
991 } | 1007 } |
992 | 1008 |
993 bool Layer::IsAnimating() const { | 1009 bool Layer::IsAnimating() const { |
994 return animator_ && animator_->is_animating(); | 1010 return animator_ && animator_->is_animating(); |
995 } | 1011 } |
996 | 1012 |
997 } // namespace ui | 1013 } // namespace ui |
OLD | NEW |