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

Unified Diff: Source/core/paint/FilterPainter.cpp

Issue 721773005: [Slimming Paint] Add *FilterDisplayItem type for slimming paint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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/core/paint/FilterPainter.h ('k') | Source/core/paint/ViewDisplayList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/FilterPainter.cpp
diff --git a/Source/core/paint/FilterPainter.cpp b/Source/core/paint/FilterPainter.cpp
index 9fe1e9483320a57f3a1cfcceab9c7b82676bfcc1..9f82642290490af86ce93167d5afe5eecaed07c8 100644
--- a/Source/core/paint/FilterPainter.cpp
+++ b/Source/core/paint/FilterPainter.cpp
@@ -8,16 +8,52 @@
#include "core/paint/LayerPainter.h"
#include "core/rendering/FilterEffectRenderer.h"
#include "core/rendering/RenderLayer.h"
+#include "core/rendering/RenderView.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/filters/FilterEffect.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
namespace blink {
+void BeginFilterDisplayItem::replay(GraphicsContext* context)
+{
+ context->save();
+ FloatRect boundaries = mapImageFilterRect(m_imageFilter.get(), m_bounds);
+ context->translate(m_bounds.x().toFloat(), m_bounds.y().toFloat());
+ boundaries.move(-m_bounds.x().toFloat(), -m_bounds.y().toFloat());
+ context->beginLayer(1, CompositeSourceOver, &boundaries, ColorFilterNone, m_imageFilter.get());
+ context->translate(-m_bounds.x().toFloat(), -m_bounds.y().toFloat());
+}
+
+#ifndef NDEBUG
+WTF::String BeginFilterDisplayItem::asDebugString() const
+{
+ return String::format("{%s, type: \"%s\", filter bounds: [%f,%f,%f,%f]}",
+ rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()).utf8().data(),
+ m_bounds.x().toFloat(), m_bounds.y().toFloat(), m_bounds.width().toFloat(), m_bounds.height().toFloat());
+}
+#endif
+
+void EndFilterDisplayItem::replay(GraphicsContext* context)
+{
+ context->endLayer();
+ context->restore();
+}
+
+#ifndef NDEBUG
+WTF::String EndFilterDisplayItem::asDebugString() const
+{
+ return String::format("{%s, type: \"%s\"}",
+ rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()).utf8().data());
+}
+#endif
+
FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context, const LayoutPoint& offsetFromRoot, const ClipRect& clipRect, LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags,
LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed)
: m_filterInProgress(false)
, m_context(context)
+ , m_renderer(renderLayer.renderer())
{
if (!renderLayer.filterRenderer() || !renderLayer.paintsWithFilters())
return;
@@ -50,20 +86,26 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context,
LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, paintFlags, *m_clipRecorder);
}
- context->save();
- FloatRect boundaries = mapImageFilterRect(imageFilter.get(), rootRelativeBounds);
- context->translate(rootRelativeBounds.x().toFloat(), rootRelativeBounds.y().toFloat());
- boundaries.move(-rootRelativeBounds.x().toFloat(), -rootRelativeBounds.y().toFloat());
- context->beginLayer(1, CompositeSourceOver, &boundaries, ColorFilterNone, imageFilter.get());
- context->translate(-rootRelativeBounds.x().toFloat(), -rootRelativeBounds.y().toFloat());
+ OwnPtr<BeginFilterDisplayItem> filterDisplayItem = adoptPtr(new BeginFilterDisplayItem(m_renderer, DisplayItem::BeginFilter, imageFilter, rootRelativeBounds));
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ renderLayer.renderer()->view()->viewDisplayList().add(filterDisplayItem.release());
+ } else {
+ filterDisplayItem->replay(context);
+ }
+
m_filterInProgress = true;
}
FilterPainter::~FilterPainter()
{
- if (m_filterInProgress) {
- m_context->endLayer();
- m_context->restore();
+ if (!m_filterInProgress)
+ return;
+
+ OwnPtr<EndFilterDisplayItem> endFilterDisplayItem = adoptPtr(new EndFilterDisplayItem(m_renderer));
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ m_renderer->view()->viewDisplayList().add(endFilterDisplayItem.release());
+ } else {
+ endFilterDisplayItem->replay(m_context);
}
}
« no previous file with comments | « Source/core/paint/FilterPainter.h ('k') | Source/core/paint/ViewDisplayList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698