| 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 this->fillImpl(domPath->path(), windingRuleString); |
| 937 } |
| 938 |
| 939 void CanvasRenderingContext2D::strokeImpl(const Path& path) |
| 940 { |
| 941 if (path.isEmpty()) { |
| 942 return; |
| 943 } |
| 930 GraphicsContext* c = drawingContext(); | 944 GraphicsContext* c = drawingContext(); |
| 931 if (!c) | 945 if (!c) |
| 932 return; | 946 return; |
| 933 if (!state().m_invertibleCTM) | 947 if (!state().m_invertibleCTM) |
| 934 return; | 948 return; |
| 935 | 949 |
| 936 // If gradient size is zero, then paint nothing. | 950 // If gradient size is zero, then paint nothing. |
| 937 Gradient* gradient = c->strokeGradient(); | 951 Gradient* gradient = c->strokeGradient(); |
| 938 if (gradient && gradient->isZeroSize()) | 952 if (gradient && gradient->isZeroSize()) |
| 939 return; | 953 return; |
| 940 | 954 |
| 941 if (!m_path.isEmpty()) { | 955 FloatRect bounds = path.boundingRect(); |
| 942 FloatRect bounds = m_path.boundingRect(); | 956 inflateStrokeRect(bounds); |
| 943 inflateStrokeRect(bounds); | 957 FloatRect dirtyRect; |
| 944 FloatRect dirtyRect; | 958 if (computeDirtyRect(bounds, &dirtyRect)) { |
| 945 if (computeDirtyRect(bounds, &dirtyRect)) { | 959 c->strokePath(path); |
| 946 c->strokePath(m_path); | 960 didDraw(dirtyRect); |
| 947 didDraw(dirtyRect); | |
| 948 } | |
| 949 } | 961 } |
| 950 } | 962 } |
| 951 | 963 |
| 952 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 964 void CanvasRenderingContext2D::stroke() |
| 965 { |
| 966 this->strokeImpl(m_path); |
| 967 } |
| 968 |
| 969 void CanvasRenderingContext2D::stroke(DOMPath* domPath) |
| 970 { |
| 971 this->strokeImpl(domPath->path()); |
| 972 } |
| 973 |
| 974 void CanvasRenderingContext2D::clipImpl(const Path& path, const String& windingR
uleString) |
| 953 { | 975 { |
| 954 GraphicsContext* c = drawingContext(); | 976 GraphicsContext* c = drawingContext(); |
| 955 if (!c) | 977 if (!c) |
| 956 return; | 978 return; |
| 957 if (!state().m_invertibleCTM) | 979 if (!state().m_invertibleCTM) |
| 958 return; | 980 return; |
| 959 | 981 |
| 960 WindRule newWindRule = RULE_NONZERO; | 982 WindRule newWindRule = RULE_NONZERO; |
| 961 if (!parseWinding(windingRuleString, newWindRule)) | 983 if (!parseWinding(windingRuleString, newWindRule)) |
| 962 return; | 984 return; |
| 963 | 985 |
| 964 realizeSaves(); | 986 realizeSaves(); |
| 965 c->canvasClip(m_path, newWindRule); | 987 c->canvasClip(path, newWindRule); |
| 988 } |
| 989 |
| 990 void CanvasRenderingContext2D::clip(const String& windingRuleString) |
| 991 { |
| 992 this->clipImpl(m_path, windingRuleString); |
| 993 } |
| 994 |
| 995 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS
tring) |
| 996 { |
| 997 this->clipImpl(domPath->path(), windingRuleString); |
| 966 } | 998 } |
| 967 | 999 |
| 968 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const
String& windingRuleString) | 1000 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const
String& windingRuleString) |
| 969 { | 1001 { |
| 970 GraphicsContext* c = drawingContext(); | 1002 GraphicsContext* c = drawingContext(); |
| 971 if (!c) | 1003 if (!c) |
| 972 return false; | 1004 return false; |
| 973 if (!state().m_invertibleCTM) | 1005 if (!state().m_invertibleCTM) |
| 974 return false; | 1006 return false; |
| 975 | 1007 |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2427 const int focusRingWidth = 5; | 2459 const int focusRingWidth = 5; |
| 2428 const int focusRingOutline = 0; | 2460 const int focusRingOutline = 0; |
| 2429 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2461 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2430 | 2462 |
| 2431 c->restore(); | 2463 c->restore(); |
| 2432 | 2464 |
| 2433 didDraw(dirtyRect); | 2465 didDraw(dirtyRect); |
| 2434 } | 2466 } |
| 2435 | 2467 |
| 2436 } // namespace WebCore | 2468 } // namespace WebCore |
| OLD | NEW |