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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 PaintFlags flags(ImmutableState()->FillFlags()); | 732 PaintFlags flags(ImmutableState()->FillFlags()); |
733 flags.setColor(StrokeColor().Rgb()); | 733 flags.setColor(StrokeColor().Rgb()); |
734 flags.setStyle(PaintFlags::kStroke_Style); | 734 flags.setStyle(PaintFlags::kStroke_Style); |
735 flags.setStrokeWidth(1); | 735 flags.setStrokeWidth(1); |
736 | 736 |
737 sk_rect.inset(0.5f, 0.5f); | 737 sk_rect.inset(0.5f, 0.5f); |
738 DrawRect(sk_rect, flags); | 738 DrawRect(sk_rect, flags); |
739 } | 739 } |
740 } | 740 } |
741 | 741 |
742 void GraphicsContext::DrawText(const Font& font, | 742 template <typename TextPaintInfo> |
743 const TextRunPaintInfo& run_info, | 743 void GraphicsContext::DrawTextInternal(const Font& font, |
744 const FloatPoint& point, | 744 const TextPaintInfo& text_info, |
745 const PaintFlags& flags) { | 745 const FloatPoint& point, |
| 746 const PaintFlags& flags) { |
746 if (ContextDisabled()) | 747 if (ContextDisabled()) |
747 return; | 748 return; |
748 | 749 |
749 if (font.DrawText(canvas_, run_info, point, device_scale_factor_, flags)) | 750 if (font.DrawText(canvas_, text_info, point, device_scale_factor_, flags)) |
750 paint_controller_.SetTextPainted(); | 751 paint_controller_.SetTextPainted(); |
751 } | 752 } |
752 | 753 |
| 754 void GraphicsContext::DrawText(const Font& font, |
| 755 const TextRunPaintInfo& text_info, |
| 756 const FloatPoint& point, |
| 757 const PaintFlags& flags) { |
| 758 DrawTextInternal(font, text_info, point, flags); |
| 759 } |
| 760 |
| 761 void GraphicsContext::DrawText(const Font& font, |
| 762 const TextFragmentPaintInfo& text_info, |
| 763 const FloatPoint& point, |
| 764 const PaintFlags& flags) { |
| 765 DrawTextInternal(font, text_info, point, flags); |
| 766 } |
| 767 |
753 template <typename DrawTextFunc> | 768 template <typename DrawTextFunc> |
754 void GraphicsContext::DrawTextPasses(const DrawTextFunc& draw_text) { | 769 void GraphicsContext::DrawTextPasses(const DrawTextFunc& draw_text) { |
755 TextDrawingModeFlags mode_flags = TextDrawingMode(); | 770 TextDrawingModeFlags mode_flags = TextDrawingMode(); |
756 | 771 |
757 if (mode_flags & kTextModeFill) { | 772 if (mode_flags & kTextModeFill) { |
758 draw_text(ImmutableState()->FillFlags()); | 773 draw_text(ImmutableState()->FillFlags()); |
759 } | 774 } |
760 | 775 |
761 if ((mode_flags & kTextModeStroke) && GetStrokeStyle() != kNoStroke && | 776 if ((mode_flags & kTextModeStroke) && GetStrokeStyle() != kNoStroke && |
762 StrokeThickness() > 0) { | 777 StrokeThickness() > 0) { |
763 PaintFlags stroke_flags(ImmutableState()->StrokeFlags()); | 778 PaintFlags stroke_flags(ImmutableState()->StrokeFlags()); |
764 if (mode_flags & kTextModeFill) { | 779 if (mode_flags & kTextModeFill) { |
765 // shadow was already applied during fill pass | 780 // shadow was already applied during fill pass |
766 stroke_flags.setLooper(0); | 781 stroke_flags.setLooper(0); |
767 } | 782 } |
768 draw_text(stroke_flags); | 783 draw_text(stroke_flags); |
769 } | 784 } |
770 } | 785 } |
771 | 786 |
772 void GraphicsContext::DrawText(const Font& font, | 787 template <typename TextPaintInfo> |
773 const TextRunPaintInfo& run_info, | 788 void GraphicsContext::DrawTextInternal(const Font& font, |
774 const FloatPoint& point) { | 789 const TextPaintInfo& text_info, |
| 790 const FloatPoint& point) { |
775 if (ContextDisabled()) | 791 if (ContextDisabled()) |
776 return; | 792 return; |
777 | 793 |
778 DrawTextPasses([&font, &run_info, &point, this](const PaintFlags& flags) { | 794 DrawTextPasses([&font, &text_info, &point, this](const PaintFlags& flags) { |
779 if (font.DrawText(canvas_, run_info, point, device_scale_factor_, flags)) | 795 if (font.DrawText(canvas_, text_info, point, device_scale_factor_, flags)) |
780 paint_controller_.SetTextPainted(); | 796 paint_controller_.SetTextPainted(); |
781 }); | 797 }); |
782 } | 798 } |
783 | 799 |
784 void GraphicsContext::DrawEmphasisMarks(const Font& font, | 800 void GraphicsContext::DrawText(const Font& font, |
785 const TextRunPaintInfo& run_info, | 801 const TextRunPaintInfo& text_info, |
786 const AtomicString& mark, | 802 const FloatPoint& point) { |
787 const FloatPoint& point) { | 803 DrawTextInternal(font, text_info, point); |
| 804 } |
| 805 |
| 806 void GraphicsContext::DrawText(const Font& font, |
| 807 const TextFragmentPaintInfo& text_info, |
| 808 const FloatPoint& point) { |
| 809 DrawTextInternal(font, text_info, point); |
| 810 } |
| 811 |
| 812 template <typename TextPaintInfo> |
| 813 void GraphicsContext::DrawEmphasisMarksInternal(const Font& font, |
| 814 const TextPaintInfo& text_info, |
| 815 const AtomicString& mark, |
| 816 const FloatPoint& point) { |
788 if (ContextDisabled()) | 817 if (ContextDisabled()) |
789 return; | 818 return; |
790 | 819 |
791 DrawTextPasses( | 820 DrawTextPasses( |
792 [&font, &run_info, &mark, &point, this](const PaintFlags& flags) { | 821 [&font, &text_info, &mark, &point, this](const PaintFlags& flags) { |
793 font.DrawEmphasisMarks(canvas_, run_info, mark, point, | 822 font.DrawEmphasisMarks(canvas_, text_info, mark, point, |
794 device_scale_factor_, flags); | 823 device_scale_factor_, flags); |
795 }); | 824 }); |
796 } | 825 } |
797 | 826 |
| 827 void GraphicsContext::DrawEmphasisMarks(const Font& font, |
| 828 const TextRunPaintInfo& text_info, |
| 829 const AtomicString& mark, |
| 830 const FloatPoint& point) { |
| 831 DrawEmphasisMarksInternal(font, text_info, mark, point); |
| 832 } |
| 833 |
| 834 void GraphicsContext::DrawEmphasisMarks(const Font& font, |
| 835 const TextFragmentPaintInfo& text_info, |
| 836 const AtomicString& mark, |
| 837 const FloatPoint& point) { |
| 838 DrawEmphasisMarksInternal(font, text_info, mark, point); |
| 839 } |
| 840 |
798 void GraphicsContext::DrawBidiText( | 841 void GraphicsContext::DrawBidiText( |
799 const Font& font, | 842 const Font& font, |
800 const TextRunPaintInfo& run_info, | 843 const TextRunPaintInfo& run_info, |
801 const FloatPoint& point, | 844 const FloatPoint& point, |
802 Font::CustomFontNotReadyAction custom_font_not_ready_action) { | 845 Font::CustomFontNotReadyAction custom_font_not_ready_action) { |
803 if (ContextDisabled()) | 846 if (ContextDisabled()) |
804 return; | 847 return; |
805 | 848 |
806 DrawTextPasses([&font, &run_info, &point, custom_font_not_ready_action, | 849 DrawTextPasses([&font, &run_info, &point, custom_font_not_ready_action, |
807 this](const PaintFlags& flags) { | 850 this](const PaintFlags& flags) { |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 break; | 1404 break; |
1362 default: | 1405 default: |
1363 NOTREACHED(); | 1406 NOTREACHED(); |
1364 break; | 1407 break; |
1365 } | 1408 } |
1366 | 1409 |
1367 return nullptr; | 1410 return nullptr; |
1368 } | 1411 } |
1369 | 1412 |
1370 } // namespace blink | 1413 } // namespace blink |
OLD | NEW |