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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Rebased to resolve conflict. Created 3 years, 4 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
« 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 cc_layer_->RemoveAllChildren(); 620 cc_layer_->RemoveAllChildren();
621 if (cc_layer_->parent()) { 621 if (cc_layer_->parent()) {
622 cc_layer_->parent()->ReplaceChild(cc_layer_, new_layer); 622 cc_layer_->parent()->ReplaceChild(cc_layer_, new_layer);
623 } 623 }
624 cc_layer_->SetLayerClient(NULL); 624 cc_layer_->SetLayerClient(NULL);
625 new_layer->SetOpacity(cc_layer_->opacity()); 625 new_layer->SetOpacity(cc_layer_->opacity());
626 new_layer->SetTransform(cc_layer_->transform()); 626 new_layer->SetTransform(cc_layer_->transform());
627 new_layer->SetPosition(cc_layer_->position()); 627 new_layer->SetPosition(cc_layer_->position());
628 new_layer->SetBackgroundColor(cc_layer_->background_color()); 628 new_layer->SetBackgroundColor(cc_layer_->background_color());
629 new_layer->SetCacheRenderSurface(cc_layer_->cache_render_surface());
629 630
630 cc_layer_ = new_layer.get(); 631 cc_layer_ = new_layer.get();
631 content_layer_ = NULL; 632 content_layer_ = NULL;
632 solid_color_layer_ = NULL; 633 solid_color_layer_ = NULL;
633 texture_layer_ = NULL; 634 texture_layer_ = NULL;
634 surface_layer_ = NULL; 635 surface_layer_ = NULL;
635 636
636 for (size_t i = 0; i < children_.size(); ++i) { 637 for (size_t i = 0; i < children_.size(); ++i) {
637 DCHECK(children_[i]->cc_layer_); 638 DCHECK(children_[i]->cc_layer_);
638 cc_layer_->AddChild(children_[i]->cc_layer_); 639 cc_layer_->AddChild(children_[i]->cc_layer_);
639 } 640 }
640 cc_layer_->SetLayerClient(this); 641 cc_layer_->SetLayerClient(this);
641 cc_layer_->SetTransformOrigin(gfx::Point3F()); 642 cc_layer_->SetTransformOrigin(gfx::Point3F());
642 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); 643 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_);
643 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); 644 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
644 cc_layer_->SetHideLayerAndSubtree(!visible_); 645 cc_layer_->SetHideLayerAndSubtree(!visible_);
645 cc_layer_->SetElementId(cc::ElementId(cc_layer_->id())); 646 cc_layer_->SetElementId(cc::ElementId(cc_layer_->id()));
646 647
647 SetLayerFilters(); 648 SetLayerFilters();
648 SetLayerBackgroundFilters(); 649 SetLayerBackgroundFilters();
649 } 650 }
650 651
651 void Layer::SwitchCCLayerForTest() { 652 void Layer::SwitchCCLayerForTest() {
652 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this); 653 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this);
653 SwitchToLayer(new_layer); 654 SwitchToLayer(new_layer);
654 content_layer_ = new_layer; 655 content_layer_ = new_layer;
655 } 656 }
656 657
658 // Note: The code that sets this flag would be responsible to unset it on that
659 // ui::Layer. We do not want to clone this flag to a cloned layer by accident,
660 // which could be a supprise. But we want to preserve it after switching to a
661 // new cc::Layer. There could be a whole subtree and the root changed, but does
662 // not mean we want to treat the cache all different.
663 void Layer::SetCacheRenderSurface(bool cache_render_surface) {
664 cc_layer_->SetCacheRenderSurface(cache_render_surface);
665 }
666
657 void Layer::SetTextureMailbox( 667 void Layer::SetTextureMailbox(
658 const viz::TextureMailbox& mailbox, 668 const viz::TextureMailbox& mailbox,
659 std::unique_ptr<viz::SingleReleaseCallback> release_callback, 669 std::unique_ptr<viz::SingleReleaseCallback> release_callback,
660 gfx::Size texture_size_in_dip) { 670 gfx::Size texture_size_in_dip) {
661 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); 671 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
662 DCHECK(mailbox.IsValid()); 672 DCHECK(mailbox.IsValid());
663 DCHECK(release_callback); 673 DCHECK(release_callback);
664 if (!texture_layer_.get()) { 674 if (!texture_layer_.get()) {
665 scoped_refptr<cc::TextureLayer> new_layer = 675 scoped_refptr<cc::TextureLayer> new_layer =
666 cc::TextureLayer::CreateForMailbox(this); 676 cc::TextureLayer::CreateForMailbox(this);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1264 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1255 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1265 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1256 return mirror_ptr.get() == mirror; 1266 return mirror_ptr.get() == mirror;
1257 }); 1267 });
1258 1268
1259 DCHECK(it != mirrors_.end()); 1269 DCHECK(it != mirrors_.end());
1260 mirrors_.erase(it); 1270 mirrors_.erase(it);
1261 } 1271 }
1262 1272
1263 } // namespace ui 1273 } // 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