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

Side by Side Diff: cc/layer_impl.cc

Issue 11365239: cc: Add support for debugging layer borders directly in the compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 | « cc/layer_impl.h ('k') | cc/layer_impl_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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layer_impl.h" 5 #include "cc/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "cc/debug_border_draw_quad.h" 9 #include "cc/debug_border_draw_quad.h"
10 #include "cc/geometry.h" 10 #include "cc/geometry.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 , m_drawCheckerboardForMissingTiles(false) 47 , m_drawCheckerboardForMissingTiles(false)
48 , m_useLCDText(false) 48 , m_useLCDText(false)
49 , m_drawsContent(false) 49 , m_drawsContent(false)
50 , m_forceRenderSurface(false) 50 , m_forceRenderSurface(false)
51 , m_isContainerForFixedPositionLayers(false) 51 , m_isContainerForFixedPositionLayers(false)
52 , m_fixedToContainerLayer(false) 52 , m_fixedToContainerLayer(false)
53 , m_renderTarget(0) 53 , m_renderTarget(0)
54 , m_drawDepth(0) 54 , m_drawDepth(0)
55 , m_drawOpacity(0) 55 , m_drawOpacity(0)
56 , m_drawOpacityIsAnimating(false) 56 , m_drawOpacityIsAnimating(false)
57 , m_debugBorderColor(0)
58 , m_debugBorderWidth(0)
59 , m_filter(0) 57 , m_filter(0)
60 , m_drawTransformIsAnimating(false) 58 , m_drawTransformIsAnimating(false)
61 , m_screenSpaceTransformIsAnimating(false) 59 , m_screenSpaceTransformIsAnimating(false)
62 #ifndef NDEBUG 60 #ifndef NDEBUG
63 , m_betweenWillDrawAndDidDraw(false) 61 , m_betweenWillDrawAndDidDraw(false)
64 #endif 62 #endif
65 , m_layerAnimationController(LayerAnimationController::create(this)) 63 , m_layerAnimationController(LayerAnimationController::create(this))
66 { 64 {
67 DCHECK(m_layerId > 0); 65 DCHECK(m_layerId > 0);
68 } 66 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 137 }
140 138
141 void LayerImpl::didDraw(ResourceProvider*) 139 void LayerImpl::didDraw(ResourceProvider*)
142 { 140 {
143 #ifndef NDEBUG 141 #ifndef NDEBUG
144 DCHECK(m_betweenWillDrawAndDidDraw); 142 DCHECK(m_betweenWillDrawAndDidDraw);
145 m_betweenWillDrawAndDidDraw = false; 143 m_betweenWillDrawAndDidDraw = false;
146 #endif 144 #endif
147 } 145 }
148 146
147 bool LayerImpl::showDebugBorders() const
148 {
149 if (!m_layerTreeHostImpl)
150 return false;
151 return m_layerTreeHostImpl->settings().showDebugBorders;
152 }
153
154 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const
155 {
156 if (m_drawsContent) {
157 // Non-tiled content layers are green.
158 *color = SkColorSetARGB(128, 0, 128, 32);
159 *width = 2;
160 return;
161 }
162
163 if (m_masksToBounds) {
164 // Masking layers are pale blue.
165 *color = SkColorSetARGB(48, 128, 255, 255);
166 *width = 20;
167 return;
168 }
169
170 // Other container layers are yellow.
171 *color = SkColorSetARGB(192, 255, 255, 0);
172 *width = 2;
173 }
174
149 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const 175 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const
150 { 176 {
151 if (!hasDebugBorders()) 177 if (!showDebugBorders())
152 return; 178 return;
153 179
180 SkColor color;
181 float width;
182 getDebugBorderProperties(&color, &width);
183
154 gfx::Rect contentRect(gfx::Point(), contentBounds()); 184 gfx::Rect contentRect(gfx::Point(), contentBounds());
155 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData); 185 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, co lor, width).PassAs<DrawQuad>(), appendQuadsData);
156 } 186 }
157 187
158 bool LayerImpl::hasContributingDelegatedRenderPasses() const 188 bool LayerImpl::hasContributingDelegatedRenderPasses() const
159 { 189 {
160 return false; 190 return false;
161 } 191 }
162 192
163 RenderPass::Id LayerImpl::firstContributingRenderPassId() const 193 RenderPass::Id LayerImpl::firstContributingRenderPassId() const
164 { 194 {
165 return RenderPass::Id(0, 0); 195 return RenderPass::Id(0, 0);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 610
581 m_transform = transform; 611 m_transform = transform;
582 m_layerSurfacePropertyChanged = true; 612 m_layerSurfacePropertyChanged = true;
583 } 613 }
584 614
585 bool LayerImpl::transformIsAnimating() const 615 bool LayerImpl::transformIsAnimating() const
586 { 616 {
587 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); 617 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
588 } 618 }
589 619
590 void LayerImpl::setDebugBorderColor(SkColor debugBorderColor)
591 {
592 if (m_debugBorderColor == debugBorderColor)
593 return;
594
595 m_debugBorderColor = debugBorderColor;
596 m_layerPropertyChanged = true;
597 }
598
599 void LayerImpl::setDebugBorderWidth(float debugBorderWidth)
600 {
601 if (m_debugBorderWidth == debugBorderWidth)
602 return;
603
604 m_debugBorderWidth = debugBorderWidth;
605 m_layerPropertyChanged = true;
606 }
607
608 bool LayerImpl::hasDebugBorders() const
609 {
610 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0;
611 }
612
613 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) 620 void LayerImpl::setContentBounds(const gfx::Size& contentBounds)
614 { 621 {
615 if (m_contentBounds == contentBounds) 622 if (m_contentBounds == contentBounds)
616 return; 623 return;
617 624
618 m_contentBounds = contentBounds; 625 m_contentBounds = contentBounds;
619 m_layerPropertyChanged = true; 626 m_layerPropertyChanged = true;
620 } 627 }
621 628
622 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) 629 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 712
706 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 713 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
707 { 714 {
708 if (!m_scrollbarAnimationController) 715 if (!m_scrollbarAnimationController)
709 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 716 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
710 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 717 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
711 m_scrollbarAnimationController->updateScrollOffset(this); 718 m_scrollbarAnimationController->updateScrollOffset(this);
712 } 719 }
713 720
714 } // namespace cc 721 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698