OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/quad_culler.h" | 5 #include "cc/quad_culler.h" |
6 | 6 |
7 #include "cc/append_quads_data.h" | 7 #include "cc/append_quads_data.h" |
8 #include "cc/debug_border_draw_quad.h" | 8 #include "cc/debug_border_draw_quad.h" |
| 9 #include "cc/debug_colors.h" |
9 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
10 #include "cc/occlusion_tracker.h" | 11 #include "cc/occlusion_tracker.h" |
11 #include "cc/overdraw_metrics.h" | 12 #include "cc/overdraw_metrics.h" |
12 #include "cc/render_pass.h" | 13 #include "cc/render_pass.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
14 #include <public/WebTransformationMatrix.h> | 15 #include <public/WebTransformationMatrix.h> |
15 | 16 |
16 using namespace std; | 17 using namespace std; |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 static const int debugTileBorderWidth = 1; | |
21 static const int debugTileBorderAlpha = 120; | |
22 static const int debugTileBorderColorRed = 160; | |
23 static const int debugTileBorderColorGreen = 100; | |
24 static const int debugTileBorderColorBlue = 0; | |
25 | |
26 QuadCuller::QuadCuller(QuadList& quadList, SharedQuadStateList& sharedQuadStateL
ist, LayerImpl* layer, const OcclusionTrackerImpl* occlusionTracker, bool showCu
llingWithDebugBorderQuads, bool forSurface) | 21 QuadCuller::QuadCuller(QuadList& quadList, SharedQuadStateList& sharedQuadStateL
ist, LayerImpl* layer, const OcclusionTrackerImpl* occlusionTracker, bool showCu
llingWithDebugBorderQuads, bool forSurface) |
27 : m_quadList(quadList) | 22 : m_quadList(quadList) |
28 , m_sharedQuadStateList(sharedQuadStateList) | 23 , m_sharedQuadStateList(sharedQuadStateList) |
29 , m_currentSharedQuadState(0) | 24 , m_currentSharedQuadState(0) |
30 , m_layer(layer) | 25 , m_layer(layer) |
31 , m_occlusionTracker(occlusionTracker) | 26 , m_occlusionTracker(occlusionTracker) |
32 , m_showCullingWithDebugBorderQuads(showCullingWithDebugBorderQuads) | 27 , m_showCullingWithDebugBorderQuads(showCullingWithDebugBorderQuads) |
33 , m_forSurface(forSurface) | 28 , m_forSurface(forSurface) |
34 { | 29 { |
35 } | 30 } |
36 | 31 |
37 SharedQuadState* QuadCuller::useSharedQuadState(scoped_ptr<SharedQuadState> shar
edQuadState) | 32 SharedQuadState* QuadCuller::useSharedQuadState(scoped_ptr<SharedQuadState> shar
edQuadState) |
38 { | 33 { |
39 sharedQuadState->id = m_sharedQuadStateList.size(); | 34 sharedQuadState->id = m_sharedQuadStateList.size(); |
40 | 35 |
41 // FIXME: If all quads are culled for the sharedQuadState, we can drop it fr
om the list. | 36 // FIXME: If all quads are culled for the sharedQuadState, we can drop it fr
om the list. |
42 m_currentSharedQuadState = sharedQuadState.get(); | 37 m_currentSharedQuadState = sharedQuadState.get(); |
43 m_sharedQuadStateList.append(sharedQuadState.Pass()); | 38 m_sharedQuadStateList.append(sharedQuadState.Pass()); |
44 return m_currentSharedQuadState; | 39 return m_currentSharedQuadState; |
45 } | 40 } |
46 | 41 |
47 static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const gfx::
Rect& culledRect, QuadList& quadList, const OcclusionTrackerImpl& occlusionTrack
er, bool createDebugBorderQuads) | 42 static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const gfx::
Rect& culledRect, QuadList& quadList, const OcclusionTrackerImpl& occlusionTrack
er, LayerImpl* layer, bool createDebugBorderQuads) |
48 { | 43 { |
49 bool keepQuad = !culledRect.IsEmpty(); | 44 bool keepQuad = !culledRect.IsEmpty(); |
50 if (keepQuad) | 45 if (keepQuad) |
51 drawQuad->setQuadVisibleRect(culledRect); | 46 drawQuad->setQuadVisibleRect(culledRect); |
52 | 47 |
53 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->quadRect(), culledRect); | 48 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->quadRect(), culledRect); |
54 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, drawQuad->opaqueRect()); | 49 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, drawQuad->opaqueRect()); |
55 | 50 |
56 if (keepQuad) { | 51 if (keepQuad) { |
57 if (createDebugBorderQuads && !drawQuad->isDebugQuad() && drawQuad->quad
VisibleRect() != drawQuad->quadRect()) { | 52 if (createDebugBorderQuads && !drawQuad->isDebugQuad() && drawQuad->quad
VisibleRect() != drawQuad->quadRect()) { |
58 SkColor borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); | 53 SkColor color = DebugColors::CulledTileBorderColor(); |
59 quadList.append(DebugBorderDrawQuad::create(drawQuad->sharedQuadStat
e(), drawQuad->quadVisibleRect(), borderColor, debugTileBorderWidth).PassAs<Draw
Quad>()); | 54 float width = DebugColors::CulledTileBorderWidth(layer ? layer->laye
rTreeHostImpl() : NULL); |
| 55 quadList.append(DebugBorderDrawQuad::create(drawQuad->sharedQuadStat
e(), drawQuad->quadVisibleRect(), color, width).PassAs<DrawQuad>()); |
60 } | 56 } |
61 | 57 |
62 // Pass the quad after we're done using it. | 58 // Pass the quad after we're done using it. |
63 quadList.append(drawQuad.Pass()); | 59 quadList.append(drawQuad.Pass()); |
64 } | 60 } |
65 return keepQuad; | 61 return keepQuad; |
66 } | 62 } |
67 | 63 |
68 bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu
adsData) | 64 bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu
adsData) |
69 { | 65 { |
70 DCHECK(drawQuad->sharedQuadState() == m_currentSharedQuadState); | 66 DCHECK(drawQuad->sharedQuadState() == m_currentSharedQuadState); |
71 DCHECK(drawQuad->sharedQuadStateId() == m_currentSharedQuadState->id); | 67 DCHECK(drawQuad->sharedQuadStateId() == m_currentSharedQuadState->id); |
72 DCHECK(!m_sharedQuadStateList.isEmpty()); | 68 DCHECK(!m_sharedQuadStateList.isEmpty()); |
73 DCHECK(m_sharedQuadStateList.last() == m_currentSharedQuadState); | 69 DCHECK(m_sharedQuadStateList.last() == m_currentSharedQuadState); |
74 | 70 |
75 gfx::Rect culledRect; | 71 gfx::Rect culledRect; |
76 bool hasOcclusionFromOutsideTargetSurface; | 72 bool hasOcclusionFromOutsideTargetSurface; |
77 bool implDrawTransformIsUnknown = false; | 73 bool implDrawTransformIsUnknown = false; |
78 | 74 |
79 if (m_forSurface) | 75 if (m_forSurface) |
80 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->quadRect(), &hasOcclusionFromOutsideTargetSurface); | 76 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->quadRect(), &hasOcclusionFromOutsideTargetSurface); |
81 else | 77 else |
82 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTa
rget(), drawQuad->quadRect(), drawQuad->quadTransform(), implDrawTransformIsUnkn
own, drawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); | 78 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTa
rget(), drawQuad->quadRect(), drawQuad->quadTransform(), implDrawTransformIsUnkn
own, drawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); |
83 | 79 |
84 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; | 80 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; |
85 | 81 |
86 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_showCullingWithDebugBorderQuads); | 82 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_layer, m_showCullingWithDebugBorderQuads); |
87 } | 83 } |
88 | 84 |
89 } // namespace cc | 85 } // namespace cc |
OLD | NEW |