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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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/layer_tree_host_common_unittest.cc ('k') | cc/layer_tree_host_impl_unittest.cc » ('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 "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 sendManagedMemoryStats(memoryRequiredBytes, 281 sendManagedMemoryStats(memoryRequiredBytes,
282 memoryNiceToHaveBytes, 282 memoryNiceToHaveBytes,
283 memoryUsedBytes); 283 memoryUsedBytes);
284 } 284 }
285 285
286 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati on) 286 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati on)
287 { 287 {
288 if (!rootScrollLayer()) 288 if (!rootScrollLayer())
289 return; 289 return;
290 290
291 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); 291 gfx::Vector2dF scrollTotal = rootScrollLayer()->scroll_offset() + rootScroll Layer()->scroll_delta();
292 gfx::SizeF scaledScrollableSize = activeTree()->ScrollableSize(); 292 gfx::SizeF scaledScrollableSize = activeTree()->ScrollableSize();
293 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS caleFactor); 293 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS caleFactor);
294 294
295 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); 295 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
296 m_pageScaleAnimation = PageScaleAnimation::Create(scrollTotal, activeTree()- >total_page_scale_factor(), viewportSize, scaledScrollableSize, startTimeSeconds ); 296 m_pageScaleAnimation = PageScaleAnimation::Create(scrollTotal, activeTree()- >total_page_scale_factor(), viewportSize, scaledScrollableSize, startTimeSeconds );
297 297
298 if (anchorPoint) { 298 if (anchorPoint) {
299 gfx::Vector2dF anchor(targetOffset); 299 gfx::Vector2dF anchor(targetOffset);
300 m_pageScaleAnimation->ZoomWithAnchor(anchor, pageScale, duration.InSecon dsF()); 300 m_pageScaleAnimation->ZoomWithAnchor(anchor, pageScale, duration.InSecon dsF());
301 } else { 301 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 void LayerTreeHostImpl::trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, cons t LayerList& renderSurfaceLayerList) 336 void LayerTreeHostImpl::trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, cons t LayerList& renderSurfaceLayerList)
337 { 337 {
338 // For now, we use damage tracking to compute a global scissor. To do this, we must 338 // For now, we use damage tracking to compute a global scissor. To do this, we must
339 // compute all damage tracking before drawing anything, so that we know the root 339 // compute all damage tracking before drawing anything, so that we know the root
340 // damage rect. The root damage rect is then used to scissor each surface. 340 // damage rect. The root damage rect is then used to scissor each surface.
341 341
342 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { 342 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
343 LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; 343 LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
344 RenderSurfaceImpl* renderSurface = renderSurfaceLayer->renderSurface(); 344 RenderSurfaceImpl* renderSurface = renderSurfaceLayer->render_surface();
345 DCHECK(renderSurface); 345 DCHECK(renderSurface);
346 renderSurface->damage_tracker()->UpdateDamageTrackingState(renderSurface ->layer_list(), renderSurfaceLayer->id(), renderSurface->SurfacePropertyChangedO nlyFromDescendant(), renderSurface->content_rect(), renderSurfaceLayer->maskLaye r(), renderSurfaceLayer->filters(), renderSurfaceLayer->filter().get()); 346 renderSurface->damage_tracker()->UpdateDamageTrackingState(renderSurface ->layer_list(), renderSurfaceLayer->id(), renderSurface->SurfacePropertyChangedO nlyFromDescendant(), renderSurface->content_rect(), renderSurfaceLayer->mask_lay er(), renderSurfaceLayer->filters(), renderSurfaceLayer->filter().get());
347 } 347 }
348 } 348 }
349 349
350 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass) 350 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass)
351 { 351 {
352 renderPassesById[renderPass->id] = renderPass.get(); 352 renderPassesById[renderPass->id] = renderPass.get();
353 renderPasses.push_back(renderPass.Pass()); 353 renderPasses.push_back(renderPass.Pass());
354 } 354 }
355 355
356 static void appendQuadsForLayer(RenderPass* targetRenderPass, LayerImpl* layer, OcclusionTrackerImpl& occlusionTracker, AppendQuadsData& appendQuadsData) 356 static void appendQuadsForLayer(RenderPass* targetRenderPass, LayerImpl* layer, OcclusionTrackerImpl& occlusionTracker, AppendQuadsData& appendQuadsData)
357 { 357 {
358 bool forSurface = false; 358 bool forSurface = false;
359 QuadCuller quadCuller(targetRenderPass->quad_list, 359 QuadCuller quadCuller(targetRenderPass->quad_list,
360 targetRenderPass->shared_quad_state_list, 360 targetRenderPass->shared_quad_state_list,
361 layer, 361 layer,
362 occlusionTracker, 362 occlusionTracker,
363 layer->showDebugBorders(), 363 layer->ShowDebugBorders(),
364 forSurface); 364 forSurface);
365 layer->appendQuads(quadCuller, appendQuadsData); 365 layer->AppendQuads(&quadCuller, &appendQuadsData);
366 } 366 }
367 367
368 static void appendQuadsForRenderSurfaceLayer(RenderPass* targetRenderPass, Layer Impl* layer, const RenderPass* contributingRenderPass, OcclusionTrackerImpl& occ lusionTracker, AppendQuadsData& appendQuadsData) 368 static void appendQuadsForRenderSurfaceLayer(RenderPass* targetRenderPass, Layer Impl* layer, const RenderPass* contributingRenderPass, OcclusionTrackerImpl& occ lusionTracker, AppendQuadsData& appendQuadsData)
369 { 369 {
370 bool forSurface = true; 370 bool forSurface = true;
371 QuadCuller quadCuller(targetRenderPass->quad_list, 371 QuadCuller quadCuller(targetRenderPass->quad_list,
372 targetRenderPass->shared_quad_state_list, 372 targetRenderPass->shared_quad_state_list,
373 layer, 373 layer,
374 occlusionTracker, 374 occlusionTracker,
375 layer->showDebugBorders(), 375 layer->ShowDebugBorders(),
376 forSurface); 376 forSurface);
377 377
378 bool isReplica = false; 378 bool isReplica = false;
379 layer->renderSurface()->AppendQuads(&quadCuller, 379 layer->render_surface()->AppendQuads(&quadCuller,
380 &appendQuadsData, 380 &appendQuadsData,
381 isReplica, 381 isReplica,
382 contributingRenderPass->id); 382 contributingRenderPass->id);
383 383
384 // Add replica after the surface so that it appears below the surface. 384 // Add replica after the surface so that it appears below the surface.
385 if (layer->hasReplica()) { 385 if (layer->has_replica()) {
386 isReplica = true; 386 isReplica = true;
387 layer->renderSurface()->AppendQuads(&quadCuller, 387 layer->render_surface()->AppendQuads(&quadCuller,
388 &appendQuadsData, 388 &appendQuadsData,
389 isReplica, 389 isReplica,
390 contributingRenderPass->id); 390 contributingRenderPass->id);
391 } 391 }
392 } 392 }
393 393
394 static void appendQuadsToFillScreen(RenderPass* targetRenderPass, LayerImpl* roo tLayer, SkColor screenBackgroundColor, const OcclusionTrackerImpl& occlusionTrac ker) 394 static void appendQuadsToFillScreen(RenderPass* targetRenderPass, LayerImpl* roo tLayer, SkColor screenBackgroundColor, const OcclusionTrackerImpl& occlusionTrac ker)
395 { 395 {
396 if (!rootLayer || !SkColorGetA(screenBackgroundColor)) 396 if (!rootLayer || !SkColorGetA(screenBackgroundColor))
397 return; 397 return;
398 398
399 Region fillRegion = occlusionTracker.ComputeVisibleRegionInScreen(); 399 Region fillRegion = occlusionTracker.ComputeVisibleRegionInScreen();
400 if (fillRegion.IsEmpty()) 400 if (fillRegion.IsEmpty())
401 return; 401 return;
402 402
403 bool forSurface = false; 403 bool forSurface = false;
404 QuadCuller quadCuller(targetRenderPass->quad_list, 404 QuadCuller quadCuller(targetRenderPass->quad_list,
405 targetRenderPass->shared_quad_state_list, 405 targetRenderPass->shared_quad_state_list,
406 rootLayer, 406 rootLayer,
407 occlusionTracker, 407 occlusionTracker,
408 rootLayer->showDebugBorders(), 408 rootLayer->ShowDebugBorders(),
409 forSurface); 409 forSurface);
410 410
411 // Manually create the quad state for the gutter quads, as the root layer 411 // Manually create the quad state for the gutter quads, as the root layer
412 // doesn't have any bounds and so can't generate this itself. 412 // doesn't have any bounds and so can't generate this itself.
413 // FIXME: Make the gutter quads generated by the solid color layer (make it smarter about generating quads to fill unoccluded areas). 413 // FIXME: Make the gutter quads generated by the solid color layer (make it smarter about generating quads to fill unoccluded areas).
414 414
415 gfx::Rect rootTargetRect = rootLayer->renderSurface()->content_rect(); 415 gfx::Rect rootTargetRect = rootLayer->render_surface()->content_rect();
416 float opacity = 1; 416 float opacity = 1;
417 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS tate::Create()); 417 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS tate::Create());
418 sharedQuadState->SetAll(rootLayer->drawTransform(), 418 sharedQuadState->SetAll(rootLayer->draw_transform(),
419 rootTargetRect.size(), 419 rootTargetRect.size(),
420 rootTargetRect, 420 rootTargetRect,
421 rootTargetRect, 421 rootTargetRect,
422 false, 422 false,
423 opacity); 423 opacity);
424 424
425 AppendQuadsData appendQuadsData; 425 AppendQuadsData appendQuadsData;
426 426
427 gfx::Transform transformToLayerSpace(gfx::Transform::kSkipInitialization); 427 gfx::Transform transformToLayerSpace(gfx::Transform::kSkipInitialization);
428 bool didInvert = rootLayer->screenSpaceTransform().GetInverse(&transformToLa yerSpace); 428 bool didInvert = rootLayer->screen_space_transform().GetInverse(&transformTo LayerSpace);
429 DCHECK(didInvert); 429 DCHECK(didInvert);
430 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects .next()) { 430 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects .next()) {
431 // The root layer transform is composed of translations and scales only, 431 // The root layer transform is composed of translations and scales only,
432 // no perspective, so mapping is sufficient (as opposed to projecting). 432 // no perspective, so mapping is sufficient (as opposed to projecting).
433 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi llRects.rect()); 433 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi llRects.rect());
434 // Skip the quad culler and just append the quads directly to avoid 434 // Skip the quad culler and just append the quads directly to avoid
435 // occlusion checks. 435 // occlusion checks.
436 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 436 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
437 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); 437 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor);
438 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); 438 quadCuller.append(quad.PassAs<DrawQuad>(), &appendQuadsData);
439 } 439 }
440 } 440 }
441 441
442 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) 442 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame)
443 { 443 {
444 DCHECK(frame.renderPasses.empty()); 444 DCHECK(frame.renderPasses.empty());
445 445
446 if (!canDraw() || !rootLayer()) 446 if (!canDraw() || !rootLayer())
447 return false; 447 return false;
448 448
449 trackDamageForAllSurfaces(rootLayer(), *frame.renderSurfaceLayerList); 449 trackDamageForAllSurfaces(rootLayer(), *frame.renderSurfaceLayerList);
450 450
451 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size())); 451 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size()));
452 452
453 // Create the render passes in dependency order. 453 // Create the render passes in dependency order.
454 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { 454 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) {
455 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; 455 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex];
456 renderSurfaceLayer->renderSurface()->AppendRenderPasses(&frame); 456 renderSurfaceLayer->render_surface()->AppendRenderPasses(&frame);
457 } 457 }
458 458
459 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); 459 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled();
460 OcclusionTrackerImpl occlusionTracker(rootLayer()->renderSurface()->content_ rect(), recordMetricsForFrame); 460 OcclusionTrackerImpl occlusionTracker(rootLayer()->render_surface()->content _rect(), recordMetricsForFrame);
461 occlusionTracker.set_minimum_tracking_size(m_settings.minimumOcclusionTracki ngSize); 461 occlusionTracker.set_minimum_tracking_size(m_settings.minimumOcclusionTracki ngSize);
462 462
463 if (m_debugState.showOccludingRects) 463 if (m_debugState.showOccludingRects)
464 occlusionTracker.set_occluding_screen_space_rects_container(&frame.occlu dingScreenSpaceRects); 464 occlusionTracker.set_occluding_screen_space_rects_container(&frame.occlu dingScreenSpaceRects);
465 if (m_debugState.showNonOccludingRects) 465 if (m_debugState.showNonOccludingRects)
466 occlusionTracker.set_non_occluding_screen_space_rects_container(&frame.n onOccludingScreenSpaceRects); 466 occlusionTracker.set_non_occluding_screen_space_rects_container(&frame.n onOccludingScreenSpaceRects);
467 467
468 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. 468 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk.
469 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; 469 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType;
470 470
471 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being 471 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being
472 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing 472 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing
473 // in the future. 473 // in the future.
474 bool drawFrame = true; 474 bool drawFrame = true;
475 475
476 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; 476 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ;
477 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) { 477 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) {
478 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende rSurface()->RenderPassId(); 478 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende r_surface()->RenderPassId();
479 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ]; 479 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ];
480 480
481 occlusionTracker.EnterLayer(it); 481 occlusionTracker.EnterLayer(it);
482 482
483 AppendQuadsData appendQuadsData(targetRenderPass->id); 483 AppendQuadsData appendQuadsData(targetRenderPass->id);
484 484
485 if (it.representsContributingRenderSurface()) { 485 if (it.representsContributingRenderSurface()) {
486 RenderPass::Id contributingRenderPassId = it->renderSurface()->Rende rPassId(); 486 RenderPass::Id contributingRenderPassId = it->render_surface()->Rend erPassId();
487 RenderPass* contributingRenderPass = frame.renderPassesById[contribu tingRenderPassId]; 487 RenderPass* contributingRenderPass = frame.renderPassesById[contribu tingRenderPassId];
488 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData); 488 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData);
489 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty()) { 489 } else if (it.representsItself() && !it->visible_content_rect().IsEmpty( )) {
490 bool hasOcclusionFromOutsideTargetSurface; 490 bool hasOcclusionFromOutsideTargetSurface;
491 bool implDrawTransformIsUnknown = false; 491 bool implDrawTransformIsUnknown = false;
492 if (occlusionTracker.Occluded(it->renderTarget(), it->visibleContent Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->isClipped(), it->cl ipRect(), &hasOcclusionFromOutsideTargetSurface)) 492 if (occlusionTracker.Occluded(it->render_target(), it->visible_conte nt_rect(), it->draw_transform(), implDrawTransformIsUnknown, it->is_clipped(), i t->clip_rect(), &hasOcclusionFromOutsideTargetSurface))
493 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; 493 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface;
494 else { 494 else {
495 DCHECK_EQ(activeTree(), it->layerTreeImpl()); 495 DCHECK_EQ(activeTree(), it->layer_tree_impl());
496 it->willDraw(m_resourceProvider.get()); 496 it->WillDraw(m_resourceProvider.get());
497 frame.willDrawLayers.push_back(*it); 497 frame.willDrawLayers.push_back(*it);
498 498
499 if (it->hasContributingDelegatedRenderPasses()) { 499 if (it->HasContributingDelegatedRenderPasses()) {
500 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); 500 RenderPass::Id contributingRenderPassId = it->FirstContribut ingRenderPassId();
501 while (frame.renderPassesById.find(contributingRenderPassId) != frame.renderPassesById.end()) { 501 while (frame.renderPassesById.find(contributingRenderPassId) != frame.renderPassesById.end()) {
502 RenderPass* renderPass = frame.renderPassesById[contribu tingRenderPassId]; 502 RenderPass* renderPass = frame.renderPassesById[contribu tingRenderPassId];
503 503
504 AppendQuadsData appendQuadsData(renderPass->id); 504 AppendQuadsData appendQuadsData(renderPass->id);
505 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); 505 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData);
506 506
507 contributingRenderPassId = it->nextContributingRenderPas sId(contributingRenderPassId); 507 contributingRenderPassId = it->NextContributingRenderPas sId(contributingRenderPassId);
508 } 508 }
509 } 509 }
510 510
511 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app endQuadsData); 511 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app endQuadsData);
512 } 512 }
513 513
514 ++m_cumulativeNumLayersDrawn; 514 ++m_cumulativeNumLayersDrawn;
515 } 515 }
516 516
517 if (appendQuadsData.hadOcclusionFromOutsideTargetSurface) 517 if (appendQuadsData.hadOcclusionFromOutsideTargetSurface)
518 targetRenderPass->has_occlusion_from_outside_target_surface = true; 518 targetRenderPass->has_occlusion_from_outside_target_surface = true;
519 519
520 if (appendQuadsData.numMissingTiles) { 520 if (appendQuadsData.numMissingTiles) {
521 m_cumulativeNumMissingTiles += appendQuadsData.numMissingTiles; 521 m_cumulativeNumMissingTiles += appendQuadsData.numMissingTiles;
522 bool layerHasAnimatingTransform = it->screenSpaceTransformIsAnimatin g() || it->drawTransformIsAnimating(); 522 bool layerHasAnimatingTransform = it->screen_space_transform_is_anim ating() || it->draw_transform_is_animating();
523 if (layerHasAnimatingTransform) 523 if (layerHasAnimatingTransform)
524 drawFrame = false; 524 drawFrame = false;
525 } 525 }
526 526
527 if (appendQuadsData.hadIncompleteTile) 527 if (appendQuadsData.hadIncompleteTile)
528 frame.containsIncompleteTile = true; 528 frame.containsIncompleteTile = true;
529 529
530 occlusionTracker.LeaveLayer(it); 530 occlusionTracker.LeaveLayer(it);
531 } 531 }
532 532
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 metadata.min_page_scale_factor = activeTree()->min_page_scale_factor(); 782 metadata.min_page_scale_factor = activeTree()->min_page_scale_factor();
783 metadata.max_page_scale_factor = activeTree()->max_page_scale_factor(); 783 metadata.max_page_scale_factor = activeTree()->max_page_scale_factor();
784 if (m_topControlsManager) { 784 if (m_topControlsManager) {
785 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset()); 785 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset());
786 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset()); 786 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset());
787 } 787 }
788 788
789 if (!rootScrollLayer()) 789 if (!rootScrollLayer())
790 return metadata; 790 return metadata;
791 791
792 metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScroll Layer()->scrollDelta(); 792 metadata.root_scroll_offset = rootScrollLayer()->scroll_offset() + rootScrol lLayer()->scroll_delta();
793 793
794 return metadata; 794 return metadata;
795 } 795 }
796 796
797 void LayerTreeHostImpl::drawLayers(FrameData& frame) 797 void LayerTreeHostImpl::drawLayers(FrameData& frame)
798 { 798 {
799 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); 799 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers");
800 DCHECK(canDraw()); 800 DCHECK(canDraw());
801 DCHECK(!frame.renderPasses.empty()); 801 DCHECK(!frame.renderPasses.empty());
802 802
(...skipping 20 matching lines...) Expand all
823 if (m_activeTree->hud_layer()) 823 if (m_activeTree->hud_layer())
824 m_activeTree->hud_layer()->updateHudTexture(m_resourceProvider.get()); 824 m_activeTree->hud_layer()->updateHudTexture(m_resourceProvider.get());
825 825
826 m_renderer->DrawFrame(frame.renderPasses); 826 m_renderer->DrawFrame(frame.renderPasses);
827 // The render passes should be consumed by the renderer. 827 // The render passes should be consumed by the renderer.
828 DCHECK(frame.renderPasses.empty()); 828 DCHECK(frame.renderPasses.empty());
829 frame.renderPassesById.clear(); 829 frame.renderPassesById.clear();
830 830
831 // The next frame should start by assuming nothing has changed, and changes are noted as they occur. 831 // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
832 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) 832 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++)
833 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damage_tracker()->D idDrawDamagedArea(); 833 (*frame.renderSurfaceLayerList)[i]->render_surface()->damage_tracker()-> DidDrawDamagedArea();
834 rootLayer()->resetAllChangeTrackingForSubtree(); 834 rootLayer()->ResetAllChangeTrackingForSubtree();
835 updateAnimationState(); 835 updateAnimationState();
836 } 836 }
837 837
838 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) 838 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame)
839 { 839 {
840 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) 840 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i)
841 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); 841 frame.willDrawLayers[i]->DidDraw(m_resourceProvider.get());
842 842
843 // Once all layers have been drawn, pending texture uploads should no 843 // Once all layers have been drawn, pending texture uploads should no
844 // longer block future uploads. 844 // longer block future uploads.
845 m_resourceProvider->MarkPendingUploadsAsNonBlocking(); 845 m_resourceProvider->MarkPendingUploadsAsNonBlocking();
846 } 846 }
847 847
848 void LayerTreeHostImpl::finishAllRendering() 848 void LayerTreeHostImpl::finishAllRendering()
849 { 849 {
850 if (m_renderer) 850 if (m_renderer)
851 m_renderer->Finish(); 851 m_renderer->Finish();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 DCHECK(m_renderer); 894 DCHECK(m_renderer);
895 m_renderer->GetFramebufferPixels(pixels, rect); 895 m_renderer->GetFramebufferPixels(pixels, rect);
896 } 896 }
897 897
898 bool LayerTreeHostImpl::haveRootScrollLayer() const { 898 bool LayerTreeHostImpl::haveRootScrollLayer() const {
899 return rootScrollLayer(); 899 return rootScrollLayer();
900 } 900 }
901 901
902 float LayerTreeHostImpl::rootScrollLayerTotalScrollY() const { 902 float LayerTreeHostImpl::rootScrollLayerTotalScrollY() const {
903 if (LayerImpl* layer = rootScrollLayer()) 903 if (LayerImpl* layer = rootScrollLayer())
904 return layer->scrollOffset().y() + layer->scrollDelta().y(); 904 return layer->scroll_offset().y() + layer->scroll_delta().y();
905 return 0.0f; 905 return 0.0f;
906 } 906 }
907 907
908 LayerImpl* LayerTreeHostImpl::rootLayer() const 908 LayerImpl* LayerTreeHostImpl::rootLayer() const
909 { 909 {
910 return m_activeTree->RootLayer(); 910 return m_activeTree->RootLayer();
911 } 911 }
912 912
913 LayerImpl* LayerTreeHostImpl::rootScrollLayer() const 913 LayerImpl* LayerTreeHostImpl::rootScrollLayer() const
914 { 914 {
915 return m_activeTree->RootScrollLayer(); 915 return m_activeTree->RootScrollLayer();
916 } 916 }
917 917
918 LayerImpl* LayerTreeHostImpl::currentlyScrollingLayer() const 918 LayerImpl* LayerTreeHostImpl::currentlyScrollingLayer() const
919 { 919 {
920 return m_activeTree->CurrentlyScrollingLayer(); 920 return m_activeTree->CurrentlyScrollingLayer();
921 } 921 }
922 922
923 // Content layers can be either directly scrollable or contained in an outer 923 // Content layers can be either directly scrollable or contained in an outer
924 // scrolling layer which applies the scroll transform. Given a content layer, 924 // scrolling layer which applies the scroll transform. Given a content layer,
925 // this function returns the associated scroll layer if any. 925 // this function returns the associated scroll layer if any.
926 static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl) 926 static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl)
927 { 927 {
928 if (!layerImpl) 928 if (!layerImpl)
929 return 0; 929 return 0;
930 930
931 if (layerImpl->scrollable()) 931 if (layerImpl->scrollable())
932 return layerImpl; 932 return layerImpl;
933 933
934 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable()) 934 if (layerImpl->DrawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable())
935 return layerImpl->parent(); 935 return layerImpl->parent();
936 936
937 return 0; 937 return 0;
938 } 938 }
939 939
940 void LayerTreeHostImpl::createPendingTree() 940 void LayerTreeHostImpl::createPendingTree()
941 { 941 {
942 CHECK(!m_pendingTree); 942 CHECK(!m_pendingTree);
943 if (m_recycleTree) 943 if (m_recycleTree)
944 m_recycleTree.swap(m_pendingTree); 944 m_recycleTree.swap(m_pendingTree);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 { 998 {
999 CHECK(m_pendingTree); 999 CHECK(m_pendingTree);
1000 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", m_pendingTree.get()); 1000 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", m_pendingTree.get());
1001 1001
1002 m_activeTree->PushPersistedState(m_pendingTree.get()); 1002 m_activeTree->PushPersistedState(m_pendingTree.get());
1003 if (m_pendingTree->needs_full_tree_sync()) 1003 if (m_pendingTree->needs_full_tree_sync())
1004 m_activeTree->SetRootLayer(TreeSynchronizer::synchronizeTrees(m_pendingT ree->RootLayer(), m_activeTree->DetachLayerTree(), m_activeTree.get())); 1004 m_activeTree->SetRootLayer(TreeSynchronizer::synchronizeTrees(m_pendingT ree->RootLayer(), m_activeTree->DetachLayerTree(), m_activeTree.get()));
1005 TreeSynchronizer::pushProperties(m_pendingTree->RootLayer(), m_activeTree->R ootLayer()); 1005 TreeSynchronizer::pushProperties(m_pendingTree->RootLayer(), m_activeTree->R ootLayer());
1006 DCHECK(!m_recycleTree); 1006 DCHECK(!m_recycleTree);
1007 1007
1008 m_pendingTree->pushPropertiesTo(m_activeTree.get()); 1008 m_pendingTree->PushPropertiesTo(m_activeTree.get());
1009 1009
1010 // Now that we've synced everything from the pending tree to the active 1010 // Now that we've synced everything from the pending tree to the active
1011 // tree, rename the pending tree the recycle tree so we can reuse it on the 1011 // tree, rename the pending tree the recycle tree so we can reuse it on the
1012 // next sync. 1012 // next sync.
1013 m_pendingTree.swap(m_recycleTree); 1013 m_pendingTree.swap(m_recycleTree);
1014 m_recycleTree->ClearRenderSurfaces(); 1014 m_recycleTree->ClearRenderSurfaces();
1015 1015
1016 m_activeTree->DidBecomeActive(); 1016 m_activeTree->DidBecomeActive();
1017 1017
1018 // Reduce wasted memory now that unlinked resources are guaranteed not 1018 // Reduce wasted memory now that unlinked resources are guaranteed not
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 m_client->onCanDrawStateChanged(canDraw()); 1131 m_client->onCanDrawStateChanged(canDraw());
1132 } 1132 }
1133 1133
1134 static void adjustScrollsForPageScaleChange(LayerImpl* layerImpl, float pageScal eChange) 1134 static void adjustScrollsForPageScaleChange(LayerImpl* layerImpl, float pageScal eChange)
1135 { 1135 {
1136 if (!layerImpl) 1136 if (!layerImpl)
1137 return; 1137 return;
1138 1138
1139 if (layerImpl->scrollable()) { 1139 if (layerImpl->scrollable()) {
1140 // We need to convert impl-side scroll deltas to pageScale space. 1140 // We need to convert impl-side scroll deltas to pageScale space.
1141 gfx::Vector2dF scrollDelta = layerImpl->scrollDelta(); 1141 gfx::Vector2dF scrollDelta = layerImpl->scroll_delta();
1142 scrollDelta.Scale(pageScaleChange); 1142 scrollDelta.Scale(pageScaleChange);
1143 layerImpl->setScrollDelta(scrollDelta); 1143 layerImpl->SetScrollDelta(scrollDelta);
1144 } 1144 }
1145 1145
1146 for (size_t i = 0; i < layerImpl->children().size(); ++i) 1146 for (size_t i = 0; i < layerImpl->children().size(); ++i)
1147 adjustScrollsForPageScaleChange(layerImpl->children()[i], pageScaleChang e); 1147 adjustScrollsForPageScaleChange(layerImpl->children()[i], pageScaleChang e);
1148 } 1148 }
1149 1149
1150 void LayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor) 1150 void LayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor)
1151 { 1151 {
1152 if (deviceScaleFactor == m_deviceScaleFactor) 1152 if (deviceScaleFactor == m_deviceScaleFactor)
1153 return; 1153 return;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); 1193 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor);
1194 1194
1195 // First find out which layer was hit from the saved list of visible layers 1195 // First find out which layer was hit from the saved list of visible layers
1196 // in the most recent frame. 1196 // in the most recent frame.
1197 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); 1197 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList());
1198 1198
1199 // Walk up the hierarchy and look for a scrollable layer. 1199 // Walk up the hierarchy and look for a scrollable layer.
1200 LayerImpl* potentiallyScrollingLayerImpl = 0; 1200 LayerImpl* potentiallyScrollingLayerImpl = 0;
1201 for (; layerImpl; layerImpl = layerImpl->parent()) { 1201 for (; layerImpl; layerImpl = layerImpl->parent()) {
1202 // The content layer can also block attempts to scroll outside the main thread. 1202 // The content layer can also block attempts to scroll outside the main thread.
1203 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { 1203 if (layerImpl->TryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) {
1204 m_numMainThreadScrolls++; 1204 m_numMainThreadScrolls++;
1205 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 1205 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
1206 return ScrollOnMainThread; 1206 return ScrollOnMainThread;
1207 } 1207 }
1208 1208
1209 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); 1209 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl);
1210 if (!scrollLayerImpl) 1210 if (!scrollLayerImpl)
1211 continue; 1211 continue;
1212 1212
1213 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty pe); 1213 ScrollStatus status = scrollLayerImpl->TryScroll(deviceViewportPoint, ty pe);
1214 1214
1215 // If any layer wants to divert the scroll event to the main thread, abo rt. 1215 // If any layer wants to divert the scroll event to the main thread, abo rt.
1216 if (status == ScrollOnMainThread) { 1216 if (status == ScrollOnMainThread) {
1217 m_numMainThreadScrolls++; 1217 m_numMainThreadScrolls++;
1218 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 1218 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
1219 return ScrollOnMainThread; 1219 return ScrollOnMainThread;
1220 } 1220 }
1221 1221
1222 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) 1222 if (status == ScrollStarted && !potentiallyScrollingLayerImpl)
1223 potentiallyScrollingLayerImpl = scrollLayerImpl; 1223 potentiallyScrollingLayerImpl = scrollLayerImpl;
(...skipping 16 matching lines...) Expand all
1240 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); 1240 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
1241 return ScrollStarted; 1241 return ScrollStarted;
1242 } 1242 }
1243 return ScrollIgnored; 1243 return ScrollIgnored;
1244 } 1244 }
1245 1245
1246 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx:: Vector2dF viewportDelta) 1246 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx:: Vector2dF viewportDelta)
1247 { 1247 {
1248 // Layers with non-invertible screen space transforms should not have passed the scroll hit 1248 // Layers with non-invertible screen space transforms should not have passed the scroll hit
1249 // test in the first place. 1249 // test in the first place.
1250 DCHECK(layerImpl->screenSpaceTransform().IsInvertible()); 1250 DCHECK(layerImpl->screen_space_transform().IsInvertible());
1251 gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitializati on); 1251 gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitializati on);
1252 bool didInvert = layerImpl->screenSpaceTransform().GetInverse(&inverseScreen SpaceTransform); 1252 bool didInvert = layerImpl->screen_space_transform().GetInverse(&inverseScre enSpaceTransform);
1253 // TODO: With the advent of impl-side crolling for non-root layers, we may 1253 // TODO: With the advent of impl-side crolling for non-root layers, we may
1254 // need to explicitly handle uninvertible transforms here. 1254 // need to explicitly handle uninvertible transforms here.
1255 DCHECK(didInvert); 1255 DCHECK(didInvert);
1256 1256
1257 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp ortToScreenSpace); 1257 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp ortToScreenSpace);
1258 1258
1259 gfx::Vector2dF screenSpaceDelta = viewportDelta; 1259 gfx::Vector2dF screenSpaceDelta = viewportDelta;
1260 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace); 1260 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace);
1261 1261
1262 // First project the scroll start and end points to local layer space to fin d the scroll delta 1262 // First project the scroll start and end points to local layer space to fin d the scroll delta
1263 // in layer coordinates. 1263 // in layer coordinates.
1264 bool startClipped, endClipped; 1264 bool startClipped, endClipped;
1265 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; 1265 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta;
1266 gfx::PointF localStartPoint = MathUtil::projectPoint(inverseScreenSpaceTrans form, screenSpacePoint, startClipped); 1266 gfx::PointF localStartPoint = MathUtil::projectPoint(inverseScreenSpaceTrans form, screenSpacePoint, startClipped);
1267 gfx::PointF localEndPoint = MathUtil::projectPoint(inverseScreenSpaceTransfo rm, screenSpaceEndPoint, endClipped); 1267 gfx::PointF localEndPoint = MathUtil::projectPoint(inverseScreenSpaceTransfo rm, screenSpaceEndPoint, endClipped);
1268 1268
1269 // In general scroll point coordinates should not get clipped. 1269 // In general scroll point coordinates should not get clipped.
1270 DCHECK(!startClipped); 1270 DCHECK(!startClipped);
1271 DCHECK(!endClipped); 1271 DCHECK(!endClipped);
1272 if (startClipped || endClipped) 1272 if (startClipped || endClipped)
1273 return gfx::Vector2dF(); 1273 return gfx::Vector2dF();
1274 1274
1275 // localStartPoint and localEndPoint are in content space but we want to mov e them to layer space for scrolling. 1275 // localStartPoint and localEndPoint are in content space but we want to mov e them to layer space for scrolling.
1276 float widthScale = 1 / layerImpl->contentsScaleX(); 1276 float widthScale = 1.f / layerImpl->contents_scale_x();
1277 float heightScale = 1 / layerImpl->contentsScaleY(); 1277 float heightScale = 1.f / layerImpl->contents_scale_y();
1278 localStartPoint.Scale(widthScale, heightScale); 1278 localStartPoint.Scale(widthScale, heightScale);
1279 localEndPoint.Scale(widthScale, heightScale); 1279 localEndPoint.Scale(widthScale, heightScale);
1280 1280
1281 // Apply the scroll delta. 1281 // Apply the scroll delta.
1282 gfx::Vector2dF previousDelta = layerImpl->scrollDelta(); 1282 gfx::Vector2dF previousDelta = layerImpl->scroll_delta();
1283 layerImpl->scrollBy(localEndPoint - localStartPoint); 1283 layerImpl->ScrollBy(localEndPoint - localStartPoint);
1284 1284
1285 // Get the end point in the layer's content space so we can apply its screen SpaceTransform. 1285 // Get the end point in the layer's content space so we can apply its screen SpaceTransform.
1286 gfx::PointF actualLocalEndPoint = localStartPoint + layerImpl->scrollDelta() - previousDelta; 1286 gfx::PointF actualLocalEndPoint = localStartPoint + layerImpl->scroll_delta( ) - previousDelta;
1287 gfx::PointF actualLocalContentEndPoint = gfx::ScalePoint(actualLocalEndPoint , 1 / widthScale, 1 / heightScale); 1287 gfx::PointF actualLocalContentEndPoint = gfx::ScalePoint(actualLocalEndPoint , 1 / widthScale, 1 / heightScale);
1288 1288
1289 // Calculate the applied scroll delta in viewport space coordinates. 1289 // Calculate the applied scroll delta in viewport space coordinates.
1290 gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl->screen SpaceTransform(), actualLocalContentEndPoint, endClipped); 1290 gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl->screen _space_transform(), actualLocalContentEndPoint, endClipped);
1291 DCHECK(!endClipped); 1291 DCHECK(!endClipped);
1292 if (endClipped) 1292 if (endClipped)
1293 return gfx::Vector2dF(); 1293 return gfx::Vector2dF();
1294 gfx::PointF actualViewportEndPoint = gfx::ScalePoint(actualScreenSpaceEndPoi nt, 1 / scaleFromViewportToScreenSpace); 1294 gfx::PointF actualViewportEndPoint = gfx::ScalePoint(actualScreenSpaceEndPoi nt, 1 / scaleFromViewportToScreenSpace);
1295 return actualViewportEndPoint - viewportPoint; 1295 return actualViewportEndPoint - viewportPoint;
1296 } 1296 }
1297 1297
1298 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta) 1298 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta)
1299 { 1299 {
1300 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); 1300 gfx::Vector2dF previousDelta(layerImpl.scroll_delta());
1301 layerImpl.scrollBy(localDelta); 1301 layerImpl.ScrollBy(localDelta);
1302 return layerImpl.scrollDelta() - previousDelta; 1302 return layerImpl.scroll_delta() - previousDelta;
1303 } 1303 }
1304 1304
1305 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, 1305 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint,
1306 const gfx::Vector2dF& scrollDelta) 1306 const gfx::Vector2dF& scrollDelta)
1307 { 1307 {
1308 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); 1308 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
1309 if (!currentlyScrollingLayer()) 1309 if (!currentlyScrollingLayer())
1310 return false; 1310 return false;
1311 1311
1312 gfx::Vector2dF pendingDelta = scrollDelta; 1312 gfx::Vector2dF pendingDelta = scrollDelta;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 gfx::PointF previousScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta ); 1402 gfx::PointF previousScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta );
1403 activeTree()->SetPageScaleDelta(pageScaleDelta * magnifyDelta); 1403 activeTree()->SetPageScaleDelta(pageScaleDelta * magnifyDelta);
1404 pageScaleDelta = activeTree()->page_scale_delta(); 1404 pageScaleDelta = activeTree()->page_scale_delta();
1405 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); 1405 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta);
1406 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; 1406 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor;
1407 1407
1408 m_previousPinchAnchor = anchor; 1408 m_previousPinchAnchor = anchor;
1409 1409
1410 move.Scale(1 / activeTree()->page_scale_factor()); 1410 move.Scale(1 / activeTree()->page_scale_factor());
1411 1411
1412 rootScrollLayer()->scrollBy(move); 1412 rootScrollLayer()->ScrollBy(move);
1413 1413
1414 if (rootScrollLayer()->scrollbarAnimationController()) 1414 if (rootScrollLayer()->scrollbar_animation_controller())
1415 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (base::TimeTicks::Now()); 1415 rootScrollLayer()->scrollbar_animation_controller()->didPinchGestureUpda te(base::TimeTicks::Now());
1416 1416
1417 m_client->setNeedsCommitOnImplThread(); 1417 m_client->setNeedsCommitOnImplThread();
1418 m_client->setNeedsRedrawOnImplThread(); 1418 m_client->setNeedsRedrawOnImplThread();
1419 m_client->renewTreePriority(); 1419 m_client->renewTreePriority();
1420 } 1420 }
1421 1421
1422 void LayerTreeHostImpl::pinchGestureEnd() 1422 void LayerTreeHostImpl::pinchGestureEnd()
1423 { 1423 {
1424 m_pinchGestureActive = false; 1424 m_pinchGestureActive = false;
1425 1425
1426 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) 1426 if (rootScrollLayer() && rootScrollLayer()->scrollbar_animation_controller() )
1427 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(ba se::TimeTicks::Now()); 1427 rootScrollLayer()->scrollbar_animation_controller()->didPinchGestureEnd( base::TimeTicks::Now());
1428 1428
1429 m_client->setNeedsCommitOnImplThread(); 1429 m_client->setNeedsCommitOnImplThread();
1430 } 1430 }
1431 1431
1432 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI mpl) 1432 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI mpl)
1433 { 1433 {
1434 if (!layerImpl) 1434 if (!layerImpl)
1435 return; 1435 return;
1436 1436
1437 gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelta()) ; 1437 gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scroll_delta() );
1438 if (!scrollDelta.IsZero()) { 1438 if (!scrollDelta.IsZero()) {
1439 LayerTreeHostCommon::ScrollUpdateInfo scroll; 1439 LayerTreeHostCommon::ScrollUpdateInfo scroll;
1440 scroll.layerId = layerImpl->id(); 1440 scroll.layerId = layerImpl->id();
1441 scroll.scrollDelta = scrollDelta; 1441 scroll.scrollDelta = scrollDelta;
1442 scrollInfo->scrolls.push_back(scroll); 1442 scrollInfo->scrolls.push_back(scroll);
1443 layerImpl->setSentScrollDelta(scrollDelta); 1443 layerImpl->SetSentScrollDelta(scrollDelta);
1444 } 1444 }
1445 1445
1446 for (size_t i = 0; i < layerImpl->children().size(); ++i) 1446 for (size_t i = 0; i < layerImpl->children().size(); ++i)
1447 collectScrollDeltas(scrollInfo, layerImpl->children()[i]); 1447 collectScrollDeltas(scrollInfo, layerImpl->children()[i]);
1448 } 1448 }
1449 1449
1450 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas() 1450 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas()
1451 { 1451 {
1452 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet()); 1452 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet());
1453 1453
1454 collectScrollDeltas(scrollInfo.get(), rootLayer()); 1454 collectScrollDeltas(scrollInfo.get(), rootLayer());
1455 scrollInfo->pageScaleDelta = activeTree()->page_scale_delta(); 1455 scrollInfo->pageScaleDelta = activeTree()->page_scale_delta();
1456 activeTree()->set_sent_page_scale_delta(scrollInfo->pageScaleDelta); 1456 activeTree()->set_sent_page_scale_delta(scrollInfo->pageScaleDelta);
1457 1457
1458 return scrollInfo.Pass(); 1458 return scrollInfo.Pass();
1459 } 1459 }
1460 1460
1461 void LayerTreeHostImpl::SetFullRootLayerDamage() 1461 void LayerTreeHostImpl::SetFullRootLayerDamage()
1462 { 1462 {
1463 if (rootLayer()) { 1463 if (rootLayer()) {
1464 RenderSurfaceImpl* renderSurface = rootLayer()->renderSurface(); 1464 RenderSurfaceImpl* renderSurface = rootLayer()->render_surface();
1465 if (renderSurface) 1465 if (renderSurface)
1466 renderSurface->damage_tracker()->ForceFullDamageNextUpdate(); 1466 renderSurface->damage_tracker()->ForceFullDamageNextUpdate();
1467 } 1467 }
1468 } 1468 }
1469 1469
1470 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) 1470 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
1471 { 1471 {
1472 if (!m_pageScaleAnimation || !rootScrollLayer()) 1472 if (!m_pageScaleAnimation || !rootScrollLayer())
1473 return; 1473 return;
1474 1474
1475 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1475 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1476 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); 1476 gfx::Vector2dF scrollTotal = rootScrollLayer()->scroll_offset() + rootScroll Layer()->scroll_delta();
1477 1477
1478 activeTree()->SetPageScaleDelta(m_pageScaleAnimation->PageScaleFactorAtTime( monotonicTime) / activeTree()->page_scale_factor()); 1478 activeTree()->SetPageScaleDelta(m_pageScaleAnimation->PageScaleFactorAtTime( monotonicTime) / activeTree()->page_scale_factor());
1479 gfx::Vector2dF nextScroll = m_pageScaleAnimation->ScrollOffsetAtTime(monoton icTime); 1479 gfx::Vector2dF nextScroll = m_pageScaleAnimation->ScrollOffsetAtTime(monoton icTime);
1480 1480
1481 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); 1481 rootScrollLayer()->ScrollBy(nextScroll - scrollTotal);
1482 m_client->setNeedsRedrawOnImplThread(); 1482 m_client->setNeedsRedrawOnImplThread();
1483 1483
1484 if (m_pageScaleAnimation->IsAnimationCompleteAtTime(monotonicTime)) { 1484 if (m_pageScaleAnimation->IsAnimationCompleteAtTime(monotonicTime)) {
1485 m_pageScaleAnimation.reset(); 1485 m_pageScaleAnimation.reset();
1486 m_client->setNeedsCommitOnImplThread(); 1486 m_client->setNeedsCommitOnImplThread();
1487 m_client->renewTreePriority(); 1487 m_client->renewTreePriority();
1488 } 1488 }
1489 } 1489 }
1490 1490
1491 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) 1491 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime)
(...skipping 30 matching lines...) Expand all
1522 } 1522 }
1523 1523
1524 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const 1524 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const
1525 { 1525 {
1526 return base::TimeDelta::FromSeconds(1); 1526 return base::TimeDelta::FromSeconds(1);
1527 } 1527 }
1528 1528
1529 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) 1529 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current)
1530 { 1530 {
1531 DCHECK(current); 1531 DCHECK(current);
1532 current->didLoseOutputSurface(); 1532 current->DidLoseOutputSurface();
1533 if (current->maskLayer()) 1533 if (current->mask_layer())
1534 sendDidLoseOutputSurfaceRecursive(current->maskLayer()); 1534 sendDidLoseOutputSurfaceRecursive(current->mask_layer());
1535 if (current->replicaLayer()) 1535 if (current->replica_layer())
1536 sendDidLoseOutputSurfaceRecursive(current->replicaLayer()); 1536 sendDidLoseOutputSurfaceRecursive(current->replica_layer());
1537 for (size_t i = 0; i < current->children().size(); ++i) 1537 for (size_t i = 0; i < current->children().size(); ++i)
1538 sendDidLoseOutputSurfaceRecursive(current->children()[i]); 1538 sendDidLoseOutputSurfaceRecursive(current->children()[i]);
1539 } 1539 }
1540 1540
1541 void LayerTreeHostImpl::clearRenderSurfaces() 1541 void LayerTreeHostImpl::clearRenderSurfaces()
1542 { 1542 {
1543 activeTree()->ClearRenderSurfaces(); 1543 activeTree()->ClearRenderSurfaces();
1544 if (pendingTree()) 1544 if (pendingTree())
1545 pendingTree()->ClearRenderSurfaces(); 1545 pendingTree()->ClearRenderSurfaces();
1546 } 1546 }
1547 1547
1548 std::string LayerTreeHostImpl::layerTreeAsText() const 1548 std::string LayerTreeHostImpl::layerTreeAsText() const
1549 { 1549 {
1550 std::string str; 1550 std::string str;
1551 if (rootLayer()) { 1551 if (rootLayer()) {
1552 str = rootLayer()->layerTreeAsText(); 1552 str = rootLayer()->LayerTreeAsText();
1553 str += "RenderSurfaces:\n"; 1553 str += "RenderSurfaces:\n";
1554 dumpRenderSurfaces(&str, 1, rootLayer()); 1554 dumpRenderSurfaces(&str, 1, rootLayer());
1555 } 1555 }
1556 return str; 1556 return str;
1557 } 1557 }
1558 1558
1559 std::string LayerTreeHostImpl::layerTreeAsJson() const 1559 std::string LayerTreeHostImpl::layerTreeAsJson() const
1560 { 1560 {
1561 std::string str; 1561 std::string str;
1562 if (rootLayer()) { 1562 if (rootLayer()) {
1563 scoped_ptr<base::Value> json(rootLayer()->layerTreeAsJson()); 1563 scoped_ptr<base::Value> json(rootLayer()->LayerTreeAsJson());
1564 base::JSONWriter::WriteWithOptions( 1564 base::JSONWriter::WriteWithOptions(
1565 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); 1565 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
1566 } 1566 }
1567 return str; 1567 return str;
1568 } 1568 }
1569 1569
1570 void LayerTreeHostImpl::dumpRenderSurfaces(std::string* str, int indent, const L ayerImpl* layer) const 1570 void LayerTreeHostImpl::dumpRenderSurfaces(std::string* str, int indent, const L ayerImpl* layer) const
1571 { 1571 {
1572 if (layer->renderSurface()) 1572 if (layer->render_surface())
1573 layer->renderSurface()->DumpSurface(str, indent); 1573 layer->render_surface()->DumpSurface(str, indent);
1574 1574
1575 for (size_t i = 0; i < layer->children().size(); ++i) 1575 for (size_t i = 0; i < layer->children().size(); ++i)
1576 dumpRenderSurfaces(str, indent, layer->children()[i]); 1576 dumpRenderSurfaces(str, indent, layer->children()[i]);
1577 } 1577 }
1578 1578
1579 int LayerTreeHostImpl::sourceAnimationFrameNumber() const 1579 int LayerTreeHostImpl::sourceAnimationFrameNumber() const
1580 { 1580 {
1581 return fpsCounter()->currentFrameNumber(); 1581 return fpsCounter()->currentFrameNumber();
1582 } 1582 }
1583 1583
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) 1625 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time)
1626 { 1626 {
1627 animateScrollbarsRecursive(rootLayer(), time); 1627 animateScrollbarsRecursive(rootLayer(), time);
1628 } 1628 }
1629 1629
1630 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time) 1630 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time)
1631 { 1631 {
1632 if (!layer) 1632 if (!layer)
1633 return; 1633 return;
1634 1634
1635 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1635 ScrollbarAnimationController* scrollbarController = layer->scrollbar_animati on_controller();
1636 if (scrollbarController && scrollbarController->animate(time)) 1636 if (scrollbarController && scrollbarController->animate(time))
1637 m_client->setNeedsRedrawOnImplThread(); 1637 m_client->setNeedsRedrawOnImplThread();
1638 1638
1639 for (size_t i = 0; i < layer->children().size(); ++i) 1639 for (size_t i = 0; i < layer->children().size(); ++i)
1640 animateScrollbarsRecursive(layer->children()[i], time); 1640 animateScrollbarsRecursive(layer->children()[i], time);
1641 } 1641 }
1642 1642
1643 void LayerTreeHostImpl::setTreePriority(TreePriority priority) 1643 void LayerTreeHostImpl::setTreePriority(TreePriority priority)
1644 { 1644 {
1645 if (!m_tileManager) 1645 if (!m_tileManager)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 state->Set("active_tree", activeTree()->AsValue().release()); 1692 state->Set("active_tree", activeTree()->AsValue().release());
1693 return state.PassAs<base::Value>(); 1693 return state.PassAs<base::Value>();
1694 } 1694 }
1695 1695
1696 // static 1696 // static
1697 LayerImpl* LayerTreeHostImpl::getNonCompositedContentLayerRecursive(LayerImpl* l ayer) 1697 LayerImpl* LayerTreeHostImpl::getNonCompositedContentLayerRecursive(LayerImpl* l ayer)
1698 { 1698 {
1699 if (!layer) 1699 if (!layer)
1700 return NULL; 1700 return NULL;
1701 1701
1702 if (layer->drawsContent()) 1702 if (layer->DrawsContent())
1703 return layer; 1703 return layer;
1704 1704
1705 for (LayerImpl::LayerList::const_iterator it = layer->children().begin(); 1705 for (LayerImpl::LayerList::const_iterator it = layer->children().begin();
1706 it != layer->children().end(); ++it) { 1706 it != layer->children().end(); ++it) {
1707 LayerImpl* nccr = getNonCompositedContentLayerRecursive(*it); 1707 LayerImpl* nccr = getNonCompositedContentLayerRecursive(*it);
1708 if (nccr) 1708 if (nccr)
1709 return nccr; 1709 return nccr;
1710 } 1710 }
1711 1711
1712 return NULL; 1712 return NULL;
1713 } 1713 }
1714 1714
1715 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() 1715 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture()
1716 { 1716 {
1717 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); 1717 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree();
1718 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); 1718 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer());
1719 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); 1719 return layer ? layer->GetPicture() : skia::RefPtr<SkPicture>();
1720 } 1720 }
1721 1721
1722 void LayerTreeHostImpl::setDebugState(const LayerTreeDebugState& debugState) 1722 void LayerTreeHostImpl::setDebugState(const LayerTreeDebugState& debugState)
1723 { 1723 {
1724 if (m_debugState.continuousPainting != debugState.continuousPainting) 1724 if (m_debugState.continuousPainting != debugState.continuousPainting)
1725 m_paintTimeCounter->ClearHistory(); 1725 m_paintTimeCounter->ClearHistory();
1726 1726
1727 m_debugState = debugState; 1727 m_debugState = debugState;
1728 1728
1729 if (m_tileManager) 1729 if (m_tileManager)
1730 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ()); 1730 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ());
1731 } 1731 }
1732 1732
1733 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber) 1733 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber)
1734 { 1734 {
1735 DCHECK(m_debugState.continuousPainting); 1735 DCHECK(m_debugState.continuousPainting);
1736 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber); 1736 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber);
1737 } 1737 }
1738 1738
1739 } // namespace cc 1739 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common_unittest.cc ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698