OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
10 * | 10 * |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 if (windingRuleString == "nonzero") | 863 if (windingRuleString == "nonzero") |
864 windRule = RULE_NONZERO; | 864 windRule = RULE_NONZERO; |
865 else if (windingRuleString == "evenodd") | 865 else if (windingRuleString == "evenodd") |
866 windRule = RULE_EVENODD; | 866 windRule = RULE_EVENODD; |
867 else | 867 else |
868 return false; | 868 return false; |
869 | 869 |
870 return true; | 870 return true; |
871 } | 871 } |
872 | 872 |
873 void CanvasRenderingContext2D::fill(const String& windingRuleString) | 873 void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind ingRuleString) |
874 { | 874 { |
875 if (path.isEmpty()) { | |
876 return; | |
877 } | |
875 GraphicsContext* c = drawingContext(); | 878 GraphicsContext* c = drawingContext(); |
876 if (!c) | 879 if (!c) |
877 return; | 880 return; |
878 if (!state().m_invertibleCTM) | 881 if (!state().m_invertibleCTM) |
879 return; | 882 return; |
880 FloatRect clipBounds; | 883 FloatRect clipBounds; |
881 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) | 884 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) |
882 return; | 885 return; |
883 | 886 |
884 // If gradient size is zero, then paint nothing. | 887 // If gradient size is zero, then paint nothing. |
885 Gradient* gradient = c->fillGradient(); | 888 Gradient* gradient = c->fillGradient(); |
886 if (gradient && gradient->isZeroSize()) | 889 if (gradient && gradient->isZeroSize()) |
887 return; | 890 return; |
888 | 891 |
889 if (!m_path.isEmpty()) { | 892 WindRule windRule = c->fillRule(); |
890 WindRule windRule = c->fillRule(); | 893 WindRule newWindRule = RULE_NONZERO; |
891 WindRule newWindRule = RULE_NONZERO; | 894 if (!parseWinding(windingRuleString, newWindRule)) |
892 if (!parseWinding(windingRuleString, newWindRule)) | 895 return; |
893 return; | 896 c->setFillRule(newWindRule); |
894 c->setFillRule(newWindRule); | |
895 | 897 |
896 if (isFullCanvasCompositeMode(state().m_globalComposite)) { | 898 if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
897 fullCanvasCompositedFill(m_path); | 899 fullCanvasCompositedFill(path); |
898 didDraw(clipBounds); | 900 didDraw(clipBounds); |
899 } else if (state().m_globalComposite == CompositeCopy) { | 901 } else if (state().m_globalComposite == CompositeCopy) { |
900 clearCanvas(); | 902 clearCanvas(); |
901 c->fillPath(m_path); | 903 c->fillPath(path); |
902 didDraw(clipBounds); | 904 didDraw(clipBounds); |
903 } else { | 905 } else { |
904 FloatRect dirtyRect; | 906 FloatRect dirtyRect; |
905 if (computeDirtyRect(m_path.boundingRect(), clipBounds, &dirtyRect)) { | 907 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) { |
906 c->fillPath(m_path); | 908 c->fillPath(path); |
907 didDraw(dirtyRect); | 909 didDraw(dirtyRect); |
908 } | |
909 } | 910 } |
911 } | |
910 | 912 |
911 c->setFillRule(windRule); | 913 c->setFillRule(windRule); |
912 } | |
913 } | 914 } |
914 | 915 |
915 void CanvasRenderingContext2D::stroke() | 916 void CanvasRenderingContext2D::fill(const String& windingRuleString) |
916 { | 917 { |
918 this->fillInternal(m_path, windingRuleString); | |
eseidel
2014/02/20 18:59:52
Why is this-> needed?
jcgregorio
2014/02/20 19:28:30
It's not, fixed. (I'm confusing blink style with s
| |
919 } | |
920 | |
921 void CanvasRenderingContext2D::fill(DOMPath* domPath, const String& windingRuleS tring) | |
922 { | |
923 this->fillInternal(domPath->path(), windingRuleString); | |
924 } | |
925 | |
926 void CanvasRenderingContext2D::strokeInternal(const Path& path) | |
927 { | |
928 if (path.isEmpty()) { | |
929 return; | |
eseidel
2014/02/20 18:59:52
This CL inconsistently uses { } around oneline ifs
jcgregorio
2014/02/20 19:28:30
Fixed all the functions I touched in this CL to us
| |
930 } | |
917 GraphicsContext* c = drawingContext(); | 931 GraphicsContext* c = drawingContext(); |
918 if (!c) | 932 if (!c) |
919 return; | 933 return; |
920 if (!state().m_invertibleCTM) | 934 if (!state().m_invertibleCTM) |
921 return; | 935 return; |
922 | 936 |
923 // If gradient size is zero, then paint nothing. | 937 // If gradient size is zero, then paint nothing. |
924 Gradient* gradient = c->strokeGradient(); | 938 Gradient* gradient = c->strokeGradient(); |
925 if (gradient && gradient->isZeroSize()) | 939 if (gradient && gradient->isZeroSize()) |
926 return; | 940 return; |
927 | 941 |
928 if (!m_path.isEmpty()) { | 942 FloatRect bounds = path.boundingRect(); |
929 FloatRect bounds = m_path.boundingRect(); | 943 inflateStrokeRect(bounds); |
930 inflateStrokeRect(bounds); | 944 FloatRect dirtyRect; |
931 FloatRect dirtyRect; | 945 if (computeDirtyRect(bounds, &dirtyRect)) { |
932 if (computeDirtyRect(bounds, &dirtyRect)) { | 946 c->strokePath(path); |
933 c->strokePath(m_path); | 947 didDraw(dirtyRect); |
934 didDraw(dirtyRect); | |
935 } | |
936 } | 948 } |
937 } | 949 } |
938 | 950 |
939 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 951 void CanvasRenderingContext2D::stroke() |
952 { | |
953 this->strokeInternal(m_path); | |
954 } | |
955 | |
956 void CanvasRenderingContext2D::stroke(DOMPath* domPath) | |
957 { | |
958 this->strokeInternal(domPath->path()); | |
959 } | |
960 | |
961 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind ingRuleString) | |
940 { | 962 { |
941 GraphicsContext* c = drawingContext(); | 963 GraphicsContext* c = drawingContext(); |
942 if (!c) | 964 if (!c) |
943 return; | 965 return; |
944 if (!state().m_invertibleCTM) | 966 if (!state().m_invertibleCTM) |
945 return; | 967 return; |
946 | 968 |
947 WindRule newWindRule = RULE_NONZERO; | 969 WindRule newWindRule = RULE_NONZERO; |
948 if (!parseWinding(windingRuleString, newWindRule)) | 970 if (!parseWinding(windingRuleString, newWindRule)) |
949 return; | 971 return; |
950 | 972 |
951 realizeSaves(); | 973 realizeSaves(); |
952 c->canvasClip(m_path, newWindRule); | 974 c->canvasClip(path, newWindRule); |
975 } | |
976 | |
977 void CanvasRenderingContext2D::clip(const String& windingRuleString) | |
978 { | |
979 this->clipInternal(m_path, windingRuleString); | |
980 } | |
981 | |
982 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS tring) | |
983 { | |
984 this->clipInternal(domPath->path(), windingRuleString); | |
953 } | 985 } |
954 | 986 |
955 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) | 987 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |
956 { | 988 { |
957 GraphicsContext* c = drawingContext(); | 989 GraphicsContext* c = drawingContext(); |
958 if (!c) | 990 if (!c) |
959 return false; | 991 return false; |
960 if (!state().m_invertibleCTM) | 992 if (!state().m_invertibleCTM) |
961 return false; | 993 return false; |
962 | 994 |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 const int focusRingWidth = 5; | 2424 const int focusRingWidth = 5; |
2393 const int focusRingOutline = 0; | 2425 const int focusRingOutline = 0; |
2394 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2426 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
2395 | 2427 |
2396 c->restore(); | 2428 c->restore(); |
2397 | 2429 |
2398 didDraw(dirtyRect); | 2430 didDraw(dirtyRect); |
2399 } | 2431 } |
2400 | 2432 |
2401 } // namespace WebCore | 2433 } // namespace WebCore |
OLD | NEW |