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

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

Issue 11410098: ui: Enable debug borders for the UI compositor through layer tree settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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') | no next file » | 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 target->ConvertPointFromAncestor(root_layer, point); 367 target->ConvertPointFromAncestor(root_layer, point);
368 } 368 }
369 369
370 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { 370 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
371 if (fills_bounds_opaquely_ == fills_bounds_opaquely) 371 if (fills_bounds_opaquely_ == fills_bounds_opaquely)
372 return; 372 return;
373 373
374 fills_bounds_opaquely_ = fills_bounds_opaquely; 374 fills_bounds_opaquely_ = fills_bounds_opaquely;
375 375
376 web_layer_->setOpaque(fills_bounds_opaquely); 376 web_layer_->setOpaque(fills_bounds_opaquely);
377 RecomputeDebugBorderColor();
378 } 377 }
379 378
380 void Layer::SetExternalTexture(Texture* texture) { 379 void Layer::SetExternalTexture(Texture* texture) {
381 DCHECK_EQ(type_, LAYER_TEXTURED); 380 DCHECK_EQ(type_, LAYER_TEXTURED);
382 layer_updated_externally_ = !!texture; 381 layer_updated_externally_ = !!texture;
383 texture_ = texture; 382 texture_ = texture;
384 if (web_layer_is_accelerated_ != layer_updated_externally_) { 383 if (web_layer_is_accelerated_ != layer_updated_externally_) {
385 // Switch to a different type of layer. 384 // Switch to a different type of layer.
386 web_layer_->removeAllChildren(); 385 web_layer_->removeAllChildren();
387 scoped_ptr<WebKit::WebContentLayer> old_content_layer( 386 scoped_ptr<WebKit::WebContentLayer> old_content_layer(
(...skipping 21 matching lines...) Expand all
409 } 408 }
410 web_layer_= new_layer; 409 web_layer_= new_layer;
411 web_layer_is_accelerated_ = layer_updated_externally_; 410 web_layer_is_accelerated_ = layer_updated_externally_;
412 for (size_t i = 0; i < children_.size(); ++i) { 411 for (size_t i = 0; i < children_.size(); ++i) {
413 DCHECK(children_[i]->web_layer_); 412 DCHECK(children_[i]->web_layer_);
414 web_layer_->addChild(children_[i]->web_layer_); 413 web_layer_->addChild(children_[i]->web_layer_);
415 } 414 }
416 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 415 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
417 web_layer_->setOpaque(fills_bounds_opaquely_); 416 web_layer_->setOpaque(fills_bounds_opaquely_);
418 web_layer_->setOpacity(visible_ ? opacity_ : 0.f); 417 web_layer_->setOpacity(visible_ ? opacity_ : 0.f);
419 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0);
420 web_layer_->setForceRenderSurface(force_render_surface_); 418 web_layer_->setForceRenderSurface(force_render_surface_);
421 RecomputeTransform(); 419 RecomputeTransform();
422 RecomputeDebugBorderColor();
423 } 420 }
424 RecomputeDrawsContentAndUVRect(); 421 RecomputeDrawsContentAndUVRect();
425 } 422 }
426 423
427 void Layer::SetColor(SkColor color) { 424 void Layer::SetColor(SkColor color) {
428 GetAnimator()->SetColor(color); 425 GetAnimator()->SetColor(color);
429 } 426 }
430 427
431 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { 428 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) {
432 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_)) 429 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_))
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 617
621 RecomputeTransform(); 618 RecomputeTransform();
622 } 619 }
623 620
624 void Layer::SetOpacityImmediately(float opacity) { 621 void Layer::SetOpacityImmediately(float opacity) {
625 bool schedule_draw = (opacity != opacity_ && IsDrawn()); 622 bool schedule_draw = (opacity != opacity_ && IsDrawn());
626 opacity_ = opacity; 623 opacity_ = opacity;
627 624
628 if (visible_) 625 if (visible_)
629 web_layer_->setOpacity(opacity); 626 web_layer_->setOpacity(opacity);
630 RecomputeDebugBorderColor();
631 if (schedule_draw) 627 if (schedule_draw)
632 ScheduleDraw(); 628 ScheduleDraw();
633 } 629 }
634 630
635 void Layer::SetVisibilityImmediately(bool visible) { 631 void Layer::SetVisibilityImmediately(bool visible) {
636 if (visible_ == visible) 632 if (visible_ == visible)
637 return; 633 return;
638 634
639 visible_ = visible; 635 visible_ = visible;
640 // TODO(piman): Expose a visibility flag on WebLayer. 636 // TODO(piman): Expose a visibility flag on WebLayer.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 WebKit::WebCompositorSupport* compositor_support = 722 WebKit::WebCompositorSupport* compositor_support =
727 WebKit::Platform::current()->compositorSupport(); 723 WebKit::Platform::current()->compositorSupport();
728 if (type_ == LAYER_SOLID_COLOR) { 724 if (type_ == LAYER_SOLID_COLOR) {
729 solid_color_layer_.reset(compositor_support->createSolidColorLayer()); 725 solid_color_layer_.reset(compositor_support->createSolidColorLayer());
730 web_layer_ = solid_color_layer_->layer(); 726 web_layer_ = solid_color_layer_->layer();
731 } else { 727 } else {
732 content_layer_.reset(compositor_support->createContentLayer(this)); 728 content_layer_.reset(compositor_support->createContentLayer(this));
733 web_layer_ = content_layer_->layer(); 729 web_layer_ = content_layer_->layer();
734 } 730 }
735 web_layer_is_accelerated_ = false; 731 web_layer_is_accelerated_ = false;
736 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch(
737 switches::kUIShowLayerBorders);
738 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 732 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
739 web_layer_->setOpaque(true); 733 web_layer_->setOpaque(true);
740 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0);
741 } 734 }
742 735
743 void Layer::RecomputeTransform() { 736 void Layer::RecomputeTransform() {
744 gfx::Transform scale_translate; 737 gfx::Transform scale_translate;
745 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, 738 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
746 0, device_scale_factor_, 0, 739 0, device_scale_factor_, 0,
747 0, 0, 1); 740 0, 0, 1);
748 // Start with the inverse matrix of above. 741 // Start with the inverse matrix of above.
749 gfx::Transform transform; 742 gfx::Transform transform;
750 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, 743 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0,
(...skipping 27 matching lines...) Expand all
778 0, 771 0,
779 static_cast<float>(size.width())/texture_size.width(), 772 static_cast<float>(size.width())/texture_size.width(),
780 static_cast<float>(size.height())/texture_size.height()); 773 static_cast<float>(size.height())/texture_size.height());
781 texture_layer_->setUVRect(rect); 774 texture_layer_->setUVRect(rect);
782 775
783 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); 776 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size);
784 web_layer_->setBounds(size_in_pixel); 777 web_layer_->setBounds(size_in_pixel);
785 } 778 }
786 } 779 }
787 780
788 void Layer::RecomputeDebugBorderColor() {
789 if (!show_debug_borders_)
790 return;
791 unsigned int color = 0xFF000000;
792 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
793 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
794 if (!opaque)
795 color |= 0xFF;
796 web_layer_->setDebugBorderColor(color);
jonathan.backer 2012/11/14 21:39:12 Is the purpose of this code to give the UI layer b
danakj 2012/11/14 22:26:39 As per offline, this was the way to get layer bord
797 }
798
799 } // namespace ui 781 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698