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

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
« no previous file with comments | « Source/core/paint/FilterPainter.h ('k') | Source/core/paint/LayerPainter.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
new file mode 100644
index 0000000000000000000000000000000000000000..4591c71baf20cc32a5ed6d20fa0a737b9227777b
--- /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, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
+ : m_filterInProgress(false)
+ , m_context(context)
+{
+ 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));
+ if (clipRect.hasRadius())
+ LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, 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
« no previous file with comments | « Source/core/paint/FilterPainter.h ('k') | Source/core/paint/LayerPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698