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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/FilterPainter.h ('k') | Source/core/paint/LayerPainter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/FilterPainter.h"
7
8 #include "core/paint/LayerPainter.h"
9 #include "core/rendering/FilterEffectRenderer.h"
10 #include "core/rendering/RenderLayer.h"
11 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/filters/FilterEffect.h"
13 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
14
15 namespace blink {
16
17 FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context, const FloatRect& filterBoxRect, const ClipRect& clipRect, const LayerPaintingIn fo& paintingInfo, PaintLayerFlags paintFlags)
18 : m_filterInProgress(false)
19 , m_context(context)
20 {
21 SkiaImageFilterBuilder builder(context);
22 RefPtr<FilterEffect> lastEffect = renderLayer.filterRenderer()->lastEffect() ;
23 lastEffect->determineFilterPrimitiveSubregion(MapRectForward);
24 RefPtr<ImageFilter> imageFilter = builder.build(lastEffect.get(), ColorSpace DeviceRGB);
25 if (!imageFilter)
26 return;
27
28 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) {
29 m_clipRecorder = adoptPtr(new ClipRecorder(&renderLayer, context, Displa yItem::ClipLayerFilter, clipRect));
30 if (clipRect.hasRadius())
31 LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, conte xt, paintFlags, *m_clipRecorder);
32 }
33
34 context->save();
35 FloatRect boundaries = mapImageFilterRect(imageFilter.get(), filterBoxRect);
36 context->translate(filterBoxRect.x(), filterBoxRect.y());
37 boundaries.move(-filterBoxRect.x(), -filterBoxRect.y());
38 context->beginLayer(1, CompositeSourceOver, &boundaries, ColorFilterNone, im ageFilter.get());
39 context->translate(-filterBoxRect.x(), -filterBoxRect.y());
40 m_filterInProgress = true;
41 }
42
43 FilterPainter::~FilterPainter()
44 {
45 if (m_filterInProgress) {
46 m_context->endLayer();
47 m_context->restore();
48 }
49 }
50
51 } // namespace blink
OLDNEW
« 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