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 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 // Filters. | 175 // Filters. |
176 clone->SetLayerSaturation(layer_saturation_); | 176 clone->SetLayerSaturation(layer_saturation_); |
177 clone->SetLayerBrightness(GetTargetBrightness()); | 177 clone->SetLayerBrightness(GetTargetBrightness()); |
178 clone->SetLayerGrayscale(GetTargetGrayscale()); | 178 clone->SetLayerGrayscale(GetTargetGrayscale()); |
179 clone->SetLayerInverted(layer_inverted_); | 179 clone->SetLayerInverted(layer_inverted_); |
180 if (alpha_shape_) | 180 if (alpha_shape_) |
181 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); | 181 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); |
182 | 182 |
183 // cc::Layer state. | 183 // cc::Layer state. |
184 if (surface_layer_ && surface_layer_->surface_id().is_valid()) { | 184 if (surface_layer_ && surface_layer_->surface_info().id().is_valid()) { |
185 clone->SetShowSurface( | 185 clone->SetShowSurface(surface_layer_->surface_info(), |
186 surface_layer_->surface_id(), | 186 surface_layer_->surface_reference_factory(), |
187 surface_layer_->satisfy_callback(), | 187 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) { | 188 } else if (type_ == LAYER_SOLID_COLOR) { |
193 clone->SetColor(GetTargetColor()); | 189 clone->SetColor(GetTargetColor()); |
194 } | 190 } |
195 return clone; | 191 return clone; |
196 } | 192 } |
197 | 193 |
198 std::unique_ptr<Layer> Layer::Mirror() { | 194 std::unique_ptr<Layer> Layer::Mirror() { |
199 auto mirror = Clone(); | 195 auto mirror = Clone(); |
200 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); | 196 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); |
201 return mirror; | 197 return mirror; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 DCHECK(texture_layer_.get()); | 647 DCHECK(texture_layer_.get()); |
652 texture_layer_->SetFlipped(flipped); | 648 texture_layer_->SetFlipped(flipped); |
653 } | 649 } |
654 | 650 |
655 bool Layer::TextureFlipped() const { | 651 bool Layer::TextureFlipped() const { |
656 DCHECK(texture_layer_.get()); | 652 DCHECK(texture_layer_.get()); |
657 return texture_layer_->flipped(); | 653 return texture_layer_->flipped(); |
658 } | 654 } |
659 | 655 |
660 void Layer::SetShowSurface( | 656 void Layer::SetShowSurface( |
661 const cc::SurfaceId& surface_id, | 657 const cc::SurfaceInfo& surface_info, |
662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, | 658 scoped_refptr<cc::SurfaceReferenceFactory> ref_factory, |
663 const cc::SurfaceLayer::RequireCallback& require_callback, | |
664 gfx::Size surface_size, | |
665 float scale, | |
666 gfx::Size frame_size_in_dip) { | 659 gfx::Size frame_size_in_dip) { |
667 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); | 660 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); |
668 | 661 |
669 scoped_refptr<cc::SurfaceLayer> new_layer = | 662 scoped_refptr<cc::SurfaceLayer> new_layer = |
670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 663 cc::SurfaceLayer::Create(ref_factory); |
671 new_layer->SetSurfaceId(surface_id, scale, surface_size); | 664 new_layer->SetSurfaceInfo(surface_info); |
672 SwitchToLayer(new_layer); | 665 SwitchToLayer(new_layer); |
673 surface_layer_ = new_layer; | 666 surface_layer_ = new_layer; |
674 | 667 |
675 frame_size_in_dip_ = frame_size_in_dip; | 668 frame_size_in_dip_ = frame_size_in_dip; |
676 RecomputeDrawsContentAndUVRect(); | 669 RecomputeDrawsContentAndUVRect(); |
677 | 670 |
678 for (const auto& mirror : mirrors_) { | 671 for (const auto& mirror : mirrors_) { |
679 mirror->dest()->SetShowSurface( | 672 mirror->dest()->SetShowSurface(surface_info, ref_factory, |
680 surface_id, satisfy_callback, require_callback, | 673 frame_size_in_dip); |
681 surface_size, scale, frame_size_in_dip); | |
682 } | 674 } |
683 } | 675 } |
684 | 676 |
685 void Layer::SetShowSolidColorContent() { | 677 void Layer::SetShowSolidColorContent() { |
686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 678 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
687 | 679 |
688 if (solid_color_layer_.get()) | 680 if (solid_color_layer_.get()) |
689 return; | 681 return; |
690 | 682 |
691 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 683 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(), | 1167 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { | 1168 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
1177 return mirror_ptr.get() == mirror; | 1169 return mirror_ptr.get() == mirror; |
1178 }); | 1170 }); |
1179 | 1171 |
1180 DCHECK(it != mirrors_.end()); | 1172 DCHECK(it != mirrors_.end()); |
1181 mirrors_.erase(it); | 1173 mirrors_.erase(it); |
1182 } | 1174 } |
1183 | 1175 |
1184 } // namespace ui | 1176 } // namespace ui |
OLD | NEW |