| 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 // 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_id().is_valid()) { |
| 185 clone->SetShowSurface( | 185 clone->SetShowSurface(surface_layer_->surface_emb()->Clone(), |
| 186 surface_layer_->surface_id(), | 186 frame_size_in_dip_); |
| 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(cc::SurfaceEmbeddingPtr surface_ref, |
| 661 const cc::SurfaceId& surface_id, | 656 gfx::Size frame_size_in_dip) { |
| 662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, | |
| 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); | 657 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); |
| 668 | 658 |
| 669 scoped_refptr<cc::SurfaceLayer> new_layer = | 659 scoped_refptr<cc::SurfaceLayer> new_layer = |
| 670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 660 cc::SurfaceLayer::Create(surface_ref->Clone()); |
| 671 new_layer->SetSurfaceId(surface_id, scale, surface_size); | |
| 672 SwitchToLayer(new_layer); | 661 SwitchToLayer(new_layer); |
| 673 surface_layer_ = new_layer; | 662 surface_layer_ = new_layer; |
| 674 | 663 |
| 675 frame_size_in_dip_ = frame_size_in_dip; | 664 frame_size_in_dip_ = frame_size_in_dip; |
| 676 RecomputeDrawsContentAndUVRect(); | 665 RecomputeDrawsContentAndUVRect(); |
| 677 | 666 |
| 678 for (const auto& mirror : mirrors_) { | 667 for (const auto& mirror : mirrors_) { |
| 679 mirror->dest()->SetShowSurface( | 668 mirror->dest()->SetShowSurface(surface_ref->Clone(), frame_size_in_dip); |
| 680 surface_id, satisfy_callback, require_callback, | |
| 681 surface_size, scale, frame_size_in_dip); | |
| 682 } | 669 } |
| 683 } | 670 } |
| 684 | 671 |
| 685 void Layer::SetShowSolidColorContent() { | 672 void Layer::SetShowSolidColorContent() { |
| 686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 673 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 687 | 674 |
| 688 if (solid_color_layer_.get()) | 675 if (solid_color_layer_.get()) |
| 689 return; | 676 return; |
| 690 | 677 |
| 691 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 678 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(), | 1162 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), |
| 1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { | 1163 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { |
| 1177 return mirror_ptr.get() == mirror; | 1164 return mirror_ptr.get() == mirror; |
| 1178 }); | 1165 }); |
| 1179 | 1166 |
| 1180 DCHECK(it != mirrors_.end()); | 1167 DCHECK(it != mirrors_.end()); |
| 1181 mirrors_.erase(it); | 1168 mirrors_.erase(it); |
| 1182 } | 1169 } |
| 1183 | 1170 |
| 1184 } // namespace ui | 1171 } // namespace ui |
| OLD | NEW |