| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCQuadCuller.h" | 7 #include "CCQuadCuller.h" |
| 8 | 8 |
| 9 #include "CCAppendQuadsData.h" | 9 #include "CCAppendQuadsData.h" |
| 10 #include "CCDebugBorderDrawQuad.h" | 10 #include "CCDebugBorderDrawQuad.h" |
| 11 #include "CCLayerImpl.h" | 11 #include "CCLayerImpl.h" |
| 12 #include "CCOcclusionTracker.h" | 12 #include "CCOcclusionTracker.h" |
| 13 #include "CCOverdrawMetrics.h" | 13 #include "CCOverdrawMetrics.h" |
| 14 #include "CCRenderPass.h" | 14 #include "CCRenderPass.h" |
| 15 #include "Region.h" | 15 #include "Region.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include <public/WebTransformationMatrix.h> | 17 #include <public/WebTransformationMatrix.h> |
| 18 | 18 |
| 19 using namespace std; | 19 using namespace std; |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 | 22 |
| 23 static const int debugTileBorderWidth = 1; | 23 static const int debugTileBorderWidth = 1; |
| 24 static const int debugTileBorderAlpha = 120; | 24 static const int debugTileBorderAlpha = 120; |
| 25 static const int debugTileBorderColorRed = 160; | 25 static const int debugTileBorderColorRed = 160; |
| 26 static const int debugTileBorderColorGreen = 100; | 26 static const int debugTileBorderColorGreen = 100; |
| 27 static const int debugTileBorderColorBlue = 0; | 27 static const int debugTileBorderColorBlue = 0; |
| 28 | 28 |
| 29 CCQuadCuller::CCQuadCuller(CCQuadList& quadList, CCSharedQuadStateList& sharedQu
adStateList, CCLayerImpl* layer, const CCOcclusionTrackerImpl* occlusionTracker,
bool showCullingWithDebugBorderQuads, bool forSurface) | 29 QuadCuller::QuadCuller(QuadList& quadList, SharedQuadStateList& sharedQuadStateL
ist, LayerImpl* layer, const OcclusionTrackerImpl* occlusionTracker, bool showCu
llingWithDebugBorderQuads, bool forSurface) |
| 30 : m_quadList(quadList) | 30 : m_quadList(quadList) |
| 31 , m_sharedQuadStateList(sharedQuadStateList) | 31 , m_sharedQuadStateList(sharedQuadStateList) |
| 32 , m_currentSharedQuadState(0) | 32 , m_currentSharedQuadState(0) |
| 33 , m_layer(layer) | 33 , m_layer(layer) |
| 34 , m_occlusionTracker(occlusionTracker) | 34 , m_occlusionTracker(occlusionTracker) |
| 35 , m_showCullingWithDebugBorderQuads(showCullingWithDebugBorderQuads) | 35 , m_showCullingWithDebugBorderQuads(showCullingWithDebugBorderQuads) |
| 36 , m_forSurface(forSurface) | 36 , m_forSurface(forSurface) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 CCSharedQuadState* CCQuadCuller::useSharedQuadState(scoped_ptr<CCSharedQuadState
> sharedQuadState) | 40 SharedQuadState* QuadCuller::useSharedQuadState(scoped_ptr<SharedQuadState> shar
edQuadState) |
| 41 { | 41 { |
| 42 sharedQuadState->id = m_sharedQuadStateList.size(); | 42 sharedQuadState->id = m_sharedQuadStateList.size(); |
| 43 | 43 |
| 44 // FIXME: If all quads are culled for the sharedQuadState, we can drop it fr
om the list. | 44 // FIXME: If all quads are culled for the sharedQuadState, we can drop it fr
om the list. |
| 45 m_currentSharedQuadState = sharedQuadState.get(); | 45 m_currentSharedQuadState = sharedQuadState.get(); |
| 46 m_sharedQuadStateList.append(sharedQuadState.Pass()); | 46 m_sharedQuadStateList.append(sharedQuadState.Pass()); |
| 47 return m_currentSharedQuadState; | 47 return m_currentSharedQuadState; |
| 48 } | 48 } |
| 49 | 49 |
| 50 static inline bool appendQuadInternal(scoped_ptr<CCDrawQuad> drawQuad, const Int
Rect& culledRect, CCQuadList& quadList, const CCOcclusionTrackerImpl& occlusionT
racker, bool createDebugBorderQuads) | 50 static inline bool appendQuadInternal(scoped_ptr<DrawQuad> drawQuad, const IntRe
ct& culledRect, QuadList& quadList, const OcclusionTrackerImpl& occlusionTracker
, bool createDebugBorderQuads) |
| 51 { | 51 { |
| 52 bool keepQuad = !culledRect.isEmpty(); | 52 bool keepQuad = !culledRect.isEmpty(); |
| 53 if (keepQuad) | 53 if (keepQuad) |
| 54 drawQuad->setQuadVisibleRect(culledRect); | 54 drawQuad->setQuadVisibleRect(culledRect); |
| 55 | 55 |
| 56 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->quadRect(), culledRect); | 56 occlusionTracker.overdrawMetrics().didCullForDrawing(drawQuad->quadTransform
(), drawQuad->quadRect(), culledRect); |
| 57 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, drawQuad->opaqueRect()); | 57 occlusionTracker.overdrawMetrics().didDraw(drawQuad->quadTransform(), culled
Rect, drawQuad->opaqueRect()); |
| 58 | 58 |
| 59 if (keepQuad) { | 59 if (keepQuad) { |
| 60 if (createDebugBorderQuads && !drawQuad->isDebugQuad() && drawQuad->quad
VisibleRect() != drawQuad->quadRect()) { | 60 if (createDebugBorderQuads && !drawQuad->isDebugQuad() && drawQuad->quad
VisibleRect() != drawQuad->quadRect()) { |
| 61 SkColor borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); | 61 SkColor borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); |
| 62 quadList.append(CCDebugBorderDrawQuad::create(drawQuad->sharedQuadSt
ate(), drawQuad->quadVisibleRect(), borderColor, debugTileBorderWidth).PassAs<CC
DrawQuad>()); | 62 quadList.append(DebugBorderDrawQuad::create(drawQuad->sharedQuadStat
e(), drawQuad->quadVisibleRect(), borderColor, debugTileBorderWidth).PassAs<Draw
Quad>()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Pass the quad after we're done using it. | 65 // Pass the quad after we're done using it. |
| 66 quadList.append(drawQuad.Pass()); | 66 quadList.append(drawQuad.Pass()); |
| 67 } | 67 } |
| 68 return keepQuad; | 68 return keepQuad; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool CCQuadCuller::append(scoped_ptr<CCDrawQuad> drawQuad, CCAppendQuadsData& ap
pendQuadsData) | 71 bool QuadCuller::append(scoped_ptr<DrawQuad> drawQuad, AppendQuadsData& appendQu
adsData) |
| 72 { | 72 { |
| 73 ASSERT(drawQuad->sharedQuadState() == m_currentSharedQuadState); | 73 ASSERT(drawQuad->sharedQuadState() == m_currentSharedQuadState); |
| 74 ASSERT(drawQuad->sharedQuadStateId() == m_currentSharedQuadState->id); | 74 ASSERT(drawQuad->sharedQuadStateId() == m_currentSharedQuadState->id); |
| 75 ASSERT(!m_sharedQuadStateList.isEmpty()); | 75 ASSERT(!m_sharedQuadStateList.isEmpty()); |
| 76 ASSERT(m_sharedQuadStateList.last() == m_currentSharedQuadState); | 76 ASSERT(m_sharedQuadStateList.last() == m_currentSharedQuadState); |
| 77 | 77 |
| 78 IntRect culledRect; | 78 IntRect culledRect; |
| 79 bool hasOcclusionFromOutsideTargetSurface; | 79 bool hasOcclusionFromOutsideTargetSurface; |
| 80 | 80 |
| 81 if (m_forSurface) | 81 if (m_forSurface) |
| 82 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->quadRect(), &hasOcclusionFromOutsideTargetSurface); | 82 culledRect = m_occlusionTracker->unoccludedContributingSurfaceContentRec
t(m_layer, false, drawQuad->quadRect(), &hasOcclusionFromOutsideTargetSurface); |
| 83 else | 83 else |
| 84 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer, drawQuad
->quadRect(), &hasOcclusionFromOutsideTargetSurface); | 84 culledRect = m_occlusionTracker->unoccludedContentRect(m_layer, drawQuad
->quadRect(), &hasOcclusionFromOutsideTargetSurface); |
| 85 | 85 |
| 86 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; | 86 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclusionFromOuts
ideTargetSurface; |
| 87 | 87 |
| 88 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_showCullingWithDebugBorderQuads); | 88 return appendQuadInternal(drawQuad.Pass(), culledRect, m_quadList, *m_occlus
ionTracker, m_showCullingWithDebugBorderQuads); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace cc | 91 } // namespace cc |
| OLD | NEW |