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

Unified Diff: ui/compositor/layer.cc

Issue 25596002: aura: Use Layer::SetShowPaintedContent to stop showing external content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: layer-showpaintedcontent: nits Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index a96060982423ef4bd71f7d603f6a37f1eb4846a0..2da468a5b48ca5f69c8ebe98ead61cfa42ba8b11 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -476,30 +476,21 @@ void Layer::SwitchCCLayerForTest() {
}
void Layer::SetExternalTexture(Texture* texture) {
+ DCHECK(texture);
+
// Hold a ref to the old |Texture| until we have updated all
// compositor references to the texture id that it holds.
scoped_refptr<ui::Texture> old_texture = texture_;
DCHECK_EQ(type_, LAYER_TEXTURED);
DCHECK(!solid_color_layer_.get());
- bool has_texture = !!texture;
- layer_updated_externally_ = has_texture;
+ layer_updated_externally_ = true;
texture_ = texture;
- if (!!texture_layer_.get() != has_texture) {
- // Switch to a different type of layer.
- if (has_texture) {
- scoped_refptr<cc::TextureLayer> new_layer =
- cc::TextureLayer::Create(this);
- new_layer->SetFlipped(texture_->flipped());
- SwitchToLayer(new_layer);
- texture_layer_ = new_layer;
- } else {
- scoped_refptr<cc::ContentLayer> new_layer =
- cc::ContentLayer::Create(this);
- SwitchToLayer(new_layer);
- content_layer_ = new_layer;
- mailbox_ = cc::TextureMailbox();
- }
+ if (!texture_layer_.get()) {
+ scoped_refptr<cc::TextureLayer> new_layer = cc::TextureLayer::Create(this);
+ new_layer->SetFlipped(texture_->flipped());
+ SwitchToLayer(new_layer);
+ texture_layer_ = new_layer;
}
RecomputeDrawsContentAndUVRect();
}
@@ -533,25 +524,18 @@ cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) {
void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame,
gfx::Size frame_size_in_dip) {
+ DCHECK(frame && !frame->render_pass_list.empty());
+
DCHECK_EQ(type_, LAYER_TEXTURED);
- bool has_frame = frame.get() && !frame->render_pass_list.empty();
- layer_updated_externally_ = has_frame;
+ layer_updated_externally_ = true;
delegated_frame_size_in_dip_ = frame_size_in_dip;
- if (!!delegated_renderer_layer_.get() != has_frame) {
- if (has_frame) {
- scoped_refptr<cc::DelegatedRendererLayer> new_layer =
- cc::DelegatedRendererLayer::Create(NULL);
- SwitchToLayer(new_layer);
- delegated_renderer_layer_ = new_layer;
- } else {
- scoped_refptr<cc::ContentLayer> new_layer =
- cc::ContentLayer::Create(this);
- SwitchToLayer(new_layer);
- content_layer_ = new_layer;
- }
+ if (!delegated_renderer_layer_.get()) {
+ scoped_refptr<cc::DelegatedRendererLayer> new_layer =
+ cc::DelegatedRendererLayer::Create(NULL);
+ SwitchToLayer(new_layer);
+ delegated_renderer_layer_ = new_layer;
}
- if (has_frame)
- delegated_renderer_layer_->SetFrameData(frame.Pass());
+ delegated_renderer_layer_->SetFrameData(frame.Pass());
RecomputeDrawsContentAndUVRect();
}
@@ -561,10 +545,23 @@ void Layer::TakeUnusedResourcesForChildCompositor(
delegated_renderer_layer_->TakeUnusedResourcesForChildCompositor(list);
}
-void Layer::SetColor(SkColor color) {
- GetAnimator()->SetColor(color);
+void Layer::SetShowPaintedContent() {
+ if (content_layer_.get())
+ return;
+
+ scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this);
+ SwitchToLayer(new_layer);
+ content_layer_ = new_layer;
+
+ layer_updated_externally_ = false;
+ mailbox_ = cc::TextureMailbox();
+ texture_ = NULL;
+
+ RecomputeDrawsContentAndUVRect();
}
+void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); }
+
bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_.get()))
return false;
« 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