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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 if (windingRuleString == "nonzero") | 876 if (windingRuleString == "nonzero") |
877 windRule = RULE_NONZERO; | 877 windRule = RULE_NONZERO; |
878 else if (windingRuleString == "evenodd") | 878 else if (windingRuleString == "evenodd") |
879 windRule = RULE_EVENODD; | 879 windRule = RULE_EVENODD; |
880 else | 880 else |
881 return false; | 881 return false; |
882 | 882 |
883 return true; | 883 return true; |
884 } | 884 } |
885 | 885 |
886 void CanvasRenderingContext2D::fill(const String& windingRuleString) | 886 void CanvasRenderingContext2D::fillImpl(const Path& path, const String& windingR uleString) |
887 { | 887 { |
888 if (path.isEmpty()) { | |
889 return; | |
890 } | |
888 GraphicsContext* c = drawingContext(); | 891 GraphicsContext* c = drawingContext(); |
889 if (!c) | 892 if (!c) |
890 return; | 893 return; |
891 if (!state().m_invertibleCTM) | 894 if (!state().m_invertibleCTM) |
892 return; | 895 return; |
893 FloatRect clipBounds; | 896 FloatRect clipBounds; |
894 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) | 897 if (!drawingContext()->getTransformedClipBounds(&clipBounds)) |
895 return; | 898 return; |
896 | 899 |
897 // If gradient size is zero, then paint nothing. | 900 // If gradient size is zero, then paint nothing. |
898 Gradient* gradient = c->fillGradient(); | 901 Gradient* gradient = c->fillGradient(); |
899 if (gradient && gradient->isZeroSize()) | 902 if (gradient && gradient->isZeroSize()) |
900 return; | 903 return; |
901 | 904 |
902 if (!m_path.isEmpty()) { | 905 WindRule windRule = c->fillRule(); |
903 WindRule windRule = c->fillRule(); | 906 WindRule newWindRule = RULE_NONZERO; |
904 WindRule newWindRule = RULE_NONZERO; | 907 if (!parseWinding(windingRuleString, newWindRule)) |
905 if (!parseWinding(windingRuleString, newWindRule)) | 908 return; |
906 return; | 909 c->setFillRule(newWindRule); |
907 c->setFillRule(newWindRule); | |
908 | 910 |
909 if (isFullCanvasCompositeMode(state().m_globalComposite)) { | 911 if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
910 fullCanvasCompositedFill(m_path); | 912 fullCanvasCompositedFill(path); |
911 didDraw(clipBounds); | 913 didDraw(clipBounds); |
912 } else if (state().m_globalComposite == CompositeCopy) { | 914 } else if (state().m_globalComposite == CompositeCopy) { |
913 clearCanvas(); | 915 clearCanvas(); |
914 c->fillPath(m_path); | 916 c->fillPath(path); |
915 didDraw(clipBounds); | 917 didDraw(clipBounds); |
916 } else { | 918 } else { |
917 FloatRect dirtyRect; | 919 FloatRect dirtyRect; |
918 if (computeDirtyRect(m_path.boundingRect(), clipBounds, &dirtyRect)) { | 920 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) { |
919 c->fillPath(m_path); | 921 c->fillPath(path); |
920 didDraw(dirtyRect); | 922 didDraw(dirtyRect); |
921 } | |
922 } | 923 } |
924 } | |
923 | 925 |
924 c->setFillRule(windRule); | 926 c->setFillRule(windRule); |
925 } | |
926 } | 927 } |
927 | 928 |
928 void CanvasRenderingContext2D::stroke() | 929 void CanvasRenderingContext2D::fill(const String& windingRuleString) |
929 { | 930 { |
931 this->fillImpl(m_path, windingRuleString); | |
932 } | |
933 | |
934 void CanvasRenderingContext2D::fill(DOMPath* domPath, const String& windingRuleS tring) | |
935 { | |
936 if (!domPath) | |
937 return; | |
938 this->fillImpl(domPath->path(), windingRuleString); | |
939 } | |
940 | |
941 void CanvasRenderingContext2D::strokeImpl(const Path& path) | |
942 { | |
943 if (path.isEmpty()) { | |
944 return; | |
945 } | |
930 GraphicsContext* c = drawingContext(); | 946 GraphicsContext* c = drawingContext(); |
931 if (!c) | 947 if (!c) |
932 return; | 948 return; |
933 if (!state().m_invertibleCTM) | 949 if (!state().m_invertibleCTM) |
934 return; | 950 return; |
935 | 951 |
936 // If gradient size is zero, then paint nothing. | 952 // If gradient size is zero, then paint nothing. |
937 Gradient* gradient = c->strokeGradient(); | 953 Gradient* gradient = c->strokeGradient(); |
938 if (gradient && gradient->isZeroSize()) | 954 if (gradient && gradient->isZeroSize()) |
939 return; | 955 return; |
940 | 956 |
941 if (!m_path.isEmpty()) { | 957 FloatRect bounds = path.boundingRect(); |
942 FloatRect bounds = m_path.boundingRect(); | 958 inflateStrokeRect(bounds); |
943 inflateStrokeRect(bounds); | 959 FloatRect dirtyRect; |
944 FloatRect dirtyRect; | 960 if (computeDirtyRect(bounds, &dirtyRect)) { |
945 if (computeDirtyRect(bounds, &dirtyRect)) { | 961 c->strokePath(path); |
946 c->strokePath(m_path); | 962 didDraw(dirtyRect); |
947 didDraw(dirtyRect); | |
948 } | |
949 } | 963 } |
950 } | 964 } |
951 | 965 |
952 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 966 void CanvasRenderingContext2D::stroke() |
967 { | |
968 this->strokeImpl(m_path); | |
969 } | |
970 | |
971 void CanvasRenderingContext2D::stroke(DOMPath* domPath) | |
972 { | |
973 if (!domPath) | |
974 return; | |
975 this->strokeImpl(domPath->path()); | |
976 } | |
977 | |
978 void CanvasRenderingContext2D::clipImpl(const Path& path, const String& windingR uleString) | |
953 { | 979 { |
954 GraphicsContext* c = drawingContext(); | 980 GraphicsContext* c = drawingContext(); |
955 if (!c) | 981 if (!c) |
956 return; | 982 return; |
957 if (!state().m_invertibleCTM) | 983 if (!state().m_invertibleCTM) |
958 return; | 984 return; |
959 | 985 |
960 WindRule newWindRule = RULE_NONZERO; | 986 WindRule newWindRule = RULE_NONZERO; |
961 if (!parseWinding(windingRuleString, newWindRule)) | 987 if (!parseWinding(windingRuleString, newWindRule)) |
962 return; | 988 return; |
963 | 989 |
964 realizeSaves(); | 990 realizeSaves(); |
965 c->canvasClip(m_path, newWindRule); | 991 c->canvasClip(path, newWindRule); |
992 } | |
993 | |
994 void CanvasRenderingContext2D::clip(const String& windingRuleString) | |
995 { | |
996 this->clipImpl(m_path, windingRuleString); | |
997 } | |
998 | |
999 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS tring) | |
1000 { | |
1001 if (!domPath) | |
1002 return; | |
dshwang
2014/01/23 21:17:17
Could v8 binder fire dom exception if domPath is n
jcgregorio
2014/01/29 17:51:49
Updated IDL to match the spec, Path is no longer o
dshwang
2014/01/31 12:29:00
I mean this 'if statement' is not necessary becaus
jcgregorio
2014/01/31 18:08:49
Done.
| |
1003 this->clipImpl(domPath->path(), windingRuleString); | |
966 } | 1004 } |
967 | 1005 |
968 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) | 1006 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |
969 { | 1007 { |
970 GraphicsContext* c = drawingContext(); | 1008 GraphicsContext* c = drawingContext(); |
971 if (!c) | 1009 if (!c) |
972 return false; | 1010 return false; |
973 if (!state().m_invertibleCTM) | 1011 if (!state().m_invertibleCTM) |
974 return false; | 1012 return false; |
975 | 1013 |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2427 const int focusRingWidth = 5; | 2465 const int focusRingWidth = 5; |
2428 const int focusRingOutline = 0; | 2466 const int focusRingOutline = 0; |
2429 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2467 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
2430 | 2468 |
2431 c->restore(); | 2469 c->restore(); |
2432 | 2470 |
2433 didDraw(dirtyRect); | 2471 didDraw(dirtyRect); |
2434 } | 2472 } |
2435 | 2473 |
2436 } // namespace WebCore | 2474 } // namespace WebCore |
OLD | NEW |