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 "CCLayerTreeHost.h" | 7 #include "CCLayerTreeHost.h" |
8 | 8 |
9 #include "CCFontAtlas.h" | 9 #include "CCFontAtlas.h" |
10 #include "CCGraphicsContext.h" | 10 #include "CCGraphicsContext.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return; | 488 return; |
489 | 489 |
490 if (layoutViewportSize().isEmpty()) | 490 if (layoutViewportSize().isEmpty()) |
491 return; | 491 return; |
492 | 492 |
493 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; | 493 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; |
494 | 494 |
495 updateLayers(rootLayer(), queue); | 495 updateLayers(rootLayer(), queue); |
496 } | 496 } |
497 | 497 |
498 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc
aleFactor) | |
499 { | |
500 if (layer->boundsContainPageScale()) | |
501 layer->setContentsScale(deviceScaleFactor); | |
502 else | |
503 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); | |
504 } | |
505 | |
506 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer) | 498 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer) |
507 { | 499 { |
508 if (!layer) | 500 if (!layer) |
509 return 0; | 501 return 0; |
510 | 502 |
511 if (layer->scrollable()) | 503 if (layer->scrollable()) |
512 return layer; | 504 return layer; |
513 | 505 |
514 for (size_t i = 0; i < layer->children().size(); ++i) { | 506 for (size_t i = 0; i < layer->children().size(); ++i) { |
515 LayerChromium* found = findFirstScrollableLayer(layer->children()[i].get
()); | 507 LayerChromium* found = findFirstScrollableLayer(layer->children()[i].get
()); |
516 if (found) | 508 if (found) |
517 return found; | 509 return found; |
518 } | 510 } |
519 | 511 |
520 return 0; | 512 return 0; |
521 } | 513 } |
522 | 514 |
523 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa
t pageScaleFactor) | |
524 { | |
525 setScale(layer, deviceScaleFactor, pageScaleFactor); | |
526 | |
527 LayerChromium* maskLayer = layer->maskLayer(); | |
528 if (maskLayer) | |
529 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); | |
530 | |
531 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye
r()->maskLayer() : 0; | |
532 if (replicaMaskLayer) | |
533 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); | |
534 | |
535 const std::vector<scoped_refptr<LayerChromium> >& children = layer->children
(); | |
536 for (unsigned int i = 0; i < children.size(); ++i) | |
537 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); | |
538 } | |
539 | |
540 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue) | 515 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue) |
541 { | 516 { |
542 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); | 517 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); |
543 | 518 |
544 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); | |
545 | |
546 LayerList updateList; | 519 LayerList updateList; |
547 | 520 |
548 { | 521 { |
549 if (CCSettings::pageScalePinchZoomEnabled()) { | 522 if (CCSettings::pageScalePinchZoomEnabled()) { |
550 LayerChromium* rootScroll = findFirstScrollableLayer(rootLayer); | 523 LayerChromium* rootScroll = findFirstScrollableLayer(rootLayer); |
551 if (rootScroll) | 524 if (rootScroll) |
552 rootScroll->setImplTransform(m_implTransform); | 525 rootScroll->setImplTransform(m_implTransform); |
553 } | 526 } |
554 | 527 |
555 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); | 528 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); |
556 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); | 529 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, m_pageScaleFactor, rendererCapabilities().maxTextur
eSize, updateList); |
557 } | 530 } |
558 | 531 |
559 // Reset partial texture update requests. | 532 // Reset partial texture update requests. |
560 m_partialTextureUpdateRequests = 0; | 533 m_partialTextureUpdateRequests = 0; |
561 | 534 |
562 bool needMoreUpdates = paintLayerContents(updateList, queue); | 535 bool needMoreUpdates = paintLayerContents(updateList, queue); |
563 if (m_triggerIdleUpdates && needMoreUpdates) | 536 if (m_triggerIdleUpdates && needMoreUpdates) |
564 setNeedsCommit(); | 537 setNeedsCommit(); |
565 | 538 |
566 for (size_t i = 0; i < updateList.size(); ++i) | 539 for (size_t i = 0; i < updateList.size(); ++i) |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 else | 790 else |
818 layer->notifyAnimationFinished(wallClockTime); | 791 layer->notifyAnimationFinished(wallClockTime); |
819 } | 792 } |
820 } | 793 } |
821 | 794 |
822 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 795 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
823 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 796 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
824 } | 797 } |
825 | 798 |
826 } // namespace cc | 799 } // namespace cc |
OLD | NEW |