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