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