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

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: move drawMaskForRenderer too 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
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/layout/svg/SVGLayoutSupport.h"
fs 2015/03/02 13:24:51 Not needed?
Erik Dahlström (inactive) 2015/03/03 08:42:58 Done.
11 #include "core/paint/CompositingRecorder.h"
12 #include "core/paint/TransformRecorder.h"
13 #include "platform/graphics/paint/CompositingDisplayItem.h"
14 #include "platform/graphics/paint/DisplayItemList.h"
15 #include "platform/graphics/paint/DrawingDisplayItem.h"
16
17 namespace blink {
18
19 bool SVGMaskPainter::prepareEffect(LayoutObject* object, GraphicsContext* contex t)
20 {
21 ASSERT(object);
22 ASSERT(context);
23 ASSERT(m_mask.style());
24 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout());
25
26 m_mask.clearInvalidationMask();
27
28 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates();
29 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren())
30 return false;
31
32 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
33 ASSERT(context->displayItemList());
34 context->displayItemList()->add(BeginCompositingDisplayItem::create(obje ct->displayItemClient(), WebCoreCompositeToSkiaComposite(context->compositeOpera tionDeprecated(), WebBlendModeNormal), 1, &paintInvalidationRect));
35 } else {
36 BeginCompositingDisplayItem beginCompositingContent(object->displayItemC lient(), WebCoreCompositeToSkiaComposite(context->compositeOperationDeprecated() , WebBlendModeNormal), 1, &paintInvalidationRect);
37 beginCompositingContent.replay(context);
38 }
39
40 return true;
41 }
42
43 void SVGMaskPainter::finishEffect(LayoutObject* object, GraphicsContext* context )
44 {
45 ASSERT(object);
46 ASSERT(context);
47 ASSERT(m_mask.style());
48 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout());
49
50 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates();
51 {
52 ColorFilter maskLayerFilter = m_mask.style()->svgStyle().maskType() == M T_LUMINANCE
53 ? ColorFilterLuminanceToAlpha : ColorFilterNone;
54 CompositingRecorder maskCompositing(context, object->displayItemClient() , SkXfermode::kDstIn_Mode, 1, &paintInvalidationRect, maskLayerFilter);
55 drawMaskForRenderer(context, object->displayItemClient(), object->object BoundingBox());
56 }
57
58 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
59 ASSERT(context->displayItemList());
60 context->displayItemList()->add(EndCompositingDisplayItem::create(object ->displayItemClient()));
61 } else {
62 EndCompositingDisplayItem endCompositingContent(object->displayItemClien t());
63 endCompositingContent.replay(context);
64 }
65 }
66
67 void SVGMaskPainter::drawMaskForRenderer(GraphicsContext* context, DisplayItemCl ient client, const FloatRect& targetBoundingBox)
68 {
69 ASSERT(context);
70
71 AffineTransform contentTransformation;
72 SVGUnitTypes::SVGUnitType contentUnits = toSVGMaskElement(m_mask.element())- >maskContentUnits()->currentValue()->enumValue();
73 if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
74 contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox .y());
75 contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetB oundingBox.height());
76 }
77
78 if (!m_mask.m_maskContentPicture) {
fs 2015/03/02 13:24:51 Maybe this block (transform+content picture setup)
pdr. 2015/03/02 18:57:35 +1
Erik Dahlström (inactive) 2015/03/03 08:42:58 Done.
79 SubtreeContentTransformScope contentTransformScope(contentTransformation );
80 m_mask.m_maskContentPicture = m_mask.createContentPicture();
81 }
82
83 TransformRecorder recorder(*context, client, contentTransformation);
84
85 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
86 ASSERT(context->displayItemList());
87 context->displayItemList()->add(DrawingDisplayItem::create(client, Displ ayItem::SVGMask, m_mask.m_maskContentPicture));
88 } else {
89 DrawingDisplayItem maskPicture(client, DisplayItem::SVGMask, m_mask.m_ma skContentPicture);
90 maskPicture.replay(context);
91 }
92 }
93
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698