Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: ui/compositor/layer.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: up Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_);
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
661 const cc::SurfaceId& surface_id, 656 const cc::SurfaceInfo& surface_info,
662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, 657 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) { 658 gfx::Size frame_size_in_dip) {
667 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); 659 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
668 660
669 scoped_refptr<cc::SurfaceLayer> new_layer = 661 scoped_refptr<cc::SurfaceLayer> new_layer =
670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); 662 cc::SurfaceLayer::Create(ref_factory);
671 new_layer->SetSurfaceId(surface_id, scale, surface_size); 663 new_layer->SetSurfaceInfo(surface_info);
672 SwitchToLayer(new_layer); 664 SwitchToLayer(new_layer);
673 surface_layer_ = new_layer; 665 surface_layer_ = new_layer;
674 666
675 frame_size_in_dip_ = frame_size_in_dip; 667 frame_size_in_dip_ = frame_size_in_dip;
676 RecomputeDrawsContentAndUVRect(); 668 RecomputeDrawsContentAndUVRect();
677 669
678 for (const auto& mirror : mirrors_) { 670 for (const auto& mirror : mirrors_) {
679 mirror->dest()->SetShowSurface( 671 mirror->dest()->SetShowSurface(surface_info, ref_factory,
680 surface_id, satisfy_callback, require_callback, 672 frame_size_in_dip);
681 surface_size, scale, frame_size_in_dip);
682 } 673 }
683 } 674 }
684 675
685 void Layer::SetShowSolidColorContent() { 676 void Layer::SetShowSolidColorContent() {
686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); 677 DCHECK_EQ(type_, LAYER_SOLID_COLOR);
687 678
688 if (solid_color_layer_.get()) 679 if (solid_color_layer_.get())
689 return; 680 return;
690 681
691 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
1175 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1166 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1167 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1177 return mirror_ptr.get() == mirror; 1168 return mirror_ptr.get() == mirror;
1178 }); 1169 });
1179 1170
1180 DCHECK(it != mirrors_.end()); 1171 DCHECK(it != mirrors_.end());
1181 mirrors_.erase(it); 1172 mirrors_.erase(it);
1182 } 1173 }
1183 1174
1184 } // namespace ui 1175 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698