OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCRenderPass.h" | 7 #include "CCRenderPass.h" |
8 | 8 |
9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
10 #include "CCMathUtil.h" | 10 #include "CCMathUtil.h" |
11 #include "CCOcclusionTracker.h" | 11 #include "CCOcclusionTracker.h" |
12 #include "CCQuadCuller.h" | 12 #include "CCQuadCuller.h" |
13 #include "CCSharedQuadState.h" | 13 #include "CCSharedQuadState.h" |
14 #include "CCSolidColorDrawQuad.h" | 14 #include "CCSolidColorDrawQuad.h" |
15 | 15 |
16 using WebKit::WebTransformationMatrix; | 16 using WebKit::WebTransformationMatrix; |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 scoped_ptr<CCRenderPass> CCRenderPass::create(Id id, IntRect outputRect, const W
ebKit::WebTransformationMatrix& transformToRootTarget) | 20 scoped_ptr<RenderPass> RenderPass::create(Id id, IntRect outputRect, const WebKi
t::WebTransformationMatrix& transformToRootTarget) |
21 { | 21 { |
22 return make_scoped_ptr(new CCRenderPass(id, outputRect, transformToRootTarge
t)); | 22 return make_scoped_ptr(new RenderPass(id, outputRect, transformToRootTarget)
); |
23 } | 23 } |
24 | 24 |
25 CCRenderPass::CCRenderPass(Id id, IntRect outputRect, const WebKit::WebTransform
ationMatrix& transformToRootTarget) | 25 RenderPass::RenderPass(Id id, IntRect outputRect, const WebKit::WebTransformatio
nMatrix& transformToRootTarget) |
26 : m_id(id) | 26 : m_id(id) |
27 , m_transformToRootTarget(transformToRootTarget) | 27 , m_transformToRootTarget(transformToRootTarget) |
28 , m_outputRect(outputRect) | 28 , m_outputRect(outputRect) |
29 , m_hasTransparentBackground(true) | 29 , m_hasTransparentBackground(true) |
30 , m_hasOcclusionFromOutsideTargetSurface(false) | 30 , m_hasOcclusionFromOutsideTargetSurface(false) |
31 { | 31 { |
32 ASSERT(id.layerId > 0); | 32 ASSERT(id.layerId > 0); |
33 ASSERT(id.index >= 0); | 33 ASSERT(id.index >= 0); |
34 } | 34 } |
35 | 35 |
36 CCRenderPass::~CCRenderPass() | 36 RenderPass::~RenderPass() |
37 { | 37 { |
38 } | 38 } |
39 | 39 |
40 scoped_ptr<CCRenderPass> CCRenderPass::copy(Id newId) const | 40 scoped_ptr<RenderPass> RenderPass::copy(Id newId) const |
41 { | 41 { |
42 ASSERT(newId != m_id); | 42 ASSERT(newId != m_id); |
43 | 43 |
44 scoped_ptr<CCRenderPass> copyPass(create(newId, m_outputRect, m_transformToR
ootTarget)); | 44 scoped_ptr<RenderPass> copyPass(create(newId, m_outputRect, m_transformToRoo
tTarget)); |
45 copyPass->setDamageRect(m_damageRect); | 45 copyPass->setDamageRect(m_damageRect); |
46 copyPass->setHasTransparentBackground(m_hasTransparentBackground); | 46 copyPass->setHasTransparentBackground(m_hasTransparentBackground); |
47 copyPass->setHasOcclusionFromOutsideTargetSurface(m_hasOcclusionFromOutsideT
argetSurface); | 47 copyPass->setHasOcclusionFromOutsideTargetSurface(m_hasOcclusionFromOutsideT
argetSurface); |
48 copyPass->setFilters(m_filters); | 48 copyPass->setFilters(m_filters); |
49 copyPass->setBackgroundFilters(m_backgroundFilters); | 49 copyPass->setBackgroundFilters(m_backgroundFilters); |
50 return copyPass.Pass(); | 50 return copyPass.Pass(); |
51 } | 51 } |
52 | 52 |
53 void CCRenderPass::appendQuadsForLayer(CCLayerImpl* layer, CCOcclusionTrackerImp
l* occlusionTracker, CCAppendQuadsData& appendQuadsData) | 53 void RenderPass::appendQuadsForLayer(LayerImpl* layer, OcclusionTrackerImpl* occ
lusionTracker, AppendQuadsData& appendQuadsData) |
54 { | 54 { |
55 const bool forSurface = false; | 55 const bool forSurface = false; |
56 CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionT
racker, layer->hasDebugBorders(), forSurface); | 56 QuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTra
cker, layer->hasDebugBorders(), forSurface); |
57 | 57 |
58 layer->appendQuads(quadCuller, appendQuadsData); | 58 layer->appendQuads(quadCuller, appendQuadsData); |
59 } | 59 } |
60 | 60 |
61 void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer, const CC
RenderPass* contributingRenderPass, CCOcclusionTrackerImpl* occlusionTracker, CC
AppendQuadsData& appendQuadsData) | 61 void RenderPass::appendQuadsForRenderSurfaceLayer(LayerImpl* layer, const Render
Pass* contributingRenderPass, OcclusionTrackerImpl* occlusionTracker, AppendQuad
sData& appendQuadsData) |
62 { | 62 { |
63 const bool forSurface = true; | 63 const bool forSurface = true; |
64 CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionT
racker, layer->hasDebugBorders(), forSurface); | 64 QuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTra
cker, layer->hasDebugBorders(), forSurface); |
65 | 65 |
66 bool isReplica = false; | 66 bool isReplica = false; |
67 layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isReplica,
contributingRenderPass->id()); | 67 layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isReplica,
contributingRenderPass->id()); |
68 | 68 |
69 // Add replica after the surface so that it appears below the surface. | 69 // Add replica after the surface so that it appears below the surface. |
70 if (layer->hasReplica()) { | 70 if (layer->hasReplica()) { |
71 isReplica = true; | 71 isReplica = true; |
72 layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isRepli
ca, contributingRenderPass->id()); | 72 layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isRepli
ca, contributingRenderPass->id()); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void CCRenderPass::appendQuadsToFillScreen(CCLayerImpl* rootLayer, SkColor scree
nBackgroundColor, const CCOcclusionTrackerImpl& occlusionTracker) | 76 void RenderPass::appendQuadsToFillScreen(LayerImpl* rootLayer, SkColor screenBac
kgroundColor, const OcclusionTrackerImpl& occlusionTracker) |
77 { | 77 { |
78 if (!rootLayer || !screenBackgroundColor) | 78 if (!rootLayer || !screenBackgroundColor) |
79 return; | 79 return; |
80 | 80 |
81 Region fillRegion = occlusionTracker.computeVisibleRegionInScreen(); | 81 Region fillRegion = occlusionTracker.computeVisibleRegionInScreen(); |
82 if (fillRegion.isEmpty()) | 82 if (fillRegion.isEmpty()) |
83 return; | 83 return; |
84 | 84 |
85 bool forSurface = false; | 85 bool forSurface = false; |
86 CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, rootLayer, &occlu
sionTracker, rootLayer->hasDebugBorders(), forSurface); | 86 QuadCuller quadCuller(m_quadList, m_sharedQuadStateList, rootLayer, &occlusi
onTracker, rootLayer->hasDebugBorders(), forSurface); |
87 | 87 |
88 // Manually create the quad state for the gutter quads, as the root layer | 88 // Manually create the quad state for the gutter quads, as the root layer |
89 // doesn't have any bounds and so can't generate this itself. | 89 // doesn't have any bounds and so can't generate this itself. |
90 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). | 90 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). |
91 IntRect rootTargetRect = rootLayer->renderSurface()->contentRect(); | 91 IntRect rootTargetRect = rootLayer->renderSurface()->contentRect(); |
92 float opacity = 1; | 92 float opacity = 1; |
93 bool opaque = true; | 93 bool opaque = true; |
94 CCSharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(CCSharedQ
uadState::create(rootLayer->drawTransform(), rootTargetRect, rootTargetRect, opa
city, opaque)); | 94 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS
tate::create(rootLayer->drawTransform(), rootTargetRect, rootTargetRect, opacity
, opaque)); |
95 ASSERT(rootLayer->screenSpaceTransform().isInvertible()); | 95 ASSERT(rootLayer->screenSpaceTransform().isInvertible()); |
96 WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransf
orm().inverse(); | 96 WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransf
orm().inverse(); |
97 Vector<WebCore::IntRect> fillRects = fillRegion.rects(); | 97 Vector<WebCore::IntRect> fillRects = fillRegion.rects(); |
98 for (size_t i = 0; i < fillRects.size(); ++i) { | 98 for (size_t i = 0; i < fillRects.size(); ++i) { |
99 // The root layer transform is composed of translations and scales only,
no perspective, so mapping is sufficient. | 99 // The root layer transform is composed of translations and scales only,
no perspective, so mapping is sufficient. |
100 IntRect layerRect = CCMathUtil::mapClippedRect(transformToLayerSpace, cc
::IntRect(fillRects[i])); | 100 IntRect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, cc::
IntRect(fillRects[i])); |
101 // Skip the quad culler and just append the quads directly to avoid occl
usion checks. | 101 // Skip the quad culler and just append the quads directly to avoid occl
usion checks. |
102 m_quadList.append(CCSolidColorDrawQuad::create(sharedQuadState, layerRec
t, screenBackgroundColor).PassAs<CCDrawQuad>()); | 102 m_quadList.append(SolidColorDrawQuad::create(sharedQuadState, layerRect,
screenBackgroundColor).PassAs<DrawQuad>()); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 } // namespace cc | 106 } // namespace cc |
OLD | NEW |