| 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::SetShowNinePatch() { |
| 588 if (nine_patch_layer_.get()) |
| 589 return; |
| 590 |
| 591 scoped_refptr<cc::NinePatchLayer> new_layer = cc::NinePatchLayer::Create(); |
| 592 SetFillsBoundsOpaquely(false); |
| 593 |
| 594 SwitchToLayer(new_layer); |
| 595 nine_patch_layer_ = new_layer; |
| 596 } |
| 597 |
| 598 void Layer::UpdateNinePatchBitmap(const SkBitmap& bitmap, |
| 599 const gfx::Rect& aperture, |
| 600 const gfx::Rect& border) { |
| 601 if (!nine_patch_layer_.get()) |
| 602 return; |
| 603 |
| 604 nine_patch_layer_->SetBitmap(bitmap); |
| 605 nine_patch_layer_->SetAperture(aperture); |
| 606 nine_patch_layer_->SetBorder(border); |
| 607 } |
| 608 |
| 586 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 609 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
| 587 | 610 |
| 588 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 611 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
| 589 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !mailbox_.IsValid())) | 612 if (type_ == LAYER_SOLID_COLOR || (!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(), |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 children_.end(), | 1011 children_.end(), |
| 989 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1012 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
| 990 collection)); | 1013 collection)); |
| 991 } | 1014 } |
| 992 | 1015 |
| 993 bool Layer::IsAnimating() const { | 1016 bool Layer::IsAnimating() const { |
| 994 return animator_ && animator_->is_animating(); | 1017 return animator_ && animator_->is_animating(); |
| 995 } | 1018 } |
| 996 | 1019 |
| 997 } // namespace ui | 1020 } // namespace ui |
| OLD | NEW |