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

Side by Side Diff: cc/CCLayerTreeHost.cpp

Issue 10916279: Chromium compositor change implementing page-scale driven pinch-zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebaselined to 160422. Created 8 years, 2 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/CCLayerTreeHost.h ('k') | cc/CCLayerTreeHostCommon.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 "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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 535 }
536 536
537 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc aleFactor) 537 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc aleFactor)
538 { 538 {
539 if (layer->boundsContainPageScale()) 539 if (layer->boundsContainPageScale())
540 layer->setContentsScale(deviceScaleFactor); 540 layer->setContentsScale(deviceScaleFactor);
541 else 541 else
542 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); 542 layer->setContentsScale(deviceScaleFactor * pageScaleFactor);
543 } 543 }
544 544
545 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer)
546 {
547 if (!layer)
548 return 0;
549
550 if (layer->scrollable())
551 return layer;
552
553 for (size_t i = 0; i < layer->children().size(); ++i) {
554 LayerChromium* found = findFirstScrollableLayer(layer->children()[i].get ());
555 if (found)
556 return found;
557 }
558
559 return 0;
560 }
561
545 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa t pageScaleFactor) 562 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa t pageScaleFactor)
546 { 563 {
547 setScale(layer, deviceScaleFactor, pageScaleFactor); 564 setScale(layer, deviceScaleFactor, pageScaleFactor);
548 565
549 LayerChromium* maskLayer = layer->maskLayer(); 566 LayerChromium* maskLayer = layer->maskLayer();
550 if (maskLayer) 567 if (maskLayer)
551 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); 568 setScale(maskLayer, deviceScaleFactor, pageScaleFactor);
552 569
553 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye r()->maskLayer() : 0; 570 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye r()->maskLayer() : 0;
554 if (replicaMaskLayer) 571 if (replicaMaskLayer)
555 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); 572 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor);
556 573
557 const Vector<RefPtr<LayerChromium> >& children = layer->children(); 574 const Vector<RefPtr<LayerChromium> >& children = layer->children();
558 for (unsigned int i = 0; i < children.size(); ++i) 575 for (unsigned int i = 0; i < children.size(); ++i)
559 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); 576 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor);
560 } 577 }
561 578
562 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu e& queue) 579 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu e& queue)
563 { 580 {
564 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); 581 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers");
565 582
566 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); 583 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor);
567 584
568 LayerList updateList; 585 LayerList updateList;
569 586
570 { 587 {
588 if (CCSettings::pageScalePinchZoomEnabled()) {
589 LayerChromium* rootScroll = findFirstScrollableLayer(rootLayer);
590 if (rootScroll)
591 rootScroll->setImplTransform(m_implTransform);
592 }
593
571 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); 594 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc");
572 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); 595 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList);
573 CCLayerTreeHostCommon::calculateVisibleRects(updateList); 596 CCLayerTreeHostCommon::calculateVisibleRects(updateList);
574 } 597 }
575 598
576 // Reset partial texture update requests. 599 // Reset partial texture update requests.
577 m_partialTextureUpdateRequests = 0; 600 m_partialTextureUpdateRequests = 0;
578 601
579 bool needMoreUpdates = paintLayerContents(updateList, queue); 602 bool needMoreUpdates = paintLayerContents(updateList, queue);
580 if (m_triggerIdleUpdates && needMoreUpdates) 603 if (m_triggerIdleUpdates && needMoreUpdates)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 722 }
700 723
701 occlusionTracker.leaveLayer(it); 724 occlusionTracker.leaveLayer(it);
702 } 725 }
703 726
704 occlusionTracker.overdrawMetrics().recordMetrics(this); 727 occlusionTracker.overdrawMetrics().recordMetrics(this);
705 728
706 return needMoreUpdates; 729 return needMoreUpdates;
707 } 730 }
708 731
709 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer)
710 {
711 if (!layer)
712 return 0;
713
714 if (layer->scrollable())
715 return layer;
716
717 for (size_t i = 0; i < layer->children().size(); ++i) {
718 LayerChromium* found = findFirstScrollableLayer(layer->children()[i].get ());
719 if (found)
720 return found;
721 }
722
723 return 0;
724 }
725
726 void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info) 732 void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info)
727 { 733 {
728 if (!m_rootLayer) 734 if (!m_rootLayer)
729 return; 735 return;
730 736
731 LayerChromium* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get()) ; 737 LayerChromium* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get()) ;
732 IntSize rootScrollDelta; 738 IntSize rootScrollDelta;
733 739
734 for (size_t i = 0; i < info.scrolls.size(); ++i) { 740 for (size_t i = 0; i < info.scrolls.size(); ++i) {
735 LayerChromium* layer = CCLayerTreeHostCommon::findLayerInSubtree(m_rootL ayer.get(), info.scrolls[i].layerId); 741 LayerChromium* layer = CCLayerTreeHostCommon::findLayerInSubtree(m_rootL ayer.get(), info.scrolls[i].layerId);
736 if (!layer) 742 if (!layer)
737 continue; 743 continue;
738 if (layer == rootScrollLayer) 744 if (layer == rootScrollLayer)
739 rootScrollDelta += info.scrolls[i].scrollDelta; 745 rootScrollDelta += info.scrolls[i].scrollDelta;
740 else 746 else
741 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s crollDelta); 747 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s crollDelta);
742 } 748 }
743 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) 749 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1)
744 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta); 750 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta);
745 } 751 }
746 752
753 void CCLayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& tr ansform)
754 {
755 m_implTransform = transform;
756 }
757
747 void CCLayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) 758 void CCLayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context)
748 { 759 {
749 if (m_animating) 760 if (m_animating)
750 return; 761 return;
751 762
752 ASSERT(context); 763 ASSERT(context);
753 RateLimiterMap::iterator it = m_rateLimiters.find(context); 764 RateLimiterMap::iterator it = m_rateLimiters.find(context);
754 if (it != m_rateLimiters.end()) 765 if (it != m_rateLimiters.end())
755 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE 766 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE
756 it->value->start(); 767 it->value->start();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 else 865 else
855 layer->notifyAnimationFinished(wallClockTime); 866 layer->notifyAnimationFinished(wallClockTime);
856 } 867 }
857 } 868 }
858 869
859 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 870 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
860 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 871 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
861 } 872 }
862 873
863 } // namespace cc 874 } // namespace cc
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHost.h ('k') | cc/CCLayerTreeHostCommon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698