Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: cc/CCLayerTreeHostImpl.cpp

Issue 10917153: Update cc snapshot to r127918 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCLayerTreeHostImpl.h ('k') | cc/CCLayerTreeHostImplTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "CCLayerTreeHostImpl.h" 7 #include "CCLayerTreeHostImpl.h"
8 8
9 #include "CCActiveGestureAnimation.h"
10 #include "CCAppendQuadsData.h" 9 #include "CCAppendQuadsData.h"
11 #include "CCDamageTracker.h" 10 #include "CCDamageTracker.h"
12 #include "CCDebugRectHistory.h" 11 #include "CCDebugRectHistory.h"
13 #include "CCDelayBasedTimeSource.h" 12 #include "CCDelayBasedTimeSource.h"
14 #include "CCFontAtlas.h" 13 #include "CCFontAtlas.h"
15 #include "CCFrameRateCounter.h" 14 #include "CCFrameRateCounter.h"
16 #include "CCHeadsUpDisplayLayerImpl.h" 15 #include "CCHeadsUpDisplayLayerImpl.h"
17 #include "CCLayerIterator.h" 16 #include "CCLayerIterator.h"
18 #include "CCLayerTreeHost.h" 17 #include "CCLayerTreeHost.h"
19 #include "CCLayerTreeHostCommon.h" 18 #include "CCLayerTreeHostCommon.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 172
174 CCGraphicsContext* CCLayerTreeHostImpl::context() const 173 CCGraphicsContext* CCLayerTreeHostImpl::context() const
175 { 174 {
176 return m_context.get(); 175 return m_context.get();
177 } 176 }
178 177
179 void CCLayerTreeHostImpl::animate(double monotonicTime, double wallClockTime) 178 void CCLayerTreeHostImpl::animate(double monotonicTime, double wallClockTime)
180 { 179 {
181 animatePageScale(monotonicTime); 180 animatePageScale(monotonicTime);
182 animateLayers(monotonicTime, wallClockTime); 181 animateLayers(monotonicTime, wallClockTime);
183 animateGestures(monotonicTime);
184 animateScrollbars(monotonicTime); 182 animateScrollbars(monotonicTime);
185 } 183 }
186 184
187 void CCLayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, double startTime, double duration) 185 void CCLayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, double startTime, double duration)
188 { 186 {
189 if (!m_rootScrollLayerImpl) 187 if (!m_rootScrollLayerImpl)
190 return; 188 return;
191 189
192 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); 190 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
193 scrollTotal.scale(m_pageScaleDelta); 191 scrollTotal.scale(m_pageScaleDelta);
194 float scaleTotal = m_pageScale * m_pageScaleDelta; 192 float scaleTotal = m_pageScale * m_pageScaleDelta;
195 IntSize scaledContentSize = contentSize(); 193 IntSize scaledContentSize = contentSize();
196 scaledContentSize.scale(m_pageScaleDelta); 194 scaledContentSize.scale(m_pageScaleDelta);
197 195
198 m_pageScaleAnimation = CCPageScaleAnimation::create(scrollTotal, scaleTotal, m_deviceViewportSize, scaledContentSize, startTime); 196 m_pageScaleAnimation = CCPageScaleAnimation::create(scrollTotal, scaleTotal, m_deviceViewportSize, scaledContentSize, startTime);
199 197
200 if (anchorPoint) { 198 if (anchorPoint) {
201 IntSize windowAnchor(targetPosition); 199 IntSize windowAnchor(targetPosition);
202 windowAnchor.scale(scaleTotal / pageScale); 200 windowAnchor.scale(scaleTotal / pageScale);
203 windowAnchor -= scrollTotal; 201 windowAnchor -= scrollTotal;
204 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration); 202 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration);
205 } else 203 } else
206 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration); 204 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration);
207 205
208 m_client->setNeedsRedrawOnImplThread(); 206 m_client->setNeedsRedrawOnImplThread();
209 m_client->setNeedsCommitOnImplThread(); 207 m_client->setNeedsCommitOnImplThread();
210 } 208 }
211 209
212 void CCLayerTreeHostImpl::setActiveGestureAnimation(PassOwnPtr<CCActiveGestureAn imation> gestureAnimation)
213 {
214 m_activeGestureAnimation = gestureAnimation;
215
216 if (m_activeGestureAnimation)
217 m_client->setNeedsRedrawOnImplThread();
218 }
219
220 void CCLayerTreeHostImpl::scheduleAnimation() 210 void CCLayerTreeHostImpl::scheduleAnimation()
221 { 211 {
222 m_client->setNeedsRedrawOnImplThread(); 212 m_client->setNeedsRedrawOnImplThread();
223 } 213 }
224 214
225 void CCLayerTreeHostImpl::trackDamageForAllSurfaces(CCLayerImpl* rootDrawLayer, const CCLayerList& renderSurfaceLayerList) 215 void CCLayerTreeHostImpl::trackDamageForAllSurfaces(CCLayerImpl* rootDrawLayer, const CCLayerList& renderSurfaceLayerList)
226 { 216 {
227 // For now, we use damage tracking to compute a global scissor. To do this, we must 217 // For now, we use damage tracking to compute a global scissor. To do this, we must
228 // compute all damage tracking before drawing anything, so that we know the root 218 // compute all damage tracking before drawing anything, so that we know the root
229 // damage rect. The root damage rect is then used to scissor each surface. 219 // damage rect. The root damage rect is then used to scissor each surface.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. 272 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk.
283 typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; 273 typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
284 274
285 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being 275 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being
286 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing 276 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing
287 // in the future. 277 // in the future.
288 bool drawFrame = true; 278 bool drawFrame = true;
289 279
290 CCLayerIteratorType end = CCLayerIteratorType::end(frame.renderSurfaceLayerL ist); 280 CCLayerIteratorType end = CCLayerIteratorType::end(frame.renderSurfaceLayerL ist);
291 for (CCLayerIteratorType it = CCLayerIteratorType::begin(frame.renderSurface LayerList); it != end; ++it) { 281 for (CCLayerIteratorType it = CCLayerIteratorType::begin(frame.renderSurface LayerList); it != end; ++it) {
292 int targetRenderPassId = it.targetRenderSurfaceLayer()->id(); 282 CCRenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->ren derSurface()->renderPassId();
293 CCRenderPass* targetRenderPass = frame.renderPassesById.get(targetRender PassId); 283 CCRenderPass* targetRenderPass = frame.renderPassesById.get(targetRender PassId);
294 284
295 occlusionTracker.enterLayer(it); 285 occlusionTracker.enterLayer(it);
296 286
297 CCAppendQuadsData appendQuadsData; 287 CCAppendQuadsData appendQuadsData;
298 288
299 if (it.representsContributingRenderSurface()) { 289 if (it.representsContributingRenderSurface()) {
300 int contributingRenderPassId = it->id(); 290 CCRenderPass::Id contributingRenderPassId = it->renderSurface()->ren derPassId();
301 CCRenderPass* contributingRenderPass = frame.renderPassesById.get(co ntributingRenderPassId); 291 CCRenderPass* contributingRenderPass = frame.renderPassesById.get(co ntributingRenderPassId);
302 targetRenderPass->appendQuadsForRenderSurfaceLayer(*it, contributing RenderPass, &occlusionTracker, appendQuadsData); 292 targetRenderPass->appendQuadsForRenderSurfaceLayer(*it, contributing RenderPass, &occlusionTracker, appendQuadsData);
303 } else if (it.representsItself() && !it->visibleContentRect().isEmpty()) { 293 } else if (it.representsItself() && !it->visibleContentRect().isEmpty()) {
304 bool hasOcclusionFromOutsideTargetSurface; 294 bool hasOcclusionFromOutsideTargetSurface;
305 if (occlusionTracker.occluded(*it, it->visibleContentRect(), &hasOcc lusionFromOutsideTargetSurface)) 295 if (occlusionTracker.occluded(*it, it->visibleContentRect(), &hasOcc lusionFromOutsideTargetSurface))
306 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; 296 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface;
307 else { 297 else {
308 it->willDraw(m_resourceProvider.get()); 298 it->willDraw(m_resourceProvider.get());
309 frame.willDrawLayers.append(*it); 299 frame.willDrawLayers.append(*it);
310 targetRenderPass->appendQuadsForLayer(*it, &occlusionTracker, ap pendQuadsData); 300 targetRenderPass->appendQuadsForLayer(*it, &occlusionTracker, ap pendQuadsData);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 375
386 IntSize CCLayerTreeHostImpl::contentSize() const 376 IntSize CCLayerTreeHostImpl::contentSize() const
387 { 377 {
388 // TODO(aelias): Hardcoding the first child here is weird. Think of 378 // TODO(aelias): Hardcoding the first child here is weird. Think of
389 // a cleaner way to get the contentBounds on the Impl side. 379 // a cleaner way to get the contentBounds on the Impl side.
390 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) 380 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty())
391 return IntSize(); 381 return IntSize();
392 return m_rootScrollLayerImpl->children()[0]->contentBounds(); 382 return m_rootScrollLayerImpl->children()[0]->contentBounds();
393 } 383 }
394 384
395 static inline CCRenderPass* findRenderPassById(int renderPassId, const CCLayerTr eeHostImpl::FrameData& frame) 385 static inline CCRenderPass* findRenderPassById(CCRenderPass::Id renderPassId, co nst CCLayerTreeHostImpl::FrameData& frame)
396 { 386 {
397 CCRenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(rende rPassId); 387 CCRenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(rende rPassId);
398 ASSERT(it != frame.renderPassesById.end()); 388 ASSERT(it != frame.renderPassesById.end());
399 return it->second.get(); 389 return it->second.get();
400 } 390 }
401 391
402 static void removeRenderPassesRecursive(int removeRenderPassId, CCLayerTreeHostI mpl::FrameData& frame) 392 static void removeRenderPassesRecursive(CCRenderPass::Id removeRenderPassId, CCL ayerTreeHostImpl::FrameData& frame)
403 { 393 {
404 CCRenderPass* removeRenderPass = findRenderPassById(removeRenderPassId, fram e); 394 CCRenderPass* removeRenderPass = findRenderPassById(removeRenderPassId, fram e);
405 size_t removeIndex = frame.renderPasses.find(removeRenderPass); 395 size_t removeIndex = frame.renderPasses.find(removeRenderPass);
406 396
407 // The pass was already removed by another quad - probably the original, and we are the replica. 397 // The pass was already removed by another quad - probably the original, and we are the replica.
408 if (removeIndex == notFound) 398 if (removeIndex == notFound)
409 return; 399 return;
410 400
411 const CCRenderPass* removedPass = frame.renderPasses[removeIndex]; 401 const CCRenderPass* removedPass = frame.renderPasses[removeIndex];
412 frame.renderPasses.remove(removeIndex); 402 frame.renderPasses.remove(removeIndex);
413 403
414 // Now follow up for all RenderPass quads and remove their RenderPasses recu rsively. 404 // Now follow up for all RenderPass quads and remove their RenderPasses recu rsively.
415 const CCQuadList& quadList = removedPass->quadList(); 405 const CCQuadList& quadList = removedPass->quadList();
416 CCQuadList::constBackToFrontIterator quadListIterator = quadList.backToFront Begin(); 406 CCQuadList::constBackToFrontIterator quadListIterator = quadList.backToFront Begin();
417 for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { 407 for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) {
418 CCDrawQuad* currentQuad = (*quadListIterator).get(); 408 CCDrawQuad* currentQuad = (*quadListIterator).get();
419 if (currentQuad->material() != CCDrawQuad::RenderPass) 409 if (currentQuad->material() != CCDrawQuad::RenderPass)
420 continue; 410 continue;
421 411
422 int nextRemoveRenderPassId = CCRenderPassDrawQuad::materialCast(currentQ uad)->renderPassId(); 412 CCRenderPass::Id nextRemoveRenderPassId = CCRenderPassDrawQuad::material Cast(currentQuad)->renderPassId();
423 removeRenderPassesRecursive(nextRemoveRenderPassId, frame); 413 removeRenderPassesRecursive(nextRemoveRenderPassId, frame);
424 } 414 }
425 } 415 }
426 416
427 bool CCLayerTreeHostImpl::CullRenderPassesWithCachedTextures::shouldRemoveRender Pass(const CCRenderPassDrawQuad& quad, const FrameData&) const 417 bool CCLayerTreeHostImpl::CullRenderPassesWithCachedTextures::shouldRemoveRender Pass(const CCRenderPassDrawQuad& quad, const FrameData&) const
428 { 418 {
429 return quad.contentsChangedSinceLastFrame().isEmpty() && m_renderer.haveCach edResourcesForRenderPassId(quad.renderPassId()); 419 return quad.contentsChangedSinceLastFrame().isEmpty() && m_renderer.haveCach edResourcesForRenderPassId(quad.renderPassId());
430 } 420 }
431 421
432 bool CCLayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(co nst CCRenderPassDrawQuad& quad, const FrameData& frame) const 422 bool CCLayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(co nst CCRenderPassDrawQuad& quad, const FrameData& frame) const
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1234
1245 void CCLayerTreeHostImpl::dumpRenderSurfaces(TextStream& ts, int indent, const C CLayerImpl* layer) const 1235 void CCLayerTreeHostImpl::dumpRenderSurfaces(TextStream& ts, int indent, const C CLayerImpl* layer) const
1246 { 1236 {
1247 if (layer->renderSurface()) 1237 if (layer->renderSurface())
1248 layer->renderSurface()->dumpSurface(ts, indent); 1238 layer->renderSurface()->dumpSurface(ts, indent);
1249 1239
1250 for (size_t i = 0; i < layer->children().size(); ++i) 1240 for (size_t i = 0; i < layer->children().size(); ++i)
1251 dumpRenderSurfaces(ts, indent, layer->children()[i].get()); 1241 dumpRenderSurfaces(ts, indent, layer->children()[i].get());
1252 } 1242 }
1253 1243
1254
1255 void CCLayerTreeHostImpl::animateGestures(double monotonicTime)
1256 {
1257 if (!m_activeGestureAnimation)
1258 return;
1259
1260 bool isContinuing = m_activeGestureAnimation->animate(monotonicTime);
1261 if (isContinuing)
1262 m_client->setNeedsRedrawOnImplThread();
1263 else
1264 m_activeGestureAnimation.clear();
1265 }
1266
1267 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const 1244 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const
1268 { 1245 {
1269 return fpsCounter()->currentFrameNumber(); 1246 return fpsCounter()->currentFrameNumber();
1270 } 1247 }
1271 1248
1272 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats& stats) const 1249 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats& stats) const
1273 { 1250 {
1274 stats.numFramesSentToScreen = fpsCounter()->currentFrameNumber(); 1251 stats.numFramesSentToScreen = fpsCounter()->currentFrameNumber();
1275 stats.droppedFrameCount = fpsCounter()->droppedFrameCount(); 1252 stats.droppedFrameCount = fpsCounter()->droppedFrameCount();
1276 } 1253 }
(...skipping 10 matching lines...) Expand all
1287 1264
1288 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController(); 1265 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController();
1289 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1266 if (scrollbarController && scrollbarController->animate(monotonicTime))
1290 m_client->setNeedsRedrawOnImplThread(); 1267 m_client->setNeedsRedrawOnImplThread();
1291 1268
1292 for (size_t i = 0; i < layer->children().size(); ++i) 1269 for (size_t i = 0; i < layer->children().size(); ++i)
1293 animateScrollbarsRecursive(layer->children()[i].get(), monotonicTime); 1270 animateScrollbarsRecursive(layer->children()[i].get(), monotonicTime);
1294 } 1271 }
1295 1272
1296 } // namespace WebCore 1273 } // namespace WebCore
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostImpl.h ('k') | cc/CCLayerTreeHostImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698