Skip to content

Commit

Permalink
[Backport] Use compositor for page popups.
Browse files Browse the repository at this point in the history
This is essentially the last user of the legacy 2d path.

BUG=271140

Review URL: https://codereview.chromium.org/171343003

Change-Id: I64911d0d83b9d1d4782dff9b09db1bbcc439da24
git-svn-id: svn://svn.chromium.org/blink/trunk@167552 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
  • Loading branch information
jbauman2 authored and elProxy committed Apr 8, 2014
1 parent f4cdc8d commit a674cb3
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
87 changes: 87 additions & 0 deletions chromium/third_party/WebKit/Source/web/WebPagePopupImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ class PagePopupChromeClient : public EmptyChromeClient {
m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents);
}

virtual GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE
{
return m_popup->m_webView->graphicsLayerFactory();
}

virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer* graphicsLayer) OVERRIDE
{
m_popup->setRootGraphicsLayer(graphicsLayer);
}

WebPagePopupImpl* m_popup;
};

Expand All @@ -157,6 +167,10 @@ bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType
WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client)
: m_widgetClient(client)
, m_closing(false)
, m_layerTreeView(0)
, m_rootLayer(0)
, m_rootGraphicsLayer(0)
, m_isAcceleratedCompositingActive(false)
{
ASSERT(client);
}
Expand Down Expand Up @@ -224,6 +238,49 @@ void WebPagePopupImpl::destroyPage()
m_page.clear();
}

void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer)
{
m_rootGraphicsLayer = layer;
m_rootLayer = layer ? layer->platformLayer() : 0;

setIsAcceleratedCompositingActive(layer);
if (m_layerTreeView) {
if (m_rootLayer) {
m_layerTreeView->setRootLayer(*m_rootLayer);
} else {
m_layerTreeView->clearRootLayer();
}
}
}

void WebPagePopupImpl::setIsAcceleratedCompositingActive(bool enter)
{
if (m_isAcceleratedCompositingActive == enter)
return;

if (!enter) {
m_isAcceleratedCompositingActive = false;
m_widgetClient->didDeactivateCompositor();
} else if (m_layerTreeView) {
m_isAcceleratedCompositingActive = true;
m_widgetClient->didActivateCompositor(0);
} else {
TRACE_EVENT0("webkit", "WebPagePopupImpl::setIsAcceleratedCompositingActive(true)");

m_widgetClient->initializeLayerTreeView();
m_layerTreeView = m_widgetClient->layerTreeView();
if (m_layerTreeView) {
m_layerTreeView->setVisible(true);
m_widgetClient->didActivateCompositor(0);
m_isAcceleratedCompositingActive = true;
m_layerTreeView->setDeviceScaleFactor(m_widgetClient->deviceScaleFactor());
} else {
m_isAcceleratedCompositingActive = false;
m_widgetClient->didDeactivateCompositor();
}
}
}

WebSize WebPagePopupImpl::size()
{
return m_popupClient->contentSize();
Expand All @@ -234,6 +291,36 @@ void WebPagePopupImpl::animate(double)
PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime());
}

void WebPagePopupImpl::enterForceCompositingMode(bool enter)
{
if (m_page->settings().forceCompositingMode() == enter)
return;

TRACE_EVENT1("webkit", "WebPagePopupImpl::enterForceCompositingMode", "enter", enter);
m_page->settings().setForceCompositingMode(enter);
if (enter) {
if (!m_page)
return;
Frame* mainFrame = m_page->mainFrame();
if (!mainFrame)
return;
mainFrame->view()->updateCompositingLayersAfterStyleChange();
}
}

void WebPagePopupImpl::didExitCompositingMode()
{
setIsAcceleratedCompositingActive(false);
m_widgetClient->didInvalidateRect(IntRect(0, 0, size().width, size().height));
m_page->mainFrame()->document()->setNeedsStyleRecalc(SubtreeStyleChange);
}

void WebPagePopupImpl::willCloseLayerTreeView()
{
setIsAcceleratedCompositingActive(false);
m_layerTreeView = 0;
}

void WebPagePopupImpl::layout()
{
PageWidgetDelegate::layout(m_page.get());
Expand Down
13 changes: 13 additions & 0 deletions chromium/third_party/WebKit/Source/web/WebPagePopupImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "wtf/RefCounted.h"

namespace WebCore {
class GraphicsLayer;
class Page;
class PagePopupClient;
class PlatformKeyboardEvent;
Expand All @@ -46,6 +47,8 @@ class PlatformKeyboardEvent;
namespace blink {

class PagePopupChromeClient;
class WebLayerTreeView;
class WebLayer;
class WebViewImpl;

class WebPagePopupImpl : public WebPagePopup,
Expand All @@ -68,6 +71,9 @@ class WebPagePopupImpl : public WebPagePopup,
virtual WebSize size() OVERRIDE;
virtual void animate(double) OVERRIDE;
virtual void layout() OVERRIDE;
virtual void enterForceCompositingMode(bool enter) OVERRIDE;
virtual void didExitCompositingMode() OVERRIDE;
virtual void willCloseLayerTreeView() OVERRIDE;
virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
virtual void resize(const WebSize&) OVERRIDE;
virtual void close() OVERRIDE;
Expand All @@ -83,6 +89,8 @@ class WebPagePopupImpl : public WebPagePopup,
explicit WebPagePopupImpl(WebWidgetClient*);
bool initializePage();
void destroyPage();
void setRootGraphicsLayer(WebCore::GraphicsLayer*);
void setIsAcceleratedCompositingActive(bool enter);

WebWidgetClient* m_widgetClient;
WebRect m_windowRectInScreen;
Expand All @@ -92,6 +100,11 @@ class WebPagePopupImpl : public WebPagePopup,
WebCore::PagePopupClient* m_popupClient;
bool m_closing;

WebLayerTreeView* m_layerTreeView;
WebLayer* m_rootLayer;
WebCore::GraphicsLayer* m_rootGraphicsLayer;
bool m_isAcceleratedCompositingActive;

friend class WebPagePopup;
friend class PagePopupChromeClient;
};
Expand Down

0 comments on commit a674cb3

Please sign in to comment.