| 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/debug_colors.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 , m_forSurface(forSurface) | 28 , m_forSurface(forSurface) |
| 29 { | 29 { |
| 30 } | 30 } |
| 31 | 31 |
| 32 SharedQuadState* QuadCuller::useSharedQuadState(scoped_ptr<SharedQuadState> shar
edQuadState) | 32 SharedQuadState* QuadCuller::useSharedQuadState(scoped_ptr<SharedQuadState> shar
edQuadState) |
| 33 { | 33 { |
| 34 sharedQuadState->id = m_sharedQuadStateList.size(); | 34 sharedQuadState->id = m_sharedQuadStateList.size(); |
| 35 | 35 |
| 36 // 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. |
| 37 m_currentSharedQuadState = sharedQuadState.get(); | 37 m_currentSharedQuadState = sharedQuadState.get(); |
| 38 m_sharedQuadStateList.append(sharedQuadState.Pass()); | 38 m_sharedQuadStateList.push_back(sharedQuadState.Pass()); |
| 39 return m_currentSharedQuadState; | 39 return m_currentSharedQuadState; |
| 40 } | 40 } |
| 41 | 41 |
| 42 static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const gfx::
Rect& culledRect, QuadList& quadList, const OcclusionTrackerImpl& occlusionTrack
er, LayerImpl* layer, 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) |
| 43 { | 43 { |
| 44 bool keepQuad = !culledRect.IsEmpty(); | 44 bool keepQuad = !culledRect.IsEmpty(); |
| 45 if (keepQuad) | 45 if (keepQuad) |
| 46 drawQuad->visible_rect = culledRect; | 46 drawQuad->visible_rect = culledRect; |
| 47 | 47 |
| 48 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->rect, culledRect); | 48 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->rect, culledRect); |
| 49 gfx::Rect opaqueDrawRect = drawQuad->opacity() == 1.0f ? drawQuad->opaque_re
ct : gfx::Rect(); | 49 gfx::Rect opaqueDrawRect = drawQuad->opacity() == 1.0f ? drawQuad->opaque_re
ct : gfx::Rect(); |
| 50 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, opaqueDrawRect); | 50 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, opaqueDrawRect); |
| 51 | 51 |
| 52 if (keepQuad) { | 52 if (keepQuad) { |
| 53 if (createDebugBorderQuads && !drawQuad->IsDebugQuad() && drawQuad->visi
ble_rect != drawQuad->rect) { | 53 if (createDebugBorderQuads && !drawQuad->IsDebugQuad() && drawQuad->visi
ble_rect != drawQuad->rect) { |
| 54 SkColor color = DebugColors::CulledTileBorderColor(); | 54 SkColor color = DebugColors::CulledTileBorderColor(); |
| 55 float width = DebugColors::CulledTileBorderWidth(layer ? layer->laye
rTreeHostImpl() : NULL); | 55 float width = DebugColors::CulledTileBorderWidth(layer ? layer->laye
rTreeHostImpl() : NULL); |
| 56 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDrawQua
d::Create(); | 56 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDrawQua
d::Create(); |
| 57 debugBorderQuad->SetNew(drawQuad->shared_quad_state, drawQuad->visib
le_rect, color, width); | 57 debugBorderQuad->SetNew(drawQuad->shared_quad_state, drawQuad->visib
le_rect, color, width); |
| 58 quadList.append(debugBorderQuad.PassAs<DrawQuad>()); | 58 quadList.push_back(debugBorderQuad.PassAs<DrawQuad>()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Pass the quad after we're done using it. | 61 // Pass the quad after we're done using it. |
| 62 quadList.append(drawQuad.Pass()); | 62 quadList.push_back(drawQuad.Pass()); |
| 63 } | 63 } |
| 64 return keepQuad; | 64 return keepQuad; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu
adsData) | 67 bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu
adsData) |
| 68 { | 68 { |
| 69 DCHECK(drawQuad->shared_quad_state == m_currentSharedQuadState); | 69 DCHECK(drawQuad->shared_quad_state == m_currentSharedQuadState); |
| 70 DCHECK(!m_sharedQuadStateList.isEmpty()); | 70 DCHECK(!m_sharedQuadStateList.empty()); |
| 71 DCHECK(m_sharedQuadStateList.last() == m_currentSharedQuadState); | 71 DCHECK(m_sharedQuadStateList.back() == m_currentSharedQuadState); |
| 72 | 72 |
| 73 gfx::Rect culledRect; | 73 gfx::Rect culledRect; |
| 74 bool hasOcclusionFromOutsideTargetSurface; | 74 bool hasOcclusionFromOutsideTargetSurface; |
| 75 bool implDrawTransformIsUnknown = false; | 75 bool implDrawTransformIsUnknown = false; |
| 76 | 76 |
| 77 if (m_forSurface) | 77 if (m_forSurface) |
| 78 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->rect, &hasOcclusionFromOutsideTargetSurface); | 78 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->rect, &hasOcclusionFromOutsideTargetSurface); |
| 79 else | 79 else |
| 80 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTa
rget(), drawQuad->rect, drawQuad->quadTransform(), implDrawTransformIsUnknown, d
rawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); | 80 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer->renderTa
rget(), drawQuad->rect, drawQuad->quadTransform(), implDrawTransformIsUnknown, d
rawQuad->clippedRectInTarget(), &hasOcclusionFromOutsideTargetSurface); |
| 81 | 81 |
| 82 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; | 82 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; |
| 83 | 83 |
| 84 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_layer, m_showCullingWithDebugBorderQuads); | 84 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_layer, m_showCullingWithDebugBorderQuads); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace cc | 87 } // namespace cc |
| OLD | NEW |