| 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 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "cc/layers/nine_patch_layer.h" | 17 #include "cc/layers/nine_patch_layer.h" |
| 18 #include "cc/layers/picture_layer.h" | 18 #include "cc/layers/picture_layer.h" |
| 19 #include "cc/layers/solid_color_layer.h" | 19 #include "cc/layers/solid_color_layer.h" |
| 20 #include "cc/layers/surface_layer.h" | 20 #include "cc/layers/surface_layer.h" |
| 21 #include "cc/layers/texture_layer.h" | 21 #include "cc/layers/texture_layer.h" |
| 22 #include "cc/output/copy_output_request.h" | 22 #include "cc/output/copy_output_request.h" |
| 23 #include "cc/output/filter_operation.h" | 23 #include "cc/output/filter_operation.h" |
| 24 #include "cc/output/filter_operations.h" | 24 #include "cc/output/filter_operations.h" |
| 25 #include "cc/playback/display_item_list_settings.h" | 25 #include "cc/playback/display_item_list_settings.h" |
| 26 #include "cc/resources/transferable_resource.h" | 26 #include "cc/resources/transferable_resource.h" |
| 27 #include "cc/surfaces/surface_info.h" |
| 27 #include "cc/trees/layer_tree_settings.h" | 28 #include "cc/trees/layer_tree_settings.h" |
| 28 #include "ui/compositor/compositor_switches.h" | 29 #include "ui/compositor/compositor_switches.h" |
| 29 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
| 30 #include "ui/compositor/layer_animator.h" | 31 #include "ui/compositor/layer_animator.h" |
| 31 #include "ui/compositor/layer_observer.h" | 32 #include "ui/compositor/layer_observer.h" |
| 32 #include "ui/compositor/paint_context.h" | 33 #include "ui/compositor/paint_context.h" |
| 33 #include "ui/gfx/animation/animation.h" | 34 #include "ui/gfx/animation/animation.h" |
| 34 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 35 #include "ui/gfx/geometry/point3_f.h" | 36 #include "ui/gfx/geometry/point3_f.h" |
| 36 #include "ui/gfx/geometry/point_conversions.h" | 37 #include "ui/gfx/geometry/point_conversions.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 clone->SetLayerSaturation(layer_saturation_); | 177 clone->SetLayerSaturation(layer_saturation_); |
| 177 clone->SetLayerBrightness(GetTargetBrightness()); | 178 clone->SetLayerBrightness(GetTargetBrightness()); |
| 178 clone->SetLayerGrayscale(GetTargetGrayscale()); | 179 clone->SetLayerGrayscale(GetTargetGrayscale()); |
| 179 clone->SetLayerInverted(layer_inverted_); | 180 clone->SetLayerInverted(layer_inverted_); |
| 180 if (alpha_shape_) | 181 if (alpha_shape_) |
| 181 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); | 182 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); |
| 182 | 183 |
| 183 // cc::Layer state. | 184 // cc::Layer state. |
| 184 if (surface_layer_ && surface_layer_->surface_id().is_valid()) { | 185 if (surface_layer_ && surface_layer_->surface_id().is_valid()) { |
| 185 clone->SetShowSurface( | 186 clone->SetShowSurface( |
| 186 surface_layer_->surface_id(), | 187 surface_layer_->surface_info(), surface_layer_->satisfy_callback(), |
| 187 surface_layer_->satisfy_callback(), | 188 surface_layer_->require_callback(), frame_size_in_dip_); |
| 188 surface_layer_->require_callback(), | |
| 189 surface_layer_->surface_size(), | |
| 190 surface_layer_->surface_scale(), | |
| 191 frame_size_in_dip_); | |
| 192 } else if (type_ == LAYER_SOLID_COLOR) { | 189 } else if (type_ == LAYER_SOLID_COLOR) { |
| 193 clone->SetColor(GetTargetColor()); | 190 clone->SetColor(GetTargetColor()); |
| 194 } | 191 } |
| 195 return clone; | 192 return clone; |
| 196 } | 193 } |
| 197 | 194 |
| 198 std::unique_ptr<Layer> Layer::Mirror() { | 195 std::unique_ptr<Layer> Layer::Mirror() { |
| 199 auto mirror = Clone(); | 196 auto mirror = Clone(); |
| 200 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); | 197 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); |
| 201 return mirror; | 198 return mirror; |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 DCHECK(texture_layer_.get()); | 648 DCHECK(texture_layer_.get()); |
| 652 texture_layer_->SetFlipped(flipped); | 649 texture_layer_->SetFlipped(flipped); |
| 653 } | 650 } |
| 654 | 651 |
| 655 bool Layer::TextureFlipped() const { | 652 bool Layer::TextureFlipped() const { |
| 656 DCHECK(texture_layer_.get()); | 653 DCHECK(texture_layer_.get()); |
| 657 return texture_layer_->flipped(); | 654 return texture_layer_->flipped(); |
| 658 } | 655 } |
| 659 | 656 |
| 660 void Layer::SetShowSurface( | 657 void Layer::SetShowSurface( |
| 661 const cc::SurfaceId& surface_id, | 658 const cc::SurfaceInfo& surface_info, |
| 662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, | 659 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, |
| 663 const cc::SurfaceLayer::RequireCallback& require_callback, | 660 const cc::SurfaceLayer::RequireCallback& require_callback, |
| 664 gfx::Size surface_size, | |
| 665 float scale, | |
| 666 gfx::Size frame_size_in_dip) { | 661 gfx::Size frame_size_in_dip) { |
| 667 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); | 662 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); |
| 668 | 663 |
| 669 scoped_refptr<cc::SurfaceLayer> new_layer = | 664 scoped_refptr<cc::SurfaceLayer> new_layer = |
| 670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 665 cc::SurfaceLayer::Create(satisfy_callback, require_callback); |
| 671 new_layer->SetSurfaceId(surface_id, scale, surface_size); | 666 new_layer->SetSurfaceInfo(surface_info); |
| 672 SwitchToLayer(new_layer); | 667 SwitchToLayer(new_layer); |
| 673 surface_layer_ = new_layer; | 668 surface_layer_ = new_layer; |
| 674 | 669 |
| 675 frame_size_in_dip_ = frame_size_in_dip; | 670 frame_size_in_dip_ = frame_size_in_dip; |
| 676 RecomputeDrawsContentAndUVRect(); | 671 RecomputeDrawsContentAndUVRect(); |
| 677 | 672 |
| 678 for (const auto& mirror : mirrors_) { | 673 for (const auto& mirror : mirrors_) { |
| 679 mirror->dest()->SetShowSurface( | 674 mirror->dest()->SetShowSurface(surface_info, satisfy_callback, |
| 680 surface_id, satisfy_callback, require_callback, | 675 require_callback, frame_size_in_dip); |
| 681 surface_size, scale, frame_size_in_dip); | |
| 682 } | 676 } |
| 683 } | 677 } |
| 684 | 678 |
| 685 void Layer::SetShowSolidColorContent() { | 679 void Layer::SetShowSolidColorContent() { |
| 686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 680 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 687 | 681 |
| 688 if (solid_color_layer_.get()) | 682 if (solid_color_layer_.get()) |
| 689 return; | 683 return; |
| 690 | 684 |
| 691 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 685 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), | 1169 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
| 1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { | 1170 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
| 1177 return mirror_ptr.get() == mirror; | 1171 return mirror_ptr.get() == mirror; |
| 1178 }); | 1172 }); |
| 1179 | 1173 |
| 1180 DCHECK(it != mirrors_.end()); | 1174 DCHECK(it != mirrors_.end()); |
| 1181 mirrors_.erase(it); | 1175 mirrors_.erase(it); |
| 1182 } | 1176 } |
| 1183 | 1177 |
| 1184 } // namespace ui | 1178 } // namespace ui |
| OLD | NEW |