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

Unified Diff: Source/web/WebPopupMenuImpl.cpp

Issue 132173005: Use compositor with select popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebPopupMenuImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebPopupMenuImpl.cpp
diff --git a/Source/web/WebPopupMenuImpl.cpp b/Source/web/WebPopupMenuImpl.cpp
index 91dc6581adfadd055bc7a33447e1ee318745fd61..60db61fd7d9417dad778812686660b234c1e4577 100644
--- a/Source/web/WebPopupMenuImpl.cpp
+++ b/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,8 @@ 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)
@@ -80,6 +86,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 +186,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 +203,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 +406,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 +426,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
« no previous file with comments | « Source/web/WebPopupMenuImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698