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

Side by Side Diff: Source/core/paint/SVGMaskPainter.cpp

Issue 967543002: [S.P.] Move svg mask painting to SVGMaskPainter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review fixes Created 5 years, 9 months 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
« no previous file with comments | « Source/core/paint/SVGMaskPainter.h ('k') | Source/core/paint/SVGPaintContext.cpp » ('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 2015 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/SVGMaskPainter.h"
7
8 #include "core/layout/PaintInfo.h"
9 #include "core/layout/svg/LayoutSVGResourceMasker.h"
10 #include "core/paint/CompositingRecorder.h"
11 #include "core/paint/TransformRecorder.h"
12 #include "platform/graphics/paint/CompositingDisplayItem.h"
13 #include "platform/graphics/paint/DisplayItemList.h"
14 #include "platform/graphics/paint/DrawingDisplayItem.h"
15
16 namespace blink {
17
18 bool SVGMaskPainter::prepareEffect(LayoutObject* object, GraphicsContext* contex t)
19 {
20 ASSERT(object);
21 ASSERT(context);
22 ASSERT(m_mask.style());
23 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout());
24
25 m_mask.clearInvalidationMask();
26
27 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates();
28 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren())
29 return false;
30
31 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
32 ASSERT(context->displayItemList());
33 context->displayItemList()->add(BeginCompositingDisplayItem::create(obje ct->displayItemClient(), WebCoreCompositeToSkiaComposite(context->compositeOpera tionDeprecated(), WebBlendModeNormal), 1, &paintInvalidationRect));
34 } else {
35 BeginCompositingDisplayItem beginCompositingContent(object->displayItemC lient(), WebCoreCompositeToSkiaComposite(context->compositeOperationDeprecated() , WebBlendModeNormal), 1, &paintInvalidationRect);
36 beginCompositingContent.replay(context);
37 }
38
39 return true;
40 }
41
42 void SVGMaskPainter::finishEffect(LayoutObject* object, GraphicsContext* context )
43 {
44 ASSERT(object);
45 ASSERT(context);
46 ASSERT(m_mask.style());
47 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout());
48
49 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates();
50 {
51 ColorFilter maskLayerFilter = m_mask.style()->svgStyle().maskType() == M T_LUMINANCE
52 ? ColorFilterLuminanceToAlpha : ColorFilterNone;
53 CompositingRecorder maskCompositing(context, object->displayItemClient() , SkXfermode::kDstIn_Mode, 1, &paintInvalidationRect, maskLayerFilter);
54 drawMaskForRenderer(context, object->displayItemClient(), object->object BoundingBox());
55 }
56
57 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
58 ASSERT(context->displayItemList());
59 context->displayItemList()->add(EndCompositingDisplayItem::create(object ->displayItemClient()));
60 } else {
61 EndCompositingDisplayItem endCompositingContent(object->displayItemClien t());
62 endCompositingContent.replay(context);
63 }
64 }
65
66 void SVGMaskPainter::drawMaskForRenderer(GraphicsContext* context, DisplayItemCl ient client, const FloatRect& targetBoundingBox)
67 {
68 ASSERT(context);
69
70 AffineTransform contentTransformation;
71 RefPtr<const SkPicture> maskContentPicture = m_mask.getContentPicture(conten tTransformation, targetBoundingBox);
72
73 TransformRecorder recorder(*context, client, contentTransformation);
74
75 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
76 ASSERT(context->displayItemList());
77 context->displayItemList()->add(DrawingDisplayItem::create(client, Displ ayItem::SVGMask, maskContentPicture));
78 } else {
79 DrawingDisplayItem maskPicture(client, DisplayItem::SVGMask, maskContent Picture);
80 maskPicture.replay(context);
81 }
82 }
83
84 }
OLDNEW
« no previous file with comments | « Source/core/paint/SVGMaskPainter.h ('k') | Source/core/paint/SVGPaintContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698