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

Side by Side Diff: Source/core/rendering/svg/SVGRenderingContext.cpp

Issue 683703005: Prefer unprefixed clip-path to (webkit) prefixed (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
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved. 5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 ASSERT(object); 79 ASSERT(object);
80 80
81 #if ENABLE(ASSERT) 81 #if ENABLE(ASSERT)
82 // This function must not be called twice! 82 // This function must not be called twice!
83 ASSERT(!(m_renderingFlags & PrepareToRenderSVGContentWasCalled)); 83 ASSERT(!(m_renderingFlags & PrepareToRenderSVGContentWasCalled));
84 m_renderingFlags |= PrepareToRenderSVGContentWasCalled; 84 m_renderingFlags |= PrepareToRenderSVGContentWasCalled;
85 #endif 85 #endif
86 86
87 m_object = object; 87 m_object = object;
88 m_paintInfo = &paintInfo; 88 m_paintInfo = &paintInfo;
89 m_filter = 0;
90 89
91 RenderStyle* style = m_object->style(); 90 RenderStyle* style = m_object->style();
92 ASSERT(style); 91 ASSERT(style);
93 92
94 const SVGRenderStyle& svgStyle = style->svgStyle(); 93 const SVGRenderStyle& svgStyle = style->svgStyle();
95 94
96 // Setup transparency layers before setting up SVG resources! 95 // Setup transparency layers before setting up SVG resources!
97 bool isRenderingMask = SVGRenderSupport::isRenderingClipPathAsMaskImage(*m_o bject); 96 bool isRenderingMask = SVGRenderSupport::isRenderingClipPathAsMaskImage(*m_o bject);
98 // RenderLayer takes care of root opacity. 97 // RenderLayer takes care of root opacity.
99 float opacity = (object->isSVGRoot() || isRenderingMask) ? 1 : style->opacit y(); 98 float opacity = object->isSVGRoot() ? 1 : style->opacity();
100 bool hasBlendMode = style->hasBlendMode() && !isRenderingMask; 99 bool hasBlendMode = style->hasBlendMode();
101 100
102 if (opacity < 1 || hasBlendMode || style->hasIsolation()) { 101 if (!isRenderingMask && (opacity < 1 || hasBlendMode || style->hasIsolation( ))) {
f(malita) 2014/10/31 17:24:46 This shuffling has side effects: hasIsolation() no
fs 2014/10/31 19:29:22 I made (maybe too brief?) note about this in the l
f(malita) 2014/10/31 19:36:35 Thanks, I missed that. LGTM.
103 FloatRect paintInvalidationRect = m_object->paintInvalidationRectInLocal Coordinates(); 102 FloatRect paintInvalidationRect = m_object->paintInvalidationRectInLocal Coordinates();
104 m_paintInfo->context->clip(paintInvalidationRect); 103 m_paintInfo->context->clip(paintInvalidationRect);
105 104
106 if (hasBlendMode) { 105 if (hasBlendMode) {
107 if (!(m_renderingFlags & RestoreGraphicsContext)) { 106 if (!(m_renderingFlags & RestoreGraphicsContext)) {
108 m_paintInfo->context->save(); 107 m_paintInfo->context->save();
109 m_renderingFlags |= RestoreGraphicsContext; 108 m_renderingFlags |= RestoreGraphicsContext;
110 } 109 }
111 m_paintInfo->context->setCompositeOperation(CompositeSourceOver, sty le->blendMode()); 110 m_paintInfo->context->setCompositeOperation(CompositeSourceOver, sty le->blendMode());
112 } 111 }
113 112
114 m_paintInfo->context->beginTransparencyLayer(opacity); 113 m_paintInfo->context->beginTransparencyLayer(opacity);
115 114
116 if (hasBlendMode) 115 if (hasBlendMode)
117 m_paintInfo->context->setCompositeOperation(CompositeSourceOver, Web BlendModeNormal); 116 m_paintInfo->context->setCompositeOperation(CompositeSourceOver, Web BlendModeNormal);
118 117
119 m_renderingFlags |= EndOpacityLayer; 118 m_renderingFlags |= EndOpacityLayer;
120 } 119 }
121 120
122 ClipPathOperation* clipPathOperation = style->clipPath(); 121 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( m_object);
123 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::SHA PE) { 122
124 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOper ation); 123 // Prefer a 'clipper' (non-prefixed 'clip-path') to a 'clip shape'
125 m_paintInfo->context->clipPath(clipPath->path(object->objectBoundingBox( )), clipPath->windRule()); 124 // ('-webkit-clip-path'), until these two properties end up being merged
125 // properly.
126 if (RenderSVGResourceClipper* clipper = resources ? resources->clipper() : n ullptr) {
127 if (!clipper->applyStatefulResource(m_object, m_paintInfo->context, m_cl ipperState))
128 return;
129 m_clipper = clipper;
130 m_renderingFlags |= PostApplyResources;
131 } else {
132 ClipPathOperation* clipPathOperation = style->clipPath();
133 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation: :SHAPE) {
134 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPath Operation);
135 m_paintInfo->context->clipPath(clipPath->path(object->objectBounding Box()), clipPath->windRule());
136 }
126 } 137 }
127 138
128 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( m_object); 139 if (isRenderingMask) {
129 if (!resources) {
130 if (svgStyle.hasFilter())
131 return;
132
133 m_renderingFlags |= RenderingPrepared; 140 m_renderingFlags |= RenderingPrepared;
134 return; 141 return;
135 } 142 }
136 143
137 if (!isRenderingMask) { 144 if (resources) {
138 if (RenderSVGResourceMasker* masker = resources->masker()) { 145 if (RenderSVGResourceMasker* masker = resources->masker()) {
139 if (!masker->prepareEffect(m_object, m_paintInfo->context)) 146 if (!masker->prepareEffect(m_object, m_paintInfo->context))
140 return; 147 return;
141 m_masker = masker; 148 m_masker = masker;
142 m_renderingFlags |= PostApplyResources; 149 m_renderingFlags |= PostApplyResources;
143 } 150 }
144 }
145 151
146 RenderSVGResourceClipper* clipper = resources->clipper();
147 if (!clipPathOperation && clipper) {
148 if (!clipper->applyStatefulResource(m_object, m_paintInfo->context, m_cl ipperState))
149 return;
150 m_clipper = clipper;
151 m_renderingFlags |= PostApplyResources;
152 }
153
154 if (!isRenderingMask) {
155 m_filter = resources->filter(); 152 m_filter = resources->filter();
156 if (m_filter) { 153 if (m_filter) {
157 m_savedContext = m_paintInfo->context; 154 m_savedContext = m_paintInfo->context;
158 m_savedPaintRect = m_paintInfo->rect; 155 m_savedPaintRect = m_paintInfo->rect;
159 // Return with false here may mean that we don't need to draw the co ntent 156 // Return with false here may mean that we don't need to draw the co ntent
160 // (because it was either drawn before or empty) but we still need t o apply the filter. 157 // (because it was either drawn before or empty) but we still need t o apply the filter.
161 m_renderingFlags |= PostApplyResources; 158 m_renderingFlags |= PostApplyResources;
162 if (!m_filter->prepareEffect(m_object, m_paintInfo->context)) 159 if (!m_filter->prepareEffect(m_object, m_paintInfo->context))
163 return; 160 return;
164 161
165 // Since we're caching the resulting bitmap and do not invalidate it on paint invalidation rect 162 // Since we're caching the resulting bitmap and do not invalidate it on paint invalidation rect
166 // changes, we need to paint the whole filter region. Otherwise, ele ments not visible 163 // changes, we need to paint the whole filter region. Otherwise, ele ments not visible
167 // at the time of the initial paint (due to scrolling, window size, etc.) will never 164 // at the time of the initial paint (due to scrolling, window size, etc.) will never
168 // be drawn. 165 // be drawn.
169 m_paintInfo->rect = IntRect(m_filter->drawingRegion(m_object)); 166 m_paintInfo->rect = IntRect(m_filter->drawingRegion(m_object));
170 } 167 }
168 } else {
169 // Broken filter disables rendering.
170 if (svgStyle.hasFilter())
171 return;
171 } 172 }
172 173
173 m_renderingFlags |= RenderingPrepared; 174 m_renderingFlags |= RenderingPrepared;
174 } 175 }
175 176
176 static AffineTransform& currentContentTransformation() 177 static AffineTransform& currentContentTransformation()
177 { 178 {
178 DEFINE_STATIC_LOCAL(AffineTransform, s_currentContentTransformation, ()); 179 DEFINE_STATIC_LOCAL(AffineTransform, s_currentContentTransformation, ());
179 return s_currentContentTransformation; 180 return s_currentContentTransformation;
180 } 181 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 { 238 {
238 ASSERT(context); 239 ASSERT(context);
239 ASSERT(item); 240 ASSERT(item);
240 ASSERT(!item->needsLayout()); 241 ASSERT(!item->needsLayout());
241 242
242 PaintInfo info(context, PaintInfo::infiniteRect(), PaintPhaseForeground, Pai ntBehaviorNormal); 243 PaintInfo info(context, PaintInfo::infiniteRect(), PaintPhaseForeground, Pai ntBehaviorNormal);
243 item->paint(info, IntPoint()); 244 item->paint(info, IntPoint());
244 } 245 }
245 246
246 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698