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

Unified Diff: Source/web/PageOverlay.cpp

Issue 867063004: [Slimming Paint] Paint the inspector overlay with GraphicsLayer DisplayList. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
Index: Source/web/PageOverlay.cpp
diff --git a/Source/web/PageOverlay.cpp b/Source/web/PageOverlay.cpp
index b909ca64831626737a3ef8b5ec45ce803d7625af..4bf3c8286c1dd3b3d39b460789727b225ffd9803 100644
--- a/Source/web/PageOverlay.cpp
+++ b/Source/web/PageOverlay.cpp
@@ -32,8 +32,10 @@
#include "core/frame/Settings.h"
#include "core/page/Page.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/GraphicsContextStateSaver.h"
#include "platform/graphics/GraphicsLayer.h"
-#include "platform/graphics/GraphicsLayerClient.h"
+#include "platform/graphics/paint/DisplayItem.h"
+#include "platform/graphics/paint/DrawingRecorder.h"
#include "public/platform/WebLayer.h"
#include "public/web/WebPageOverlay.h"
#include "public/web/WebViewClient.h"
@@ -41,56 +43,31 @@
namespace blink {
-namespace {
-
-WebCanvas* ToWebCanvas(GraphicsContext* gc)
+PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverlay* overlay)
{
- return gc->canvas();
+ return adoptPtr(new PageOverlay(viewImpl, overlay));
}
-} // namespace
-
-PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverlay* overlay)
+PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, PageOverlay::Painter* overlayPainter)
{
- return adoptPtr(new PageOverlay(viewImpl, overlay));
+ return adoptPtr(new PageOverlay(viewImpl, overlayPainter));
}
PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay)
: m_viewImpl(viewImpl)
, m_overlay(overlay)
+ , m_overlayPainter(nullptr)
, m_zOrder(0)
{
}
-class OverlayGraphicsLayerClientImpl : public GraphicsLayerClient {
-public:
- static PassOwnPtr<OverlayGraphicsLayerClientImpl> create(WebPageOverlay* overlay)
- {
- return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay));
- }
-
- virtual ~OverlayGraphicsLayerClientImpl() { }
-
- virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, GraphicsLayerPaintingPhase, const IntRect& inClip)
- {
- gc.save();
- m_overlay->paintPageOverlay(ToWebCanvas(&gc));
- gc.restore();
- }
-
- virtual String debugName(const GraphicsLayer* graphicsLayer) override
- {
- return String("WebViewImpl Page Overlay Content Layer");
- }
-
-private:
- explicit OverlayGraphicsLayerClientImpl(WebPageOverlay* overlay)
- : m_overlay(overlay)
- {
- }
-
- WebPageOverlay* m_overlay;
-};
+PageOverlay::PageOverlay(WebViewImpl* viewImpl, PageOverlay::Painter* overlayPainter)
+ : m_viewImpl(viewImpl)
+ , m_overlay(nullptr)
+ , m_overlayPainter(overlayPainter)
+ , m_zOrder(0)
+{
+}
void PageOverlay::clear()
{
@@ -101,7 +78,6 @@ void PageOverlay::clear()
if (Page* page = m_viewImpl->page())
page->inspectorController().didRemovePageOverlay(m_layer.get());
m_layer = nullptr;
- m_layerClient = nullptr;
}
}
@@ -110,8 +86,7 @@ void PageOverlay::update()
invalidateWebFrame();
if (!m_layer) {
- m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay);
- m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_layerClient.get());
+ m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), this /* client */);
m_layer->setDrawsContent(true);
if (Page* page = m_viewImpl->page())
@@ -136,13 +111,33 @@ void PageOverlay::update()
void PageOverlay::paintWebFrame(GraphicsContext& gc)
{
- if (!m_viewImpl->isAcceleratedCompositingActive()) {
- gc.save();
- m_overlay->paintPageOverlay(ToWebCanvas(&gc));
- gc.restore();
+ if (m_overlay) {
+ // We clip the painted contents to the WebViewImpl, because
+ // DrawingRecorder expects to know bounds.
+ DisplayItemClient displayItemClient = static_cast<DisplayItemClient>(static_cast<void*>(this));
+ IntSize size = m_viewImpl->size();
+ FloatRect clipRect(FloatPoint(0, 0), size);
+ DrawingRecorder recorder(&gc, displayItemClient, DisplayItem::PageOverlay, clipRect);
+ GraphicsContextStateSaver saver(gc);
+ gc.clipRect(clipRect);
+ m_overlay->paintPageOverlay(gc.canvas());
+ } else if (m_overlayPainter) {
+ // FIXME: Maybe we need to make the callee responsible for saving.
+ // We can't save a GraphicsContext unless we have a canvas.
+ m_overlayPainter->paintPageOverlay(gc);
}
}
+void PageOverlay::paintContents(const GraphicsLayer*, GraphicsContext& gc, GraphicsLayerPaintingPhase, const IntRect& inClip)
+{
+ paintWebFrame(gc);
+}
+
+String PageOverlay::debugName(const GraphicsLayer*)
+{
+ return "WebViewImpl Page Overlay Content Layer";
+}
+
void PageOverlay::invalidateWebFrame()
{
// WebPageOverlay does the actual painting of the overlay.

Powered by Google App Engine
This is Rietveld 408576698