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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 months 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 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_info().id().is_valid()) { 185 if (surface_layer_ &&
186 clone->SetShowSurface(surface_layer_->surface_info(), 186 surface_layer_->primary_surface_info().id().is_valid()) {
187 clone->SetShowSurface(surface_layer_->primary_surface_info(),
187 surface_layer_->surface_reference_factory()); 188 surface_layer_->surface_reference_factory());
188 } else if (type_ == LAYER_SOLID_COLOR) { 189 } else if (type_ == LAYER_SOLID_COLOR) {
189 clone->SetColor(GetTargetColor()); 190 clone->SetColor(GetTargetColor());
190 } 191 }
191 return clone; 192 return clone;
192 } 193 }
193 194
194 std::unique_ptr<Layer> Layer::Mirror() { 195 std::unique_ptr<Layer> Layer::Mirror() {
195 auto mirror = Clone(); 196 auto mirror = Clone();
196 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); 197 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get()));
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 650 }
650 651
651 bool Layer::TextureFlipped() const { 652 bool Layer::TextureFlipped() const {
652 DCHECK(texture_layer_.get()); 653 DCHECK(texture_layer_.get());
653 return texture_layer_->flipped(); 654 return texture_layer_->flipped();
654 } 655 }
655 656
656 void Layer::SetShowSurface( 657 void Layer::SetShowSurface(
657 const cc::SurfaceInfo& surface_info, 658 const cc::SurfaceInfo& surface_info,
658 scoped_refptr<cc::SurfaceReferenceFactory> ref_factory) { 659 scoped_refptr<cc::SurfaceReferenceFactory> ref_factory) {
659 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); 660 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR ||
661 type_ == LAYER_SURFACE);
660 662
661 scoped_refptr<cc::SurfaceLayer> new_layer = 663 if (!surface_layer_) {
662 cc::SurfaceLayer::Create(ref_factory); 664 scoped_refptr<cc::SurfaceLayer> new_layer =
663 new_layer->SetSurfaceInfo(surface_info); 665 cc::SurfaceLayer::Create(ref_factory);
664 SwitchToLayer(new_layer); 666 SwitchToLayer(new_layer);
665 surface_layer_ = new_layer; 667 surface_layer_ = new_layer;
668 }
669 surface_layer_->SwapSurfaceInfo(surface_info);
666 670
667 frame_size_in_dip_ = gfx::ConvertSizeToDIP(surface_info.device_scale_factor(), 671 frame_size_in_dip_ = gfx::ConvertSizeToDIP(surface_info.device_scale_factor(),
668 surface_info.size_in_pixels()); 672 surface_info.size_in_pixels());
669 RecomputeDrawsContentAndUVRect(); 673 RecomputeDrawsContentAndUVRect();
670 674
671 for (const auto& mirror : mirrors_) { 675 for (const auto& mirror : mirrors_) {
672 mirror->dest()->SetShowSurface(surface_info, ref_factory); 676 mirror->dest()->SetShowSurface(surface_info, ref_factory);
673 } 677 }
674 } 678 }
675 679
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 cc::Layer* Layer::GetCcLayer() const { 1089 cc::Layer* Layer::GetCcLayer() const {
1086 return cc_layer_; 1090 return cc_layer_;
1087 } 1091 }
1088 1092
1089 LayerThreadedAnimationDelegate* Layer::GetThreadedAnimationDelegate() { 1093 LayerThreadedAnimationDelegate* Layer::GetThreadedAnimationDelegate() {
1090 DCHECK(animator_); 1094 DCHECK(animator_);
1091 return animator_.get(); 1095 return animator_.get();
1092 } 1096 }
1093 1097
1094 void Layer::CreateCcLayer() { 1098 void Layer::CreateCcLayer() {
1095 if (type_ == LAYER_SOLID_COLOR) { 1099 if (type_ == LAYER_SOLID_COLOR || type_ == LAYER_SURFACE) {
1096 solid_color_layer_ = cc::SolidColorLayer::Create(); 1100 solid_color_layer_ = cc::SolidColorLayer::Create();
1097 cc_layer_ = solid_color_layer_.get(); 1101 cc_layer_ = solid_color_layer_.get();
1098 } else if (type_ == LAYER_NINE_PATCH) { 1102 } else if (type_ == LAYER_NINE_PATCH) {
1099 nine_patch_layer_ = cc::NinePatchLayer::Create(); 1103 nine_patch_layer_ = cc::NinePatchLayer::Create();
1100 cc_layer_ = nine_patch_layer_.get(); 1104 cc_layer_ = nine_patch_layer_.get();
1101 } else { 1105 } else {
1102 content_layer_ = cc::PictureLayer::Create(this); 1106 content_layer_ = cc::PictureLayer::Create(this);
1103 cc_layer_ = content_layer_.get(); 1107 cc_layer_ = content_layer_.get();
1104 } 1108 }
1105 cc_layer_->SetTransformOrigin(gfx::Point3F()); 1109 cc_layer_->SetTransformOrigin(gfx::Point3F());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1170 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1167 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1171 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1168 return mirror_ptr.get() == mirror; 1172 return mirror_ptr.get() == mirror;
1169 }); 1173 });
1170 1174
1171 DCHECK(it != mirrors_.end()); 1175 DCHECK(it != mirrors_.end());
1172 mirrors_.erase(it); 1176 mirrors_.erase(it);
1173 } 1177 }
1174 1178
1175 } // namespace ui 1179 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698