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

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

Issue 713823005: Factor painting code for filters out of FilterEffectRenderer into FilterPainter. (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
Index: Source/core/paint/FilterPainter.cpp
diff --git a/Source/core/paint/FilterPainter.cpp b/Source/core/paint/FilterPainter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..81e74b1eeaf4f0cc9dc95f39e48c5ffdfd99b9a1
--- /dev/null
+++ b/Source/core/paint/FilterPainter.cpp
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/paint/FilterPainter.h"
+
+#include "core/paint/LayerPainter.h"
+#include "core/rendering/FilterEffectRenderer.h"
+#include "core/rendering/RenderLayer.h"
+#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/filters/FilterEffect.h"
+#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
+
+namespace blink {
+
+FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context, const FloatRect& filterBoxRect, const ClipRect& clipRect, LayerPaintingInfo paintingInfo, PaintLayerFlags paintFlags)
+ : m_filterInProgress(false)
+ , m_context(context)
+{
+
mstensho (USE GERRIT) 2014/11/11 22:03:19 Extraneous blank line.
+ SkiaImageFilterBuilder builder(context);
+ RefPtr<FilterEffect> lastEffect = renderLayer.filterRenderer()->lastEffect();
+ lastEffect->determineFilterPrimitiveSubregion(MapRectForward);
+ RefPtr<ImageFilter> imageFilter = builder.build(lastEffect.get(), ColorSpaceDeviceRGB);
+ if (!imageFilter)
+ return;
+
+ if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) {
+ m_clipRecorder = adoptPtr(new ClipRecorder(&renderLayer, context, DisplayItem::ClipLayerFilter, clipRect));
+ LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, clipRect, paintFlags, *m_clipRecorder);
+ }
+
+ context->save();
+ FloatRect boundaries = mapImageFilterRect(imageFilter.get(), filterBoxRect);
+ context->translate(filterBoxRect.x(), filterBoxRect.y());
+ boundaries.move(-filterBoxRect.x(), -filterBoxRect.y());
+ context->beginLayer(1, CompositeSourceOver, &boundaries, ColorFilterNone, imageFilter.get());
+ context->translate(-filterBoxRect.x(), -filterBoxRect.y());
+ m_filterInProgress = true;
+}
+
+FilterPainter::~FilterPainter()
+{
+ if (m_filterInProgress) {
+ m_context->endLayer();
+ m_context->restore();
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698