OLD | NEW |
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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 | 760 |
761 DrawLooper drawLooper; | 761 DrawLooper drawLooper; |
762 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, | 762 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, |
763 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); | 763 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); |
764 setDrawLooper(drawLooper); | 764 setDrawLooper(drawLooper); |
765 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 765 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
766 restore(); | 766 restore(); |
767 clearDrawLooper(); | 767 clearDrawLooper(); |
768 } | 768 } |
769 | 769 |
770 // This is only used to draw borders. | |
771 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 770 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
772 { | 771 { |
773 if (paintingDisabled()) | 772 if (paintingDisabled()) |
774 return; | 773 return; |
775 | 774 |
776 StrokeStyle penStyle = strokeStyle(); | 775 StrokeStyle penStyle = strokeStyle(); |
777 if (penStyle == NoStroke) | 776 if (penStyle == NoStroke) |
778 return; | 777 return; |
779 | 778 |
780 SkPaint paint; | 779 SkPaint paint; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 } | 947 } |
949 | 948 |
950 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool pr
inting) | 949 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool pr
inting) |
951 { | 950 { |
952 if (paintingDisabled()) | 951 if (paintingDisabled()) |
953 return; | 952 return; |
954 | 953 |
955 if (width <= 0) | 954 if (width <= 0) |
956 return; | 955 return; |
957 | 956 |
958 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1); | |
959 SkRect r; | |
960 r.fLeft = WebCoreFloatToSkScalar(pt.x()); | |
961 // Avoid anti-aliasing lines. Currently, these are always horizontal. | |
962 // Round to nearest pixel to match text and other content. | |
963 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f)); | |
964 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width); | |
965 r.fBottom = r.fTop + SkIntToScalar(thickness); | |
966 | |
967 SkPaint paint; | 957 SkPaint paint; |
968 switch (strokeStyle()) { | 958 switch (strokeStyle()) { |
969 case NoStroke: | 959 case NoStroke: |
970 case SolidStroke: | 960 case SolidStroke: |
971 case DoubleStroke: | 961 case DoubleStroke: |
972 case WavyStroke: | 962 case WavyStroke: { |
| 963 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1); |
| 964 SkRect r; |
| 965 r.fLeft = WebCoreFloatToSkScalar(pt.x()); |
| 966 // Avoid anti-aliasing lines. Currently, these are always horizontal. |
| 967 // Round to nearest pixel to match text and other content. |
| 968 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f)); |
| 969 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width); |
| 970 r.fBottom = r.fTop + SkIntToScalar(thickness); |
973 setupPaintForFilling(&paint); | 971 setupPaintForFilling(&paint); |
974 break; | 972 // Text lines are drawn using the stroke color. |
| 973 paint.setColor(effectiveStrokeColor()); |
| 974 drawRect(r, paint); |
| 975 return; |
| 976 } |
975 case DottedStroke: | 977 case DottedStroke: |
976 case DashedStroke: | 978 case DashedStroke: { |
977 setupPaintForStroking(&paint); | 979 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f))
; |
978 break; | 980 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y)); |
| 981 return; |
| 982 } |
979 } | 983 } |
980 | 984 |
981 // Text lines are drawn using the stroke color. | 985 ASSERT_NOT_REACHED(); |
982 paint.setColor(effectiveStrokeColor()); | |
983 drawRect(r, paint); | |
984 } | 986 } |
985 | 987 |
986 // Draws a filled rectangle with a stroked border. | 988 // Draws a filled rectangle with a stroked border. |
987 void GraphicsContext::drawRect(const IntRect& rect) | 989 void GraphicsContext::drawRect(const IntRect& rect) |
988 { | 990 { |
989 if (paintingDisabled()) | 991 if (paintingDisabled()) |
990 return; | 992 return; |
991 | 993 |
992 ASSERT(!rect.isEmpty()); | 994 ASSERT(!rect.isEmpty()); |
993 if (rect.isEmpty()) | 995 if (rect.isEmpty()) |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 | 2017 |
2016 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 2018 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
2017 { | 2019 { |
2018 if (m_trackTextRegion) { | 2020 if (m_trackTextRegion) { |
2019 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 2021 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
2020 m_textRegion.join(textRect); | 2022 m_textRegion.join(textRect); |
2021 } | 2023 } |
2022 } | 2024 } |
2023 | 2025 |
2024 } | 2026 } |
OLD | NEW |