diff options
author | jbauman@chromium.org <jbauman@chromium.org> | 2014-01-29 00:14:45 +0000 |
---|---|---|
committer | Pierre Rossi <pierre.rossi@gmail.com> | 2014-03-31 10:50:42 +0200 |
commit | b3c9bb0a1f3eae80103ddcd84b57caf6843ae174 (patch) | |
tree | 80c88031ba78b12d5cca073ea27ef34c6bdce64b /chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp | |
parent | a6014652040e76de08e643b49b69fc97cb5bfd62 (diff) | |
download | qtwebengine-chromium-b3c9bb0a1f3eae80103ddcd84b57caf6843ae174.tar.gz |
[Backport] Use compositor with select popups.
BUG=271575
Review URL: https://codereview.chromium.org/132173005
git-svn-id: svn://svn.chromium.org/blink/trunk@165977 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Change-Id: I78b3354b1040b193c984b82db51c90b8183ebd24
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp index 05c1d05281a..e8adfd7c0df 100644 --- a/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp +++ b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp @@ -49,6 +49,10 @@ #include "platform/graphics/GraphicsContext.h" #include "platform/graphics/skia/SkiaUtils.h" #include "platform/scroll/FramelessScrollView.h" +#include "public/platform/Platform.h" +#include "public/platform/WebCompositorSupport.h" +#include "public/platform/WebContentLayer.h" +#include "public/platform/WebLayerTreeView.h" #include "public/platform/WebRect.h" #include <skia/ext/platform_canvas.h> @@ -68,6 +72,10 @@ WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) : m_client(client) + , m_layerTreeView(0) + , m_isAcceleratedCompositingActive(false) + // Set to impossible point so we always get the first mouse position. + , m_lastMousePosition(WebPoint(-1, -1)) , m_widget(0) { // Set to impossible point so we always get the first mouse position. @@ -80,6 +88,12 @@ WebPopupMenuImpl::~WebPopupMenuImpl() m_widget->setClient(0); } +void WebPopupMenuImpl::willCloseLayerTreeView() +{ + enterForceCompositingMode(false); + m_layerTreeView = 0; +} + void WebPopupMenuImpl::initialize(FramelessScrollView* widget, const WebRect& bounds) { m_widget = widget; @@ -174,6 +188,9 @@ void WebPopupMenuImpl::resize(const WebSize& newSize) WebRect damagedRect(0, 0, m_size.width, m_size.height); m_client->didInvalidateRect(damagedRect); } + + if (m_rootLayer) + m_rootLayer->layer()->setBounds(newSize); } void WebPopupMenuImpl::willEndLiveResize() @@ -188,6 +205,54 @@ void WebPopupMenuImpl::layout() { } +void WebPopupMenuImpl::enterForceCompositingMode(bool enter) +{ + if (m_isAcceleratedCompositingActive == enter) + return; + + if (!enter) { + m_isAcceleratedCompositingActive = false; + m_client->didDeactivateCompositor(); + } else if (m_layerTreeView) { + m_isAcceleratedCompositingActive = true; + m_client->didActivateCompositor(0); + } else { + TRACE_EVENT0("webkit", "WebPopupMenuImpl::enterForceCompositingMode(true)"); + + m_client->initializeLayerTreeView(); + m_layerTreeView = m_client->layerTreeView(); + if (m_layerTreeView) { + m_layerTreeView->setVisible(true); + m_client->didActivateCompositor(0); + m_isAcceleratedCompositingActive = true; + m_layerTreeView->setDeviceScaleFactor(m_client->deviceScaleFactor()); + m_rootLayer = adoptPtr(Platform::current()->compositorSupport()->createContentLayer(this)); + m_rootLayer->layer()->setBounds(m_size); + m_layerTreeView->setRootLayer(*m_rootLayer->layer()); + } else { + m_isAcceleratedCompositingActive = false; + m_client->didDeactivateCompositor(); + } + } +} + +void WebPopupMenuImpl::didExitCompositingMode() +{ + enterForceCompositingMode(false); + m_client->didInvalidateRect(IntRect(0, 0, m_size.width, m_size.height)); +} + +void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, bool, WebFloatRect&) +{ + if (!m_widget) + return; + + if (!rect.isEmpty()) { + GraphicsContext context(canvas); + m_widget->paint(&context, rect); + } +} + void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions) { if (!m_widget) @@ -343,6 +408,8 @@ void WebPopupMenuImpl::invalidateContentsAndRootView(const IntRect& paintRect) return; if (m_client) m_client->didInvalidateRect(paintRect); + if (m_rootLayer) + m_rootLayer->layer()->invalidateRect(FloatRect(paintRect)); } void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect) @@ -361,6 +428,8 @@ void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, const IntRect& scrollR int dy = scrollDelta.height(); m_client->didScrollRect(dx, dy, clipRect); } + if (m_rootLayer) + m_rootLayer->layer()->invalidateRect(FloatRect(clipRect)); } IntPoint WebPopupMenuImpl::screenToRootView(const IntPoint& point) const |