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