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 "CCRenderSurface.h" | 7 #include "CCRenderSurface.h" |
8 | 8 |
9 #include "base/logging.h" | |
10 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
11 #include "CCDamageTracker.h" | 10 #include "CCDamageTracker.h" |
12 #include "CCDebugBorderDrawQuad.h" | 11 #include "CCDebugBorderDrawQuad.h" |
13 #include "CCDelegatedRendererLayerImpl.h" | 12 #include "CCDelegatedRendererLayerImpl.h" |
14 #include "CCLayerImpl.h" | 13 #include "CCLayerImpl.h" |
15 #include "CCMathUtil.h" | 14 #include "CCMathUtil.h" |
16 #include "CCQuadSink.h" | 15 #include "CCQuadSink.h" |
17 #include "CCRenderPass.h" | 16 #include "CCRenderPass.h" |
18 #include "CCRenderPassDrawQuad.h" | 17 #include "CCRenderPassDrawQuad.h" |
19 #include "CCRenderPassSink.h" | 18 #include "CCRenderPassSink.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 bool CCRenderSurface::surfacePropertyChanged() const | 127 bool CCRenderSurface::surfacePropertyChanged() const |
129 { | 128 { |
130 // Surface property changes are tracked as follows: | 129 // Surface property changes are tracked as follows: |
131 // | 130 // |
132 // - m_surfacePropertyChanged is flagged when the clipRect or contentRect ch
ange. As | 131 // - m_surfacePropertyChanged is flagged when the clipRect or contentRect ch
ange. As |
133 // of now, these are the only two properties that can be affected by desce
ndant layers. | 132 // of now, these are the only two properties that can be affected by desce
ndant layers. |
134 // | 133 // |
135 // - all other property changes come from the owning layer (or some ancestor
layer | 134 // - all other property changes come from the owning layer (or some ancestor
layer |
136 // that propagates its change to the owning layer). | 135 // that propagates its change to the owning layer). |
137 // | 136 // |
138 DCHECK(m_owningLayer); | 137 ASSERT(m_owningLayer); |
139 return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged(); | 138 return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged(); |
140 } | 139 } |
141 | 140 |
142 bool CCRenderSurface::surfacePropertyChangedOnlyFromDescendant() const | 141 bool CCRenderSurface::surfacePropertyChangedOnlyFromDescendant() const |
143 { | 142 { |
144 return m_surfacePropertyChanged && !m_owningLayer->layerPropertyChanged(); | 143 return m_surfacePropertyChanged && !m_owningLayer->layerPropertyChanged(); |
145 } | 144 } |
146 | 145 |
147 void CCRenderSurface::addContributingDelegatedRenderPassLayer(CCLayerImpl* layer
) | 146 void CCRenderSurface::addContributingDelegatedRenderPassLayer(CCLayerImpl* layer
) |
148 { | 147 { |
149 DCHECK(std::find(m_layerList.begin(), m_layerList.end(), layer) != m_layerLi
st.end()); | 148 ASSERT(std::find(m_layerList.begin(), m_layerList.end(), layer) != m_layerLi
st.end()); |
150 CCDelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<CCDelegat
edRendererLayerImpl*>(layer); | 149 CCDelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<CCDelegat
edRendererLayerImpl*>(layer); |
151 m_contributingDelegatedRenderPassLayerList.push_back(delegatedRendererLayer)
; | 150 m_contributingDelegatedRenderPassLayerList.push_back(delegatedRendererLayer)
; |
152 } | 151 } |
153 | 152 |
154 void CCRenderSurface::clearLayerLists() | 153 void CCRenderSurface::clearLayerLists() |
155 { | 154 { |
156 m_layerList.clear(); | 155 m_layerList.clear(); |
157 m_contributingDelegatedRenderPassLayerList.clear(); | 156 m_contributingDelegatedRenderPassLayerList.clear(); |
158 } | 157 } |
159 | 158 |
160 static inline IntRect computeClippedRectInTarget(const CCLayerImpl* owningLayer) | 159 static inline IntRect computeClippedRectInTarget(const CCLayerImpl* owningLayer) |
161 { | 160 { |
162 DCHECK(owningLayer->parent()); | 161 ASSERT(owningLayer->parent()); |
163 | 162 |
164 const CCLayerImpl* renderTarget = owningLayer->parent()->renderTarget(); | 163 const CCLayerImpl* renderTarget = owningLayer->parent()->renderTarget(); |
165 const CCRenderSurface* self = owningLayer->renderSurface(); | 164 const CCRenderSurface* self = owningLayer->renderSurface(); |
166 | 165 |
167 IntRect clippedRectInTarget = self->clipRect(); | 166 IntRect clippedRectInTarget = self->clipRect(); |
168 if (owningLayer->backgroundFilters().hasFilterThatMovesPixels()) { | 167 if (owningLayer->backgroundFilters().hasFilterThatMovesPixels()) { |
169 // If the layer has background filters that move pixels, we cannot sciss
or as tightly. | 168 // If the layer has background filters that move pixels, we cannot sciss
or as tightly. |
170 // FIXME: this should be able to be a tighter scissor, perhaps expanded
by the filter outsets? | 169 // FIXME: this should be able to be a tighter scissor, perhaps expanded
by the filter outsets? |
171 clippedRectInTarget = renderTarget->renderSurface()->contentRect(); | 170 clippedRectInTarget = renderTarget->renderSurface()->contentRect(); |
172 } else if (clippedRectInTarget.isEmpty()) { | 171 } else if (clippedRectInTarget.isEmpty()) { |
173 // For surfaces, empty clipRect means that the surface does not clip any
thing. | 172 // For surfaces, empty clipRect means that the surface does not clip any
thing. |
174 clippedRectInTarget = enclosingIntRect(intersection(renderTarget->render
Surface()->contentRect(), self->drawableContentRect())); | 173 clippedRectInTarget = enclosingIntRect(intersection(renderTarget->render
Surface()->contentRect(), self->drawableContentRect())); |
175 } else | 174 } else |
176 clippedRectInTarget.intersect(enclosingIntRect(self->drawableContentRect
())); | 175 clippedRectInTarget.intersect(enclosingIntRect(self->drawableContentRect
())); |
177 return clippedRectInTarget; | 176 return clippedRectInTarget; |
178 } | 177 } |
179 | 178 |
180 CCRenderPass::Id CCRenderSurface::renderPassId() | 179 CCRenderPass::Id CCRenderSurface::renderPassId() |
181 { | 180 { |
182 int layerId = m_owningLayer->id(); | 181 int layerId = m_owningLayer->id(); |
183 int subId = 0; | 182 int subId = 0; |
184 DCHECK(layerId > 0); | 183 ASSERT(layerId > 0); |
185 return CCRenderPass::Id(layerId, subId); | 184 return CCRenderPass::Id(layerId, subId); |
186 } | 185 } |
187 | 186 |
188 void CCRenderSurface::appendRenderPasses(CCRenderPassSink& passSink) | 187 void CCRenderSurface::appendRenderPasses(CCRenderPassSink& passSink) |
189 { | 188 { |
190 for (size_t i = 0; i < m_contributingDelegatedRenderPassLayerList.size(); ++
i) | 189 for (size_t i = 0; i < m_contributingDelegatedRenderPassLayerList.size(); ++
i) |
191 m_contributingDelegatedRenderPassLayerList[i]->appendContributingRenderP
asses(passSink); | 190 m_contributingDelegatedRenderPassLayerList[i]->appendContributingRenderP
asses(passSink); |
192 | 191 |
193 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(renderPassId(), m_conte
ntRect, m_screenSpaceTransform); | 192 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(renderPassId(), m_conte
ntRect, m_screenSpaceTransform); |
194 pass->setDamageRect(m_damageTracker->currentDamageRect()); | 193 pass->setDamageRect(m_damageTracker->currentDamageRect()); |
195 pass->setFilters(m_owningLayer->filters()); | 194 pass->setFilters(m_owningLayer->filters()); |
196 pass->setBackgroundFilters(m_owningLayer->backgroundFilters()); | 195 pass->setBackgroundFilters(m_owningLayer->backgroundFilters()); |
197 passSink.appendRenderPass(pass.Pass()); | 196 passSink.appendRenderPass(pass.Pass()); |
198 } | 197 } |
199 | 198 |
200 void CCRenderSurface::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appen
dQuadsData, bool forReplica, CCRenderPass::Id renderPassId) | 199 void CCRenderSurface::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appen
dQuadsData, bool forReplica, CCRenderPass::Id renderPassId) |
201 { | 200 { |
202 DCHECK(!forReplica || m_owningLayer->hasReplica()); | 201 ASSERT(!forReplica || m_owningLayer->hasReplica()); |
203 | 202 |
204 IntRect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); | 203 IntRect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); |
205 bool isOpaque = false; | 204 bool isOpaque = false; |
206 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra
nsform : m_drawTransform; | 205 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra
nsform : m_drawTransform; |
207 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(CCSharedQua
dState::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity,
isOpaque).Pass()); | 206 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(CCSharedQua
dState::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity,
isOpaque).Pass()); |
208 | 207 |
209 if (m_owningLayer->hasDebugBorders()) { | 208 if (m_owningLayer->hasDebugBorders()) { |
210 int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderCo
lorRed; | 209 int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderCo
lorRed; |
211 int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBor
derColorGreen; | 210 int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBor
derColorGreen; |
212 int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorder
ColorBlue; | 211 int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorder
ColorBlue; |
(...skipping 29 matching lines...) Expand all Loading... |
242 } | 241 } |
243 | 242 |
244 CCResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->conte
ntsResourceId() : 0; | 243 CCResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->conte
ntsResourceId() : 0; |
245 IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect :
IntRect(); | 244 IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect :
IntRect(); |
246 | 245 |
247 quadSink.append(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(),
renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, | 246 quadSink.append(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(),
renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, |
248 maskTexCoordScaleX, maskTexCoor
dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<CCDrawQuad>(), appendQ
uadsData); | 247 maskTexCoordScaleX, maskTexCoor
dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<CCDrawQuad>(), appendQ
uadsData); |
249 } | 248 } |
250 | 249 |
251 } | 250 } |
OLD | NEW |