| 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/picture_layer.h" |
| 17 #include "cc/layers/solid_color_layer.h" | 18 #include "cc/layers/solid_color_layer.h" |
| 18 #include "cc/layers/texture_layer.h" | 19 #include "cc/layers/texture_layer.h" |
| 19 #include "cc/output/copy_output_request.h" | 20 #include "cc/output/copy_output_request.h" |
| 20 #include "cc/output/delegated_frame_data.h" | 21 #include "cc/output/delegated_frame_data.h" |
| 21 #include "cc/output/filter_operation.h" | 22 #include "cc/output/filter_operation.h" |
| 22 #include "cc/output/filter_operations.h" | 23 #include "cc/output/filter_operations.h" |
| 23 #include "cc/resources/transferable_resource.h" | 24 #include "cc/resources/transferable_resource.h" |
| 24 #include "ui/compositor/compositor_switches.h" | 25 #include "ui/compositor/compositor_switches.h" |
| 25 #include "ui/compositor/dip_util.h" | 26 #include "ui/compositor/dip_util.h" |
| 26 #include "ui/compositor/layer_animator.h" | 27 #include "ui/compositor/layer_animator.h" |
| 27 #include "ui/gfx/animation/animation.h" | 28 #include "ui/gfx/animation/animation.h" |
| 28 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| 29 #include "ui/gfx/display.h" | 30 #include "ui/gfx/display.h" |
| 30 #include "ui/gfx/interpolated_transform.h" | 31 #include "ui/gfx/interpolated_transform.h" |
| 31 #include "ui/gfx/point3_f.h" | 32 #include "ui/gfx/point3_f.h" |
| 32 #include "ui/gfx/point_conversions.h" | 33 #include "ui/gfx/point_conversions.h" |
| 33 #include "ui/gfx/size_conversions.h" | 34 #include "ui/gfx/size_conversions.h" |
| 34 | 35 |
| 36 extern char GetZCopy(); |
| 37 |
| 35 namespace { | 38 namespace { |
| 36 | 39 |
| 37 const ui::Layer* GetRoot(const ui::Layer* layer) { | 40 const ui::Layer* GetRoot(const ui::Layer* layer) { |
| 38 while (layer->parent()) | 41 while (layer->parent()) |
| 39 layer = layer->parent(); | 42 layer = layer->parent(); |
| 40 return layer; | 43 return layer; |
| 41 } | 44 } |
| 42 | 45 |
| 43 } // namespace | 46 } // namespace |
| 44 | 47 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 465 } |
| 463 cc_layer_->SetLayerClient(this); | 466 cc_layer_->SetLayerClient(this); |
| 464 cc_layer_->SetAnchorPoint(gfx::PointF()); | 467 cc_layer_->SetAnchorPoint(gfx::PointF()); |
| 465 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); | 468 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); |
| 466 cc_layer_->SetForceRenderSurface(force_render_surface_); | 469 cc_layer_->SetForceRenderSurface(force_render_surface_); |
| 467 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 470 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
| 468 cc_layer_->SetHideLayerAndSubtree(!visible_); | 471 cc_layer_->SetHideLayerAndSubtree(!visible_); |
| 469 } | 472 } |
| 470 | 473 |
| 471 void Layer::SwitchCCLayerForTest() { | 474 void Layer::SwitchCCLayerForTest() { |
| 472 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); | 475 scoped_refptr<cc::Layer> new_layer; |
| 476 if (GetZCopy()) |
| 477 new_layer = cc::PictureLayer::Create(this); |
| 478 else |
| 479 new_layer = cc::ContentLayer::Create(this); |
| 473 SwitchToLayer(new_layer); | 480 SwitchToLayer(new_layer); |
| 474 content_layer_ = new_layer; | 481 content_layer_ = new_layer; |
| 475 } | 482 } |
| 476 | 483 |
| 477 void Layer::SetExternalTexture(Texture* texture) { | 484 void Layer::SetExternalTexture(Texture* texture) { |
| 478 DCHECK(texture); | 485 DCHECK(texture); |
| 479 | 486 |
| 480 // Hold a ref to the old |Texture| until we have updated all | 487 // Hold a ref to the old |Texture| until we have updated all |
| 481 // compositor references to the texture id that it holds. | 488 // compositor references to the texture id that it holds. |
| 482 scoped_refptr<ui::Texture> old_texture = texture_; | 489 scoped_refptr<ui::Texture> old_texture = texture_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 delegated_renderer_layer_ = new_layer; | 536 delegated_renderer_layer_ = new_layer; |
| 530 | 537 |
| 531 delegated_frame_size_in_dip_ = frame_size_in_dip; | 538 delegated_frame_size_in_dip_ = frame_size_in_dip; |
| 532 RecomputeDrawsContentAndUVRect(); | 539 RecomputeDrawsContentAndUVRect(); |
| 533 } | 540 } |
| 534 | 541 |
| 535 void Layer::SetShowPaintedContent() { | 542 void Layer::SetShowPaintedContent() { |
| 536 if (content_layer_.get()) | 543 if (content_layer_.get()) |
| 537 return; | 544 return; |
| 538 | 545 |
| 539 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); | 546 scoped_refptr<cc::Layer> new_layer; |
| 547 if (GetZCopy()) |
| 548 new_layer = cc::PictureLayer::Create(this); |
| 549 else |
| 550 new_layer = cc::ContentLayer::Create(this); |
| 540 SwitchToLayer(new_layer); | 551 SwitchToLayer(new_layer); |
| 541 content_layer_ = new_layer; | 552 content_layer_ = new_layer; |
| 542 | 553 |
| 543 mailbox_ = cc::TextureMailbox(); | 554 mailbox_ = cc::TextureMailbox(); |
| 544 texture_ = NULL; | 555 texture_ = NULL; |
| 545 | 556 |
| 546 RecomputeDrawsContentAndUVRect(); | 557 RecomputeDrawsContentAndUVRect(); |
| 547 } | 558 } |
| 548 | 559 |
| 549 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 560 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 886 |
| 876 for (size_t i = 0; i < children_.size(); ++i) | 887 for (size_t i = 0; i < children_.size(); ++i) |
| 877 children_[i]->SendPendingThreadedAnimations(); | 888 children_[i]->SendPendingThreadedAnimations(); |
| 878 } | 889 } |
| 879 | 890 |
| 880 void Layer::CreateWebLayer() { | 891 void Layer::CreateWebLayer() { |
| 881 if (type_ == LAYER_SOLID_COLOR) { | 892 if (type_ == LAYER_SOLID_COLOR) { |
| 882 solid_color_layer_ = cc::SolidColorLayer::Create(); | 893 solid_color_layer_ = cc::SolidColorLayer::Create(); |
| 883 cc_layer_ = solid_color_layer_.get(); | 894 cc_layer_ = solid_color_layer_.get(); |
| 884 } else { | 895 } else { |
| 885 content_layer_ = cc::ContentLayer::Create(this); | 896 if (GetZCopy()) |
| 897 content_layer_ = cc::PictureLayer::Create(this); |
| 898 else |
| 899 content_layer_ = cc::ContentLayer::Create(this); |
| 886 cc_layer_ = content_layer_.get(); | 900 cc_layer_ = content_layer_.get(); |
| 887 } | 901 } |
| 888 cc_layer_->SetAnchorPoint(gfx::PointF()); | 902 cc_layer_->SetAnchorPoint(gfx::PointF()); |
| 889 cc_layer_->SetContentsOpaque(true); | 903 cc_layer_->SetContentsOpaque(true); |
| 890 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 904 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
| 891 cc_layer_->AddLayerAnimationEventObserver(this); | 905 cc_layer_->AddLayerAnimationEventObserver(this); |
| 892 cc_layer_->SetLayerClient(this); | 906 cc_layer_->SetLayerClient(this); |
| 893 RecomputePosition(); | 907 RecomputePosition(); |
| 894 } | 908 } |
| 895 | 909 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 951 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
| 938 } | 952 } |
| 939 | 953 |
| 940 void Layer::RecomputePosition() { | 954 void Layer::RecomputePosition() { |
| 941 cc_layer_->SetPosition(gfx::ScalePoint( | 955 cc_layer_->SetPosition(gfx::ScalePoint( |
| 942 gfx::PointF(bounds_.x(), bounds_.y()), | 956 gfx::PointF(bounds_.x(), bounds_.y()), |
| 943 device_scale_factor_)); | 957 device_scale_factor_)); |
| 944 } | 958 } |
| 945 | 959 |
| 946 } // namespace ui | 960 } // namespace ui |
| OLD | NEW |