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