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

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

Issue 2465983002: Rename "paint invalidation rect" etc. to "visual rect". (Closed)
Patch Set: - Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/SVGMaskPainter.h" 5 #include "core/paint/SVGMaskPainter.h"
6 6
7 #include "core/layout/svg/LayoutSVGResourceMasker.h" 7 #include "core/layout/svg/LayoutSVGResourceMasker.h"
8 #include "core/paint/LayoutObjectDrawingRecorder.h" 8 #include "core/paint/LayoutObjectDrawingRecorder.h"
9 #include "core/paint/PaintInfo.h" 9 #include "core/paint/PaintInfo.h"
10 #include "core/paint/TransformRecorder.h" 10 #include "core/paint/TransformRecorder.h"
11 #include "platform/graphics/paint/CompositingDisplayItem.h" 11 #include "platform/graphics/paint/CompositingDisplayItem.h"
12 #include "platform/graphics/paint/CompositingRecorder.h" 12 #include "platform/graphics/paint/CompositingRecorder.h"
13 #include "platform/graphics/paint/DrawingDisplayItem.h" 13 #include "platform/graphics/paint/DrawingDisplayItem.h"
14 #include "platform/graphics/paint/PaintController.h" 14 #include "platform/graphics/paint/PaintController.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 bool SVGMaskPainter::prepareEffect(const LayoutObject& object, 18 bool SVGMaskPainter::prepareEffect(const LayoutObject& object,
19 GraphicsContext& context) { 19 GraphicsContext& context) {
20 ASSERT(m_mask.style()); 20 ASSERT(m_mask.style());
21 SECURITY_DCHECK(!m_mask.needsLayout()); 21 SECURITY_DCHECK(!m_mask.needsLayout());
22 22
23 m_mask.clearInvalidationMask(); 23 m_mask.clearInvalidationMask();
24 24
25 FloatRect paintInvalidationRect = 25 FloatRect visualRect = object.visualRectInLocalSVGCoordinates();
26 object.paintInvalidationRectInLocalSVGCoordinates(); 26 if (visualRect.isEmpty() || !m_mask.element()->hasChildren())
27 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren())
28 return false; 27 return false;
29 28
30 context.getPaintController().createAndAppend<BeginCompositingDisplayItem>( 29 context.getPaintController().createAndAppend<BeginCompositingDisplayItem>(
31 object, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect); 30 object, SkXfermode::kSrcOver_Mode, 1, &visualRect);
32 return true; 31 return true;
33 } 32 }
34 33
35 void SVGMaskPainter::finishEffect(const LayoutObject& object, 34 void SVGMaskPainter::finishEffect(const LayoutObject& object,
36 GraphicsContext& context) { 35 GraphicsContext& context) {
37 ASSERT(m_mask.style()); 36 ASSERT(m_mask.style());
38 SECURITY_DCHECK(!m_mask.needsLayout()); 37 SECURITY_DCHECK(!m_mask.needsLayout());
39 38
40 FloatRect paintInvalidationRect = 39 FloatRect visualRect = object.visualRectInLocalSVGCoordinates();
41 object.paintInvalidationRectInLocalSVGCoordinates();
42 { 40 {
43 ColorFilter maskLayerFilter = 41 ColorFilter maskLayerFilter =
44 m_mask.style()->svgStyle().maskType() == MT_LUMINANCE 42 m_mask.style()->svgStyle().maskType() == MT_LUMINANCE
45 ? ColorFilterLuminanceToAlpha 43 ? ColorFilterLuminanceToAlpha
46 : ColorFilterNone; 44 : ColorFilterNone;
47 CompositingRecorder maskCompositing( 45 CompositingRecorder maskCompositing(context, object,
48 context, object, SkXfermode::kDstIn_Mode, 1, &paintInvalidationRect, 46 SkXfermode::kDstIn_Mode, 1, &visualRect,
49 maskLayerFilter); 47 maskLayerFilter);
50 drawMaskForLayoutObject(context, object, object.objectBoundingBox(), 48 drawMaskForLayoutObject(context, object, object.objectBoundingBox(),
51 paintInvalidationRect); 49 visualRect);
52 } 50 }
53 51
54 context.getPaintController().endItem<EndCompositingDisplayItem>(object); 52 context.getPaintController().endItem<EndCompositingDisplayItem>(object);
55 } 53 }
56 54
57 void SVGMaskPainter::drawMaskForLayoutObject( 55 void SVGMaskPainter::drawMaskForLayoutObject(
58 GraphicsContext& context, 56 GraphicsContext& context,
59 const LayoutObject& layoutObject, 57 const LayoutObject& layoutObject,
60 const FloatRect& targetBoundingBox, 58 const FloatRect& targetBoundingBox,
61 const FloatRect& targetPaintInvalidationRect) { 59 const FloatRect& targetVisualRect) {
62 AffineTransform contentTransformation; 60 AffineTransform contentTransformation;
63 sk_sp<const SkPicture> maskContentPicture = m_mask.createContentPicture( 61 sk_sp<const SkPicture> maskContentPicture = m_mask.createContentPicture(
64 contentTransformation, targetBoundingBox, context); 62 contentTransformation, targetBoundingBox, context);
65 63
66 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( 64 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
67 context, layoutObject, DisplayItem::kSVGMask)) 65 context, layoutObject, DisplayItem::kSVGMask))
68 return; 66 return;
69 67
70 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, 68 LayoutObjectDrawingRecorder drawingRecorder(
71 DisplayItem::kSVGMask, 69 context, layoutObject, DisplayItem::kSVGMask, targetVisualRect);
72 targetPaintInvalidationRect);
73 context.save(); 70 context.save();
74 context.concatCTM(contentTransformation); 71 context.concatCTM(contentTransformation);
75 context.drawPicture(maskContentPicture.get()); 72 context.drawPicture(maskContentPicture.get());
76 context.restore(); 73 context.restore();
77 } 74 }
78 75
79 } // namespace blink 76 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698