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::UpdateNinePatchLayerBitmap(const SkBitmap& bitmap, |
| 588 const gfx::Rect& aperture) { |
| 589 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
| 590 SkBitmap bitmap_copy; |
| 591 if (bitmap.isImmutable()) { |
| 592 bitmap_copy = bitmap; |
| 593 } else { |
| 594 // UIResourceBitmap requires an immutable copy of the input |bitmap|. |
| 595 bitmap.copyTo(&bitmap_copy); |
| 596 bitmap_copy.setImmutable(); |
| 597 } |
| 598 nine_patch_layer_->SetBitmap(bitmap_copy); |
| 599 nine_patch_layer_->SetAperture(aperture); |
| 600 } |
| 601 |
| 602 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { |
| 603 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
| 604 nine_patch_layer_->SetBorder(border); |
| 605 } |
| 606 |
586 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 607 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
587 | 608 |
588 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 609 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
589 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !mailbox_.IsValid())) | 610 if (type_ == LAYER_SOLID_COLOR || |
| 611 type_ == LAYER_NINE_PATCH || |
| 612 (!delegate_ && !mailbox_.IsValid())) |
590 return false; | 613 return false; |
591 | 614 |
592 damaged_region_.op(invalid_rect.x(), | 615 damaged_region_.op(invalid_rect.x(), |
593 invalid_rect.y(), | 616 invalid_rect.y(), |
594 invalid_rect.right(), | 617 invalid_rect.right(), |
595 invalid_rect.bottom(), | 618 invalid_rect.bottom(), |
596 SkRegion::kUnion_Op); | 619 SkRegion::kUnion_Op); |
597 ScheduleDraw(); | 620 ScheduleDraw(); |
598 return true; | 621 return true; |
599 } | 622 } |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 pending_threaded_animations_.clear(); | 943 pending_threaded_animations_.clear(); |
921 | 944 |
922 for (size_t i = 0; i < children_.size(); ++i) | 945 for (size_t i = 0; i < children_.size(); ++i) |
923 children_[i]->SendPendingThreadedAnimations(); | 946 children_[i]->SendPendingThreadedAnimations(); |
924 } | 947 } |
925 | 948 |
926 void Layer::CreateWebLayer() { | 949 void Layer::CreateWebLayer() { |
927 if (type_ == LAYER_SOLID_COLOR) { | 950 if (type_ == LAYER_SOLID_COLOR) { |
928 solid_color_layer_ = cc::SolidColorLayer::Create(); | 951 solid_color_layer_ = cc::SolidColorLayer::Create(); |
929 cc_layer_ = solid_color_layer_.get(); | 952 cc_layer_ = solid_color_layer_.get(); |
| 953 } else if (type_ == LAYER_NINE_PATCH) { |
| 954 nine_patch_layer_ = cc::NinePatchLayer::Create(); |
| 955 cc_layer_ = nine_patch_layer_.get(); |
930 } else { | 956 } else { |
931 if (Layer::UsingPictureLayer()) | 957 if (Layer::UsingPictureLayer()) |
932 content_layer_ = cc::PictureLayer::Create(this); | 958 content_layer_ = cc::PictureLayer::Create(this); |
933 else | 959 else |
934 content_layer_ = cc::ContentLayer::Create(this); | 960 content_layer_ = cc::ContentLayer::Create(this); |
935 cc_layer_ = content_layer_.get(); | 961 cc_layer_ = content_layer_.get(); |
936 } | 962 } |
937 cc_layer_->SetTransformOrigin(gfx::Point3F()); | 963 cc_layer_->SetTransformOrigin(gfx::Point3F()); |
938 cc_layer_->SetContentsOpaque(true); | 964 cc_layer_->SetContentsOpaque(true); |
939 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 965 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 children_.end(), | 1014 children_.end(), |
989 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1015 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
990 collection)); | 1016 collection)); |
991 } | 1017 } |
992 | 1018 |
993 bool Layer::IsAnimating() const { | 1019 bool Layer::IsAnimating() const { |
994 return animator_ && animator_->is_animating(); | 1020 return animator_ && animator_->is_animating(); |
995 } | 1021 } |
996 | 1022 |
997 } // namespace ui | 1023 } // namespace ui |
OLD | NEW |