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

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
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, LayerPaintingInfo pai ntingInfo, PaintLayerFlags paintFlags)
18 : m_filterInProgress(false)
19 , m_context(context)
20 {
21
mstensho (USE GERRIT) 2014/11/11 22:03:19 Extraneous blank line.
22 SkiaImageFilterBuilder builder(context);
23 RefPtr<FilterEffect> lastEffect = renderLayer.filterRenderer()->lastEffect() ;
24 lastEffect->determineFilterPrimitiveSubregion(MapRectForward);
25 RefPtr<ImageFilter> imageFilter = builder.build(lastEffect.get(), ColorSpace DeviceRGB);
26 if (!imageFilter)
27 return;
28
29 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) {
30 m_clipRecorder = adoptPtr(new ClipRecorder(&renderLayer, context, Displa yItem::ClipLayerFilter, clipRect));
31 LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, clipRect, 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

Powered by Google App Engine
This is Rietveld 408576698