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_->ref_factory(), frame_size_in_dip_); |
Fady Samuel
2016/12/12 16:25:07
Being explicit seems useful here: surface_referenc
| |
187 surface_layer_->satisfy_callback(), | |
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) { | 187 } else if (type_ == LAYER_SOLID_COLOR) { |
193 clone->SetColor(GetTargetColor()); | 188 clone->SetColor(GetTargetColor()); |
194 } | 189 } |
195 return clone; | 190 return clone; |
196 } | 191 } |
197 | 192 |
198 std::unique_ptr<Layer> Layer::Mirror() { | 193 std::unique_ptr<Layer> Layer::Mirror() { |
199 auto mirror = Clone(); | 194 auto mirror = Clone(); |
200 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); | 195 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); |
201 return mirror; | 196 return mirror; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 void Layer::SetTextureFlipped(bool flipped) { | 645 void Layer::SetTextureFlipped(bool flipped) { |
651 DCHECK(texture_layer_.get()); | 646 DCHECK(texture_layer_.get()); |
652 texture_layer_->SetFlipped(flipped); | 647 texture_layer_->SetFlipped(flipped); |
653 } | 648 } |
654 | 649 |
655 bool Layer::TextureFlipped() const { | 650 bool Layer::TextureFlipped() const { |
656 DCHECK(texture_layer_.get()); | 651 DCHECK(texture_layer_.get()); |
657 return texture_layer_->flipped(); | 652 return texture_layer_->flipped(); |
658 } | 653 } |
659 | 654 |
660 void Layer::SetShowSurface( | 655 void Layer::SetShowSurface(const cc::SurfaceInfo& surface_info, |
661 const cc::SurfaceId& surface_id, | 656 cc::SurfaceEmbeddingPtr surface_ref, |
662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, | 657 gfx::Size frame_size_in_dip) { |
663 const cc::SurfaceLayer::RequireCallback& require_callback, | |
664 gfx::Size surface_size, | |
665 float scale, | |
666 gfx::Size frame_size_in_dip) { | |
667 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); | 658 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); |
668 | 659 |
669 scoped_refptr<cc::SurfaceLayer> new_layer = | 660 scoped_refptr<cc::SurfaceLayer> new_layer = |
670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 661 cc::SurfaceLayer::Create(surface_ref); |
671 new_layer->SetSurfaceId(surface_id, scale, surface_size); | 662 new_layer->SetSurfaceInfo(surface_info); |
672 SwitchToLayer(new_layer); | 663 SwitchToLayer(new_layer); |
673 surface_layer_ = new_layer; | 664 surface_layer_ = new_layer; |
674 | 665 |
675 frame_size_in_dip_ = frame_size_in_dip; | 666 frame_size_in_dip_ = frame_size_in_dip; |
676 RecomputeDrawsContentAndUVRect(); | 667 RecomputeDrawsContentAndUVRect(); |
677 | 668 |
678 for (const auto& mirror : mirrors_) { | 669 for (const auto& mirror : mirrors_) { |
679 mirror->dest()->SetShowSurface( | 670 mirror->dest()->SetShowSurface(surface_info, surface_ref, |
680 surface_id, satisfy_callback, require_callback, | 671 frame_size_in_dip); |
681 surface_size, scale, frame_size_in_dip); | |
682 } | 672 } |
683 } | 673 } |
684 | 674 |
685 void Layer::SetShowSolidColorContent() { | 675 void Layer::SetShowSolidColorContent() { |
686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 676 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
687 | 677 |
688 if (solid_color_layer_.get()) | 678 if (solid_color_layer_.get()) |
689 return; | 679 return; |
690 | 680 |
691 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 681 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(), | 1165 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { | 1166 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
1177 return mirror_ptr.get() == mirror; | 1167 return mirror_ptr.get() == mirror; |
1178 }); | 1168 }); |
1179 | 1169 |
1180 DCHECK(it != mirrors_.end()); | 1170 DCHECK(it != mirrors_.end()); |
1181 mirrors_.erase(it); | 1171 mirrors_.erase(it); |
1182 } | 1172 } |
1183 | 1173 |
1184 } // namespace ui | 1174 } // namespace ui |
OLD | NEW |