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

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

Issue 2416993002: Introduce support for text-decoration-skip: ink (Closed)
Patch Set: Falling back to adding rebaseline expectation 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 /* 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 633
633 if (deviceScaleFactor == 2) { 634 if (deviceScaleFactor == 2) {
634 save(); 635 save();
635 scale(0.5, 0.5); 636 scale(0.5, 0.5);
636 } 637 }
637 drawRect(rect, paint); 638 drawRect(rect, paint);
638 if (deviceScaleFactor == 2) 639 if (deviceScaleFactor == 2)
639 restore(); 640 restore();
640 } 641 }
641 642
642 void GraphicsContext::drawLineForText(const FloatPoint& pt, 643 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width) {
643 float width,
644 bool printing) {
645 if (contextDisabled()) 644 if (contextDisabled())
646 return; 645 return;
647 646
648 if (width <= 0) 647 if (width <= 0)
649 return; 648 return;
650 649
651 SkPaint paint; 650 SkPaint paint;
652 switch (getStrokeStyle()) { 651 switch (getStrokeStyle()) {
653 case NoStroke: 652 case NoStroke:
654 case SolidStroke: 653 case SolidStroke:
655 case DoubleStroke: 654 case DoubleStroke: {
656 case WavyStroke: {
657 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1); 655 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
658 SkRect r; 656 SkRect r;
659 r.fLeft = WebCoreFloatToSkScalar(pt.x()); 657 r.fLeft = WebCoreFloatToSkScalar(pt.x());
660 // Avoid anti-aliasing lines. Currently, these are always horizontal. 658 // Avoid anti-aliasing lines. Currently, these are always horizontal.
661 // Round to nearest pixel to match text and other content. 659 // Round to nearest pixel to match text and other content.
662 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f)); 660 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
663 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width); 661 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
664 r.fBottom = r.fTop + SkIntToScalar(thickness); 662 r.fBottom = r.fTop + SkIntToScalar(thickness);
665 paint = immutableState()->fillPaint(); 663 paint = immutableState()->fillPaint();
666 // Text lines are drawn using the stroke color. 664 // Text lines are drawn using the stroke color.
667 paint.setColor(strokeColor().rgb()); 665 paint.setColor(strokeColor().rgb());
668 drawRect(r, paint); 666 drawRect(r, paint);
669 return; 667 return;
670 } 668 }
671 case DottedStroke: 669 case DottedStroke:
672 case DashedStroke: { 670 case DashedStroke: {
673 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f)); 671 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f));
674 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y)); 672 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y));
675 return; 673 return;
676 } 674 }
675 case WavyStroke:
676 default:
677 break;
677 } 678 }
678 679
679 ASSERT_NOT_REACHED(); 680 ASSERT_NOT_REACHED();
680 } 681 }
681 682
682 // Draws a filled rectangle with a stroked border. 683 // Draws a filled rectangle with a stroked border.
683 void GraphicsContext::drawRect(const IntRect& rect) { 684 void GraphicsContext::drawRect(const IntRect& rect) {
684 if (contextDisabled()) 685 if (contextDisabled())
685 return; 686 return;
686 687
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 static const SkPMColor colors[] = { 1408 static const SkPMColor colors[] = {
1408 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red 1409 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red
1409 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray 1410 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray
1410 }; 1411 };
1411 1412
1412 return colors[index]; 1413 return colors[index];
1413 } 1414 }
1414 #endif 1415 #endif
1415 1416
1416 } // namespace blink 1417 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698