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

Side by Side 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, 2 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 | Annotate | Revision Log
« 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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 cc_layer_->SetHideLayerAndSubtree(!visible_); 469 cc_layer_->SetHideLayerAndSubtree(!visible_);
470 } 470 }
471 471
472 void Layer::SwitchCCLayerForTest() { 472 void Layer::SwitchCCLayerForTest() {
473 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); 473 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this);
474 SwitchToLayer(new_layer); 474 SwitchToLayer(new_layer);
475 content_layer_ = new_layer; 475 content_layer_ = new_layer;
476 } 476 }
477 477
478 void Layer::SetExternalTexture(Texture* texture) { 478 void Layer::SetExternalTexture(Texture* texture) {
479 DCHECK(texture);
480
479 // Hold a ref to the old |Texture| until we have updated all 481 // Hold a ref to the old |Texture| until we have updated all
480 // compositor references to the texture id that it holds. 482 // compositor references to the texture id that it holds.
481 scoped_refptr<ui::Texture> old_texture = texture_; 483 scoped_refptr<ui::Texture> old_texture = texture_;
482 484
483 DCHECK_EQ(type_, LAYER_TEXTURED); 485 DCHECK_EQ(type_, LAYER_TEXTURED);
484 DCHECK(!solid_color_layer_.get()); 486 DCHECK(!solid_color_layer_.get());
485 bool has_texture = !!texture; 487 layer_updated_externally_ = true;
486 layer_updated_externally_ = has_texture;
487 texture_ = texture; 488 texture_ = texture;
488 if (!!texture_layer_.get() != has_texture) { 489 if (!texture_layer_.get()) {
489 // Switch to a different type of layer. 490 scoped_refptr<cc::TextureLayer> new_layer = cc::TextureLayer::Create(this);
490 if (has_texture) { 491 new_layer->SetFlipped(texture_->flipped());
491 scoped_refptr<cc::TextureLayer> new_layer = 492 SwitchToLayer(new_layer);
492 cc::TextureLayer::Create(this); 493 texture_layer_ = new_layer;
493 new_layer->SetFlipped(texture_->flipped());
494 SwitchToLayer(new_layer);
495 texture_layer_ = new_layer;
496 } else {
497 scoped_refptr<cc::ContentLayer> new_layer =
498 cc::ContentLayer::Create(this);
499 SwitchToLayer(new_layer);
500 content_layer_ = new_layer;
501 mailbox_ = cc::TextureMailbox();
502 }
503 } 494 }
504 RecomputeDrawsContentAndUVRect(); 495 RecomputeDrawsContentAndUVRect();
505 } 496 }
506 497
507 void Layer::SetTextureMailbox( 498 void Layer::SetTextureMailbox(
508 const cc::TextureMailbox& mailbox, 499 const cc::TextureMailbox& mailbox,
509 scoped_ptr<cc::SingleReleaseCallback> release_callback, 500 scoped_ptr<cc::SingleReleaseCallback> release_callback,
510 float scale_factor) { 501 float scale_factor) {
511 DCHECK_EQ(type_, LAYER_TEXTURED); 502 DCHECK_EQ(type_, LAYER_TEXTURED);
512 DCHECK(!solid_color_layer_.get()); 503 DCHECK(!solid_color_layer_.get());
(...skipping 13 matching lines...) Expand all
526 } 517 }
527 518
528 cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) { 519 cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) {
529 if (scale_factor) 520 if (scale_factor)
530 *scale_factor = mailbox_scale_factor_; 521 *scale_factor = mailbox_scale_factor_;
531 return mailbox_; 522 return mailbox_;
532 } 523 }
533 524
534 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, 525 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame,
535 gfx::Size frame_size_in_dip) { 526 gfx::Size frame_size_in_dip) {
527 DCHECK(frame && !frame->render_pass_list.empty());
528
536 DCHECK_EQ(type_, LAYER_TEXTURED); 529 DCHECK_EQ(type_, LAYER_TEXTURED);
537 bool has_frame = frame.get() && !frame->render_pass_list.empty(); 530 layer_updated_externally_ = true;
538 layer_updated_externally_ = has_frame;
539 delegated_frame_size_in_dip_ = frame_size_in_dip; 531 delegated_frame_size_in_dip_ = frame_size_in_dip;
540 if (!!delegated_renderer_layer_.get() != has_frame) { 532 if (!delegated_renderer_layer_.get()) {
541 if (has_frame) { 533 scoped_refptr<cc::DelegatedRendererLayer> new_layer =
542 scoped_refptr<cc::DelegatedRendererLayer> new_layer = 534 cc::DelegatedRendererLayer::Create(NULL);
543 cc::DelegatedRendererLayer::Create(NULL); 535 SwitchToLayer(new_layer);
544 SwitchToLayer(new_layer); 536 delegated_renderer_layer_ = new_layer;
545 delegated_renderer_layer_ = new_layer;
546 } else {
547 scoped_refptr<cc::ContentLayer> new_layer =
548 cc::ContentLayer::Create(this);
549 SwitchToLayer(new_layer);
550 content_layer_ = new_layer;
551 }
552 } 537 }
553 if (has_frame) 538 delegated_renderer_layer_->SetFrameData(frame.Pass());
554 delegated_renderer_layer_->SetFrameData(frame.Pass());
555 RecomputeDrawsContentAndUVRect(); 539 RecomputeDrawsContentAndUVRect();
556 } 540 }
557 541
558 void Layer::TakeUnusedResourcesForChildCompositor( 542 void Layer::TakeUnusedResourcesForChildCompositor(
559 cc::ReturnedResourceArray* list) { 543 cc::ReturnedResourceArray* list) {
560 if (delegated_renderer_layer_.get()) 544 if (delegated_renderer_layer_.get())
561 delegated_renderer_layer_->TakeUnusedResourcesForChildCompositor(list); 545 delegated_renderer_layer_->TakeUnusedResourcesForChildCompositor(list);
562 } 546 }
563 547
564 void Layer::SetColor(SkColor color) { 548 void Layer::SetShowPaintedContent() {
565 GetAnimator()->SetColor(color); 549 if (content_layer_.get())
550 return;
551
552 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this);
553 SwitchToLayer(new_layer);
554 content_layer_ = new_layer;
555
556 layer_updated_externally_ = false;
557 mailbox_ = cc::TextureMailbox();
558 texture_ = NULL;
559
560 RecomputeDrawsContentAndUVRect();
566 } 561 }
567 562
563 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); }
564
568 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { 565 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
569 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_.get())) 566 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_.get()))
570 return false; 567 return false;
571 568
572 damaged_region_.op(invalid_rect.x(), 569 damaged_region_.op(invalid_rect.x(),
573 invalid_rect.y(), 570 invalid_rect.y(),
574 invalid_rect.right(), 571 invalid_rect.right(),
575 invalid_rect.bottom(), 572 invalid_rect.bottom(),
576 SkRegion::kUnion_Op); 573 SkRegion::kUnion_Op);
577 ScheduleDraw(); 574 ScheduleDraw();
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); 972 cc_layer_->SetBounds(ConvertSizeToPixel(this, size));
976 } 973 }
977 974
978 void Layer::RecomputePosition() { 975 void Layer::RecomputePosition() {
979 cc_layer_->SetPosition(gfx::ScalePoint( 976 cc_layer_->SetPosition(gfx::ScalePoint(
980 gfx::PointF(bounds_.x(), bounds_.y()), 977 gfx::PointF(bounds_.x(), bounds_.y()),
981 device_scale_factor_)); 978 device_scale_factor_));
982 } 979 }
983 980
984 } // namespace ui 981 } // 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