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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 solid_color_layer_ = new_layer; | 613 solid_color_layer_ = new_layer; |
614 | 614 |
615 mailbox_ = cc::TextureMailbox(); | 615 mailbox_ = cc::TextureMailbox(); |
616 if (mailbox_release_callback_) { | 616 if (mailbox_release_callback_) { |
617 mailbox_release_callback_->Run(0, false); | 617 mailbox_release_callback_->Run(0, false); |
618 mailbox_release_callback_.reset(); | 618 mailbox_release_callback_.reset(); |
619 } | 619 } |
620 RecomputeDrawsContentAndUVRect(); | 620 RecomputeDrawsContentAndUVRect(); |
621 } | 621 } |
622 | 622 |
623 void Layer::UpdateNinePatchLayerBitmap(const SkBitmap& bitmap) { | 623 void Layer::UpdateNinePatchLayerImage(const gfx::ImageSkia& image) { |
624 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 624 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
625 nine_patch_layer_image_ = image; | |
626 SkBitmap bitmap = nine_patch_layer_image_.GetRepresentation( | |
627 device_scale_factor_).sk_bitmap(); | |
625 SkBitmap bitmap_copy; | 628 SkBitmap bitmap_copy; |
626 if (bitmap.isImmutable()) { | 629 if (bitmap.isImmutable()) { |
627 bitmap_copy = bitmap; | 630 bitmap_copy = bitmap; |
628 } else { | 631 } else { |
629 // UIResourceBitmap requires an immutable copy of the input |bitmap|. | 632 // UIResourceBitmap requires an immutable copy of the input |bitmap|. |
630 bitmap.copyTo(&bitmap_copy); | 633 bitmap.copyTo(&bitmap_copy); |
631 bitmap_copy.setImmutable(); | 634 bitmap_copy.setImmutable(); |
632 } | 635 } |
633 nine_patch_layer_->SetBitmap(bitmap_copy); | 636 nine_patch_layer_->SetBitmap(bitmap_copy); |
634 } | 637 } |
635 | 638 |
636 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture) { | 639 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture) { |
637 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 640 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
638 nine_patch_layer_->SetAperture(aperture); | 641 nine_patch_layer_aperture_ = aperture; |
danakj
2015/03/17 17:59:40
can you add "in_dip" to this variable name?
hshi1
2015/03/17 18:24:48
Done.
| |
642 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture); | |
643 nine_patch_layer_->SetAperture(aperture_in_pixel); | |
639 } | 644 } |
640 | 645 |
641 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { | 646 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { |
642 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 647 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
643 nine_patch_layer_->SetBorder(border); | 648 nine_patch_layer_->SetBorder(border); |
644 } | 649 } |
645 | 650 |
646 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 651 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
647 | 652 |
648 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 653 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 device_scale_factor_ = device_scale_factor; | 714 device_scale_factor_ = device_scale_factor; |
710 RecomputeDrawsContentAndUVRect(); | 715 RecomputeDrawsContentAndUVRect(); |
711 RecomputePosition(); | 716 RecomputePosition(); |
712 SchedulePaint(gfx::Rect(bounds_.size())); | 717 SchedulePaint(gfx::Rect(bounds_.size())); |
713 if (delegate_) | 718 if (delegate_) |
714 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); | 719 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); |
715 for (size_t i = 0; i < children_.size(); ++i) | 720 for (size_t i = 0; i < children_.size(); ++i) |
716 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); | 721 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); |
717 if (layer_mask_) | 722 if (layer_mask_) |
718 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); | 723 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); |
724 if (nine_patch_layer_) { | |
725 UpdateNinePatchLayerImage(nine_patch_layer_image_); | |
danakj
2015/03/17 17:59:40
Can you move these up by RecomputeDrwasContentAndU
hshi1
2015/03/17 18:24:48
Done.
| |
726 UpdateNinePatchLayerAperture(nine_patch_layer_aperture_); | |
727 } | |
719 } | 728 } |
720 | 729 |
721 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 730 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
722 DCHECK(delegated_renderer_layer_.get() || surface_layer_.get()); | 731 DCHECK(delegated_renderer_layer_.get() || surface_layer_.get()); |
723 if (!delegate_) | 732 if (!delegate_) |
724 return; | 733 return; |
725 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); | 734 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); |
726 } | 735 } |
727 | 736 |
728 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { | 737 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 children_.end(), | 1080 children_.end(), |
1072 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1081 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
1073 collection)); | 1082 collection)); |
1074 } | 1083 } |
1075 | 1084 |
1076 bool Layer::IsAnimating() const { | 1085 bool Layer::IsAnimating() const { |
1077 return animator_.get() && animator_->is_animating(); | 1086 return animator_.get() && animator_->is_animating(); |
1078 } | 1087 } |
1079 | 1088 |
1080 } // namespace ui | 1089 } // namespace ui |
OLD | NEW |