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

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

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: rebase 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
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 false /* stretch_content_to_fill_bounds */); 664 false /* stretch_content_to_fill_bounds */);
670 SwitchToLayer(new_layer); 665 SwitchToLayer(new_layer);
671 surface_layer_ = new_layer; 666 surface_layer_ = new_layer;
672 667
673 frame_size_in_dip_ = gfx::ConvertSizeToDIP(scale, surface_size_in_pixels); 668 frame_size_in_dip_ = gfx::ConvertSizeToDIP(surface_info.device_scale_factor(),
669 surface_info.size_in_pixels());
674 RecomputeDrawsContentAndUVRect(); 670 RecomputeDrawsContentAndUVRect();
675 671
676 for (const auto& mirror : mirrors_) { 672 for (const auto& mirror : mirrors_) {
677 mirror->dest()->SetShowSurface(surface_id, satisfy_callback, 673 mirror->dest()->SetShowSurface(surface_info, ref_factory);
678 require_callback, surface_size_in_pixels,
679 scale);
680 } 674 }
681 } 675 }
682 676
683 void Layer::SetShowSolidColorContent() { 677 void Layer::SetShowSolidColorContent() {
684 DCHECK_EQ(type_, LAYER_SOLID_COLOR); 678 DCHECK_EQ(type_, LAYER_SOLID_COLOR);
685 679
686 if (solid_color_layer_.get()) 680 if (solid_color_layer_.get())
687 return; 681 return;
688 682
689 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
1173 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1167 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1174 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1168 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1175 return mirror_ptr.get() == mirror; 1169 return mirror_ptr.get() == mirror;
1176 }); 1170 });
1177 1171
1178 DCHECK(it != mirrors_.end()); 1172 DCHECK(it != mirrors_.end());
1179 mirrors_.erase(it); 1173 mirrors_.erase(it);
1180 } 1174 }
1181 1175
1182 } // namespace ui 1176 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698