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

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

Issue 1072403010: SVG Text should respect non-scaling-stroke. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "config.h" 5 #include "config.h"
6 #include "core/paint/SVGInlineTextBoxPainter.h" 6 #include "core/paint/SVGInlineTextBoxPainter.h"
7 7
8 #include "core/dom/DocumentMarkerController.h" 8 #include "core/dom/DocumentMarkerController.h"
9 #include "core/dom/RenderedDocumentMarker.h" 9 #include "core/dom/RenderedDocumentMarker.h"
10 #include "core/editing/Editor.h" 10 #include "core/editing/Editor.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (svgDecorationStyle.hasFill()) { 271 if (svgDecorationStyle.hasFill()) {
272 SkPaint fillPaint; 272 SkPaint fillPaint;
273 if (!SVGPaintContext::paintForLayoutObject(paintInfo, decoration Style, *decorationRenderer, ApplyToFillMode, fillPaint)) 273 if (!SVGPaintContext::paintForLayoutObject(paintInfo, decoration Style, *decorationRenderer, ApplyToFillMode, fillPaint))
274 break; 274 break;
275 fillPaint.setAntiAlias(true); 275 fillPaint.setAntiAlias(true);
276 paintInfo.context->drawPath(path.skPath(), fillPaint); 276 paintInfo.context->drawPath(path.skPath(), fillPaint);
277 } 277 }
278 break; 278 break;
279 case PT_STROKE: 279 case PT_STROKE:
280 if (svgDecorationStyle.hasVisibleStroke()) { 280 if (svgDecorationStyle.hasVisibleStroke()) {
281 // FIXME: Non-scaling stroke is not applied here. 281 // FIXME: Non-scaling stroke is not applied here.
fs 2015/04/22 12:15:55 Could you fix this too? (Other CL ok, using same b
Shanmuga Pandi 2015/04/22 13:08:35 Yes. I can fix this too. Probably Other CL. Could
fs 2015/04/22 13:31:41 I think it should be sufficient to add text-decora
Shanmuga Pandi 2015/04/22 14:00:06 Thanks for the test case , I will make another CL
282 SkPaint strokePaint; 282 SkPaint strokePaint;
283 if (!SVGPaintContext::paintForLayoutObject(paintInfo, decoration Style, *decorationRenderer, ApplyToStrokeMode, strokePaint)) 283 if (!SVGPaintContext::paintForLayoutObject(paintInfo, decoration Style, *decorationRenderer, ApplyToStrokeMode, strokePaint))
284 break; 284 break;
285 strokePaint.setAntiAlias(true); 285 strokePaint.setAntiAlias(true);
286 StrokeData strokeData; 286 StrokeData strokeData;
287 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, decor ationStyle, *decorationRenderer); 287 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, decor ationStyle, *decorationRenderer);
288 strokeData.setupPaint(&strokePaint); 288 strokeData.setupPaint(&strokePaint);
289 paintInfo.context->drawPath(path.skPath(), strokePaint); 289 paintInfo.context->drawPath(path.skPath(), strokePaint);
290 } 290 }
291 break; 291 break;
(...skipping 26 matching lines...) Expand all
318 AffineTransform paintServerTransform; 318 AffineTransform paintServerTransform;
319 const AffineTransform* additionalPaintServerTransform = 0; 319 const AffineTransform* additionalPaintServerTransform = 0;
320 320
321 GraphicsContextStateSaver stateSaver(*context, false); 321 GraphicsContextStateSaver stateSaver(*context, false);
322 if (scalingFactor != 1) { 322 if (scalingFactor != 1) {
323 textOrigin.scale(scalingFactor, scalingFactor); 323 textOrigin.scale(scalingFactor, scalingFactor);
324 textSize.scale(scalingFactor); 324 textSize.scale(scalingFactor);
325 stateSaver.save(); 325 stateSaver.save();
326 context->scale(1 / scalingFactor, 1 / scalingFactor); 326 context->scale(1 / scalingFactor, 1 / scalingFactor);
327 // Adjust the paint-server coordinate space. 327 // Adjust the paint-server coordinate space.
328 paintServerTransform.scale(scalingFactor); 328 paintServerTransform.scale(scalingFactor);
fs 2015/04/22 12:15:55 Make a test with a paint-server (gradient/pattern)
Shanmuga Pandi 2015/04/22 13:08:35 Added test case
329 additionalPaintServerTransform = &paintServerTransform; 329 additionalPaintServerTransform = &paintServerTransform;
330 } 330 }
331 331
332 // FIXME: Non-scaling stroke is not applied here. 332 // FIXME: Non-scaling stroke is not applied here.
fs 2015/04/22 12:15:55 Can remove this now.
Shanmuga Pandi 2015/04/22 13:08:35 Done.
333 SkPaint paint; 333 SkPaint paint;
334 if (!SVGPaintContext::paintForLayoutObject(paintInfo, style, m_svgInlineText Box.parent()->layoutObject(), resourceMode, paint, additionalPaintServerTransfor m)) 334 if (!SVGPaintContext::paintForLayoutObject(paintInfo, style, m_svgInlineText Box.parent()->layoutObject(), resourceMode, paint, additionalPaintServerTransfor m))
335 return; 335 return;
336 paint.setAntiAlias(true); 336 paint.setAntiAlias(true);
337 337
338 if (hasShadow) { 338 if (hasShadow) {
339 OwnPtr<DrawLooperBuilder> drawLooperBuilder = shadowList->createDrawLoop er(DrawLooperBuilder::ShadowRespectsAlpha); 339 OwnPtr<DrawLooperBuilder> drawLooperBuilder = shadowList->createDrawLoop er(DrawLooperBuilder::ShadowRespectsAlpha);
340 RefPtr<SkDrawLooper> drawLooper = drawLooperBuilder->detachDrawLooper(); 340 RefPtr<SkDrawLooper> drawLooper = drawLooperBuilder->detachDrawLooper();
341 paint.setLooper(drawLooper.get()); 341 paint.setLooper(drawLooper.get());
342 } 342 }
343 343
344 if (resourceMode == ApplyToStrokeMode) { 344 if (resourceMode == ApplyToStrokeMode) {
345 StrokeData strokeData; 345 StrokeData strokeData;
346 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, style, m_svgI nlineTextBox.parent()->layoutObject()); 346 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, style, m_svgI nlineTextBox.parent()->layoutObject());
347 strokeData.setThickness(strokeData.thickness() * scalingFactor); 347 if (style.svgStyle().vectorEffect() != VE_NON_SCALING_STROKE)
348 strokeData.setThickness(strokeData.thickness() * scalingFactor);
348 strokeData.setupPaint(&paint); 349 strokeData.setupPaint(&paint);
349 } 350 }
350 351
351 TextRunPaintInfo textRunPaintInfo(textRun); 352 TextRunPaintInfo textRunPaintInfo(textRun);
352 textRunPaintInfo.from = startPosition; 353 textRunPaintInfo.from = startPosition;
353 textRunPaintInfo.to = endPosition; 354 textRunPaintInfo.to = endPosition;
354 355
355 float baseline = scaledFont.fontMetrics().floatAscent(); 356 float baseline = scaledFont.fontMetrics().floatAscent();
356 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baselin e, 357 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baselin e,
357 textSize.width(), textSize.height()); 358 textSize.width(), textSize.height());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if (!fragmentTransform.isIdentity()) 446 if (!fragmentTransform.isIdentity())
446 context->concatCTM(fragmentTransform); 447 context->concatCTM(fragmentTransform);
447 context->setFillColor(color); 448 context->setFillColor(color);
448 context->fillRect(fragmentRect, color); 449 context->fillRect(fragmentRect, color);
449 } 450 }
450 } 451 }
451 } 452 }
452 } 453 }
453 454
454 } // namespace blink 455 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698