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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp

Issue 2416993002: Introduce support for text-decoration-skip: ink (Closed)
Patch Set: Created 4 years, 2 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 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 28 matching lines...) Expand all
39 #include "skia/ext/platform_canvas.h" 39 #include "skia/ext/platform_canvas.h"
40 #include "third_party/skia/include/core/SkAnnotation.h" 40 #include "third_party/skia/include/core/SkAnnotation.h"
41 #include "third_party/skia/include/core/SkColorFilter.h" 41 #include "third_party/skia/include/core/SkColorFilter.h"
42 #include "third_party/skia/include/core/SkData.h" 42 #include "third_party/skia/include/core/SkData.h"
43 #include "third_party/skia/include/core/SkPicture.h" 43 #include "third_party/skia/include/core/SkPicture.h"
44 #include "third_party/skia/include/core/SkPictureRecorder.h" 44 #include "third_party/skia/include/core/SkPictureRecorder.h"
45 #include "third_party/skia/include/core/SkRRect.h" 45 #include "third_party/skia/include/core/SkRRect.h"
46 #include "third_party/skia/include/core/SkRefCnt.h" 46 #include "third_party/skia/include/core/SkRefCnt.h"
47 #include "third_party/skia/include/effects/SkLumaColorFilter.h" 47 #include "third_party/skia/include/effects/SkLumaColorFilter.h"
48 #include "third_party/skia/include/effects/SkPictureImageFilter.h" 48 #include "third_party/skia/include/effects/SkPictureImageFilter.h"
49 #include "third_party/skia/include/pathops/SkPathOps.h"
49 #include "third_party/skia/include/utils/SkNullCanvas.h" 50 #include "third_party/skia/include/utils/SkNullCanvas.h"
50 #include "wtf/Assertions.h" 51 #include "wtf/Assertions.h"
51 #include "wtf/MathExtras.h" 52 #include "wtf/MathExtras.h"
52 #include <memory> 53 #include <memory>
53 54
54 namespace blink { 55 namespace blink {
55 56
56 GraphicsContext::GraphicsContext(PaintController& paintController, 57 GraphicsContext::GraphicsContext(PaintController& paintController,
57 DisabledMode disableContextOrPainting, 58 DisabledMode disableContextOrPainting,
58 SkMetaData* metaData) 59 SkMetaData* metaData)
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 638
638 if (deviceScaleFactor == 2) { 639 if (deviceScaleFactor == 2) {
639 save(); 640 save();
640 scale(0.5, 0.5); 641 scale(0.5, 0.5);
641 } 642 }
642 drawRect(rect, paint); 643 drawRect(rect, paint);
643 if (deviceScaleFactor == 2) 644 if (deviceScaleFactor == 2)
644 restore(); 645 restore();
645 } 646 }
646 647
647 void GraphicsContext::drawLineForText(const FloatPoint& pt, 648 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width) {
648 float width,
649 bool printing) {
650 if (contextDisabled()) 649 if (contextDisabled())
651 return; 650 return;
652 651
653 if (width <= 0) 652 if (width <= 0)
654 return; 653 return;
655 654
656 SkPaint paint; 655 SkPaint paint;
657 switch (getStrokeStyle()) { 656 switch (getStrokeStyle()) {
658 case NoStroke: 657 case NoStroke:
659 case SolidStroke: 658 case SolidStroke:
660 case DoubleStroke: 659 case DoubleStroke: {
661 case WavyStroke: {
662 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1); 660 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
663 SkRect r; 661 SkRect r;
664 r.fLeft = WebCoreFloatToSkScalar(pt.x()); 662 r.fLeft = WebCoreFloatToSkScalar(pt.x());
665 // Avoid anti-aliasing lines. Currently, these are always horizontal. 663 // Avoid anti-aliasing lines. Currently, these are always horizontal.
666 // Round to nearest pixel to match text and other content. 664 // Round to nearest pixel to match text and other content.
667 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f)); 665 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
668 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width); 666 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
669 r.fBottom = r.fTop + SkIntToScalar(thickness); 667 r.fBottom = r.fTop + SkIntToScalar(thickness);
670 paint = immutableState()->fillPaint(); 668 paint = immutableState()->fillPaint();
671 // Text lines are drawn using the stroke color. 669 // Text lines are drawn using the stroke color.
672 paint.setColor(strokeColor().rgb()); 670 paint.setColor(strokeColor().rgb());
673 drawRect(r, paint); 671 drawRect(r, paint);
674 return; 672 return;
675 } 673 }
676 case DottedStroke: 674 case DottedStroke:
677 case DashedStroke: { 675 case DashedStroke: {
678 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f)); 676 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f));
679 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y)); 677 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y));
680 return; 678 return;
681 } 679 }
680 case WavyStroke:
681 default:
682 break;
682 } 683 }
683 684
684 ASSERT_NOT_REACHED(); 685 ASSERT_NOT_REACHED();
685 } 686 }
686 687
687 // Draws a filled rectangle with a stroked border. 688 // Draws a filled rectangle with a stroked border.
688 void GraphicsContext::drawRect(const IntRect& rect) { 689 void GraphicsContext::drawRect(const IntRect& rect) {
689 if (contextDisabled()) 690 if (contextDisabled())
690 return; 691 return;
691 692
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 static const SkPMColor colors[] = { 1423 static const SkPMColor colors[] = {
1423 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red 1424 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red
1424 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray 1425 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray
1425 }; 1426 };
1426 1427
1427 return colors[index]; 1428 return colors[index];
1428 } 1429 }
1429 #endif 1430 #endif
1430 1431
1431 } // namespace blink 1432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698