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

Side by Side Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 13959008: Remove NonCompositedContentHost (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase. add setBackgroundColor to setIsAcceleratedCompositingActive Created 7 years, 7 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 | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/core/rendering/RenderLayer.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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "AutofillPopupMenuClient.h" 52 #include "AutofillPopupMenuClient.h"
53 #include "BatteryClientImpl.h" 53 #include "BatteryClientImpl.h"
54 #include "CSSValueKeywords.h" 54 #include "CSSValueKeywords.h"
55 #include "CompositionUnderlineVectorBuilder.h" 55 #include "CompositionUnderlineVectorBuilder.h"
56 #include "ContextFeaturesClientImpl.h" 56 #include "ContextFeaturesClientImpl.h"
57 #include "DeviceOrientationClientProxy.h" 57 #include "DeviceOrientationClientProxy.h"
58 #include "GeolocationClientProxy.h" 58 #include "GeolocationClientProxy.h"
59 #include "GraphicsLayerFactoryChromium.h" 59 #include "GraphicsLayerFactoryChromium.h"
60 #include "HTMLNames.h" 60 #include "HTMLNames.h"
61 #include "LinkHighlight.h" 61 #include "LinkHighlight.h"
62 #include "NonCompositedContentHost.h"
63 #include "PageWidgetDelegate.h" 62 #include "PageWidgetDelegate.h"
64 #include "PrerendererClientImpl.h" 63 #include "PrerendererClientImpl.h"
65 #include "SpeechInputClientImpl.h" 64 #include "SpeechInputClientImpl.h"
66 #include "SpeechRecognitionClientProxy.h" 65 #include "SpeechRecognitionClientProxy.h"
67 #include "TextFieldDecoratorImpl.h" 66 #include "TextFieldDecoratorImpl.h"
68 #include "ValidationMessageClientImpl.h" 67 #include "ValidationMessageClientImpl.h"
69 #include "ViewportAnchor.h" 68 #include "ViewportAnchor.h"
70 #include "WebAccessibilityObject.h" 69 #include "WebAccessibilityObject.h"
71 #include "WebActiveWheelFlingParameters.h" 70 #include "WebActiveWheelFlingParameters.h"
72 #include "WebAutofillClient.h" 71 #include "WebAutofillClient.h"
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 if (m_continuousPaintingEnabled) { 1792 if (m_continuousPaintingEnabled) {
1794 ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageO verlays.get()); 1793 ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageO verlays.get());
1795 m_client->scheduleAnimation(); 1794 m_client->scheduleAnimation();
1796 } 1795 }
1797 } 1796 }
1798 1797
1799 void WebViewImpl::layout() 1798 void WebViewImpl::layout()
1800 { 1799 {
1801 TRACE_EVENT0("webkit", "WebViewImpl::layout"); 1800 TRACE_EVENT0("webkit", "WebViewImpl::layout");
1802 PageWidgetDelegate::layout(m_page.get()); 1801 PageWidgetDelegate::layout(m_page.get());
1802 if (m_layerTreeView)
1803 m_layerTreeView->setBackgroundColor(backgroundColor());
1803 1804
1804 if (m_linkHighlight) 1805 if (m_linkHighlight)
1805 m_linkHighlight->updateGeometry(); 1806 m_linkHighlight->updateGeometry();
1806 } 1807 }
1807 1808
1808 void WebViewImpl::enterForceCompositingMode(bool enter) 1809 void WebViewImpl::enterForceCompositingMode(bool enter)
1809 { 1810 {
1810 if (page()->settings()->forceCompositingMode() == enter) 1811 if (page()->settings()->forceCompositingMode() == enter)
1811 return; 1812 return;
1812 1813
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 { 2960 {
2960 if (!page()) 2961 if (!page())
2961 return; 2962 return;
2962 2963
2963 Frame* frame = page()->mainFrame(); 2964 Frame* frame = page()->mainFrame();
2964 if (!frame || !frame->view()) 2965 if (!frame || !frame->view())
2965 return; 2966 return;
2966 2967
2967 frame->view()->setUseFixedLayout(enable); 2968 frame->view()->setUseFixedLayout(enable);
2968 2969
2969 // Also notify the base layer, which RenderLayerCompositor does not see. 2970 if (m_isAcceleratedCompositingActive)
2970 if (m_nonCompositedContentHost)
2971 updateLayerTreeViewport(); 2971 updateLayerTreeViewport();
2972 } 2972 }
2973 2973
2974 2974
2975 void WebViewImpl::enableAutoResizeMode(const WebSize& minSize, const WebSize& ma xSize) 2975 void WebViewImpl::enableAutoResizeMode(const WebSize& minSize, const WebSize& ma xSize)
2976 { 2976 {
2977 m_shouldAutoResize = true; 2977 m_shouldAutoResize = true;
2978 m_minAutoSize = minSize; 2978 m_minAutoSize = minSize;
2979 m_maxAutoSize = maxSize; 2979 m_maxAutoSize = maxSize;
2980 configureAutoResizeMode(); 2980 configureAutoResizeMode();
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 { 3557 {
3558 // Set any existing frames to be transparent. 3558 // Set any existing frames to be transparent.
3559 Frame* frame = m_page->mainFrame(); 3559 Frame* frame = m_page->mainFrame();
3560 while (frame) { 3560 while (frame) {
3561 frame->view()->setTransparent(isTransparent); 3561 frame->view()->setTransparent(isTransparent);
3562 frame = frame->tree()->traverseNext(); 3562 frame = frame->tree()->traverseNext();
3563 } 3563 }
3564 3564
3565 // Future frames check this to know whether to be transparent. 3565 // Future frames check this to know whether to be transparent.
3566 m_isTransparent = isTransparent; 3566 m_isTransparent = isTransparent;
3567
3568 if (m_nonCompositedContentHost)
3569 m_nonCompositedContentHost->setOpaque(!isTransparent);
3570 } 3567 }
3571 3568
3572 bool WebViewImpl::isTransparent() const 3569 bool WebViewImpl::isTransparent() const
3573 { 3570 {
3574 return m_isTransparent; 3571 return m_isTransparent;
3575 } 3572 }
3576 3573
3577 void WebViewImpl::setIsActive(bool active) 3574 void WebViewImpl::setIsActive(bool active)
3578 { 3575 {
3579 if (page() && page()->focusController()) 3576 if (page() && page()->focusController())
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
3861 } 3858 }
3862 3859
3863 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) 3860 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
3864 { 3861 {
3865 suppressInvalidations(true); 3862 suppressInvalidations(true);
3866 3863
3867 m_rootGraphicsLayer = layer; 3864 m_rootGraphicsLayer = layer;
3868 m_rootLayer = layer ? layer->platformLayer() : 0; 3865 m_rootLayer = layer ? layer->platformLayer() : 0;
3869 3866
3870 setIsAcceleratedCompositingActive(layer); 3867 setIsAcceleratedCompositingActive(layer);
3871 if (m_nonCompositedContentHost) {
3872 GraphicsLayer* scrollLayer = 0;
3873 if (layer) {
3874 Document* document = page()->mainFrame()->document();
3875 RenderView* renderView = document->renderView();
3876 RenderLayerCompositor* compositor = renderView->compositor();
3877 scrollLayer = compositor->scrollLayer();
3878 }
3879 m_nonCompositedContentHost->setScrollLayer(scrollLayer);
3880 }
3881 3868
3882 if (m_layerTreeView) { 3869 if (m_layerTreeView) {
3883 if (m_rootLayer) 3870 if (m_rootLayer)
3884 m_layerTreeView->setRootLayer(*m_rootLayer); 3871 m_layerTreeView->setRootLayer(*m_rootLayer);
3885 else 3872 else
3886 m_layerTreeView->clearRootLayer(); 3873 m_layerTreeView->clearRootLayer();
3887 } 3874 }
3888 3875
3889 suppressInvalidations(false); 3876 suppressInvalidations(false);
3890 } 3877 }
(...skipping 12 matching lines...) Expand all
3903 { 3890 {
3904 if (m_layerTreeViewCommitsDeferred) { 3891 if (m_layerTreeViewCommitsDeferred) {
3905 // If we receive an invalidation from WebKit while in deferred commit mo de, 3892 // If we receive an invalidation from WebKit while in deferred commit mo de,
3906 // that means it's time to start producing frames again so un-defer. 3893 // that means it's time to start producing frames again so un-defer.
3907 if (m_layerTreeView) 3894 if (m_layerTreeView)
3908 m_layerTreeView->setDeferCommits(false); 3895 m_layerTreeView->setDeferCommits(false);
3909 m_layerTreeViewCommitsDeferred = false; 3896 m_layerTreeViewCommitsDeferred = false;
3910 } 3897 }
3911 if (m_isAcceleratedCompositingActive) { 3898 if (m_isAcceleratedCompositingActive) {
3912 ASSERT(m_layerTreeView); 3899 ASSERT(m_layerTreeView);
3913
3914 if (!page())
3915 return;
3916
3917 FrameView* view = page()->mainFrame()->view();
3918 IntRect dirtyRect = view->windowToContents(rect);
3919 updateLayerTreeViewport(); 3900 updateLayerTreeViewport();
3920 m_nonCompositedContentHost->invalidateRect(dirtyRect);
3921 } else if (m_client) 3901 } else if (m_client)
3922 m_client->didInvalidateRect(rect); 3902 m_client->didInvalidateRect(rect);
3923 } 3903 }
3924 3904
3925 NonCompositedContentHost* WebViewImpl::nonCompositedContentHost()
3926 {
3927 return m_nonCompositedContentHost.get();
3928 }
3929
3930 void WebViewImpl::setBackgroundColor(const WebCore::Color& color)
3931 {
3932 WebCore::Color documentBackgroundColor = color.isValid() ? color : WebCore:: Color::white;
3933 WebColor webDocumentBackgroundColor = documentBackgroundColor.rgb();
3934 m_nonCompositedContentHost->setBackgroundColor(documentBackgroundColor);
3935 m_layerTreeView->setBackgroundColor(webDocumentBackgroundColor);
3936 }
3937
3938 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const 3905 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const
3939 { 3906 {
3940 return m_graphicsLayerFactory.get(); 3907 return m_graphicsLayerFactory.get();
3941 } 3908 }
3942 3909
3943 void WebViewImpl::registerForAnimations(WebLayer* layer) 3910 void WebViewImpl::registerForAnimations(WebLayer* layer)
3944 { 3911 {
3945 if (m_layerTreeView) 3912 if (m_layerTreeView)
3946 m_layerTreeView->registerForAnimations(layer); 3913 m_layerTreeView->registerForAnimations(layer);
3947 } 3914 }
3948 3915
3949 WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer() 3916 WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer()
3950 { 3917 {
3951 return m_rootGraphicsLayer; 3918 return m_rootGraphicsLayer;
3952 } 3919 }
3953 3920
3954 void WebViewImpl::scheduleAnimation() 3921 void WebViewImpl::scheduleAnimation()
3955 { 3922 {
3956 if (isAcceleratedCompositingActive()) { 3923 if (isAcceleratedCompositingActive()) {
3957 if (Platform::current()->isThreadedCompositingEnabled()) { 3924 if (Platform::current()->isThreadedCompositingEnabled()) {
3958 ASSERT(m_layerTreeView); 3925 ASSERT(m_layerTreeView);
3959 m_layerTreeView->setNeedsAnimate(); 3926 m_layerTreeView->setNeedsAnimate();
3960 } else 3927 } else
3961 m_client->scheduleAnimation(); 3928 m_client->scheduleAnimation();
3962 } else 3929 } else
3963 m_client->scheduleAnimation(); 3930 m_client->scheduleAnimation();
3964 } 3931 }
3965 3932
3966 void WebViewImpl::paintRootLayer(GraphicsContext& context, const IntRect& conten tRect)
3967 {
3968 double paintStart = currentTime();
3969 if (!page())
3970 return;
3971 FrameView* view = page()->mainFrame()->view();
3972 context.setUseHighResMarkers(page()->deviceScaleFactor() > 1.5f);
3973 view->paintContents(&context, contentRect);
3974 double paintEnd = currentTime();
3975 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE nd - paintStart);
3976 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaint DurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
3977 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaint MegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
3978
3979 setBackgroundColor(view->documentBackgroundColor());
3980 }
3981
3982 void WebViewImpl::setIsAcceleratedCompositingActive(bool active) 3933 void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
3983 { 3934 {
3984 WebKit::Platform::current()->histogramEnumeration("GPU.setIsAcceleratedCompo sitingActive", active * 2 + m_isAcceleratedCompositingActive, 4); 3935 WebKit::Platform::current()->histogramEnumeration("GPU.setIsAcceleratedCompo sitingActive", active * 2 + m_isAcceleratedCompositingActive, 4);
3985 3936
3986 if (m_isAcceleratedCompositingActive == active) 3937 if (m_isAcceleratedCompositingActive == active)
3987 return; 3938 return;
3988 3939
3989 if (!active) { 3940 if (!active) {
3990 m_isAcceleratedCompositingActive = false; 3941 m_isAcceleratedCompositingActive = false;
3991 // We need to finish all GL rendering before sending didDeactivateCompos itor() to prevent 3942 // We need to finish all GL rendering before sending didDeactivateCompos itor() to prevent
(...skipping 12 matching lines...) Expand all
4004 m_layerTreeViewCommitsDeferred = true; 3955 m_layerTreeViewCommitsDeferred = true;
4005 } 3956 }
4006 } else if (m_layerTreeView) { 3957 } else if (m_layerTreeView) {
4007 m_isAcceleratedCompositingActive = true; 3958 m_isAcceleratedCompositingActive = true;
4008 updateLayerTreeViewport(); 3959 updateLayerTreeViewport();
4009 3960
4010 m_client->didActivateCompositor(m_inputHandlerIdentifier); 3961 m_client->didActivateCompositor(m_inputHandlerIdentifier);
4011 } else { 3962 } else {
4012 TRACE_EVENT0("webkit", "WebViewImpl::setIsAcceleratedCompositingActive(t rue)"); 3963 TRACE_EVENT0("webkit", "WebViewImpl::setIsAcceleratedCompositingActive(t rue)");
4013 3964
4014 m_nonCompositedContentHost = NonCompositedContentHost::create(this, grap hicsLayerFactory());
4015 m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->show DebugBorders());
4016 m_nonCompositedContentHost->setOpaque(!isTransparent());
4017
4018 m_client->initializeLayerTreeView(); 3965 m_client->initializeLayerTreeView();
4019 m_layerTreeView = m_client->layerTreeView(); 3966 m_layerTreeView = m_client->layerTreeView();
4020 if (m_layerTreeView) { 3967 if (m_layerTreeView) {
4021 m_layerTreeView->setRootLayer(*m_rootLayer); 3968 m_layerTreeView->setRootLayer(*m_rootLayer);
4022 3969
4023 bool visible = page()->visibilityState() == PageVisibilityStateVisib le; 3970 bool visible = page()->visibilityState() == PageVisibilityStateVisib le;
4024 m_layerTreeView->setVisible(visible); 3971 m_layerTreeView->setVisible(visible);
4025 m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor()); 3972 m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor());
4026 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_mi nimumPageScaleFactor, m_maximumPageScaleFactor); 3973 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_mi nimumPageScaleFactor, m_maximumPageScaleFactor);
3974 m_layerTreeView->setBackgroundColor(backgroundColor());
enne (OOO) 2013/05/16 18:08:12 If layout() doesn't get called with the single thr
danakj 2013/05/16 18:09:45 It comes from RenderWidget instead. RenderWidget:
4027 m_layerTreeView->setHasTransparentBackground(isTransparent()); 3975 m_layerTreeView->setHasTransparentBackground(isTransparent());
4028 updateLayerTreeViewport(); 3976 updateLayerTreeViewport();
4029 m_client->didActivateCompositor(m_inputHandlerIdentifier); 3977 m_client->didActivateCompositor(m_inputHandlerIdentifier);
4030 m_isAcceleratedCompositingActive = true; 3978 m_isAcceleratedCompositingActive = true;
4031 m_compositorCreationFailed = false; 3979 m_compositorCreationFailed = false;
4032 if (m_pageOverlays) 3980 if (m_pageOverlays)
4033 m_pageOverlays->update(); 3981 m_pageOverlays->update();
4034 m_layerTreeView->setShowFPSCounter(m_showFPSCounter); 3982 m_layerTreeView->setShowFPSCounter(m_showFPSCounter);
4035 m_layerTreeView->setShowPaintRects(m_showPaintRects); 3983 m_layerTreeView->setShowPaintRects(m_showPaintRects);
4036 m_layerTreeView->setShowDebugBorders(m_showDebugBorders); 3984 m_layerTreeView->setShowDebugBorders(m_showDebugBorders);
4037 m_layerTreeView->setContinuousPaintingEnabled(m_continuousPaintingEn abled); 3985 m_layerTreeView->setContinuousPaintingEnabled(m_continuousPaintingEn abled);
4038 } else { 3986 } else {
4039 m_nonCompositedContentHost.clear();
4040 m_isAcceleratedCompositingActive = false; 3987 m_isAcceleratedCompositingActive = false;
4041 m_client->didDeactivateCompositor(); 3988 m_client->didDeactivateCompositor();
4042 m_compositorCreationFailed = true; 3989 m_compositorCreationFailed = true;
4043 } 3990 }
4044 } 3991 }
4045 if (page()) 3992 if (page())
4046 page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositin gActive); 3993 page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositin gActive);
4047 } 3994 }
4048 3995
4049 WebInputHandler* WebViewImpl::createInputHandler() 3996 WebInputHandler* WebViewImpl::createInputHandler()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 4047
4101 // Force a style recalc to remove all the composited layers. 4048 // Force a style recalc to remove all the composited layers.
4102 m_page->mainFrame()->document()->scheduleForcedStyleRecalc(); 4049 m_page->mainFrame()->document()->scheduleForcedStyleRecalc();
4103 4050
4104 if (m_pageOverlays) 4051 if (m_pageOverlays)
4105 m_pageOverlays->update(); 4052 m_pageOverlays->update();
4106 } 4053 }
4107 4054
4108 void WebViewImpl::updateLayerTreeViewport() 4055 void WebViewImpl::updateLayerTreeViewport()
4109 { 4056 {
4110 if (!page() || !m_nonCompositedContentHost || !m_layerTreeView) 4057 if (!page() || !m_layerTreeView)
4111 return; 4058 return;
4112 4059
4113 FrameView* view = page()->mainFrame()->view();
4114 m_nonCompositedContentHost->setViewport(m_size, view->contentsSize(), view-> scrollPosition(), view->scrollOrigin());
4115 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPag eScaleFactor, m_maximumPageScaleFactor); 4060 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPag eScaleFactor, m_maximumPageScaleFactor);
4116 } 4061 }
4117 4062
4118 void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex) 4063 void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex)
4119 { 4064 {
4120 if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestio nsCount()) 4065 if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestio nsCount())
4121 m_autofillPopupClient->valueChanged(listIndex); 4066 m_autofillPopupClient->valueChanged(listIndex);
4122 } 4067 }
4123 4068
4124 bool WebViewImpl::detectContentOnTouch(const WebPoint& position) 4069 bool WebViewImpl::detectContentOnTouch(const WebPoint& position)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 } 4156 }
4212 4157
4213 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4158 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4214 { 4159 {
4215 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4160 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4216 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4161 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4217 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4162 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4218 } 4163 }
4219 4164
4220 } // namespace WebKit 4165 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698