Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 84a4294e2697b7ceb24dd1a81faf75eaa08f334c..778168d29717d34c00a5f5197eabe779f933296b 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -1014,7 +1014,7 @@ void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind |
c->setFillRule(newWindRule); |
if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
- fullCanvasCompositedFill(path); |
+ fullCanvasComposited(path, FillPathFunctor()); |
didDraw(clipBounds); |
} else if (state().m_globalComposite == CompositeCopy) { |
clearCanvas(); |
@@ -1070,12 +1070,21 @@ void CanvasRenderingContext2D::strokeInternal(const Path& path) |
return; |
} |
- FloatRect bounds = path.boundingRect(); |
- inflateStrokeRect(bounds); |
- FloatRect dirtyRect; |
- if (computeDirtyRect(bounds, &dirtyRect)) { |
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
+ fullCanvasComposited(path, StrokePathFunctor()); |
+ didDraw(path.boundingRect()); |
krit
2014/04/07 08:10:35
It think you should make the whole canvas for repa
|
+ } else if (state().m_globalComposite == CompositeCopy) { |
+ clearCanvas(); |
c->strokePath(path); |
- didDraw(dirtyRect); |
+ didDraw(path.boundingRect()); |
+ } else { |
+ FloatRect bounds = path.boundingRect(); |
+ inflateStrokeRect(bounds); |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(path.boundingRect(), &dirtyRect)) { |
+ c->strokePath(path); |
+ didDraw(dirtyRect); |
+ } |
} |
} |
@@ -1324,7 +1333,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei |
c->fillRect(rect); |
didDraw(clipBounds); |
} else if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
- fullCanvasCompositedFill(rect); |
+ fullCanvasComposited(rect, FillRectFunctor()); |
didDraw(clipBounds); |
} else if (state().m_globalComposite == CompositeCopy) { |
clearCanvas(); |
@@ -1360,12 +1369,21 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h |
FloatRect rect(x, y, width, height); |
- FloatRect boundingRect = rect; |
- boundingRect.inflate(state().m_lineWidth / 2); |
- FloatRect dirtyRect; |
- if (computeDirtyRect(boundingRect, &dirtyRect)) { |
- c->strokeRect(rect, state().m_lineWidth); |
- didDraw(dirtyRect); |
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
+ fullCanvasComposited(rect, StrokeRectFunctor()); |
+ didDraw(rect); |
krit
2014/04/07 08:10:35
Ditto.
|
+ } else if (state().m_globalComposite == CompositeCopy) { |
+ clearCanvas(); |
+ c->strokeRect(rect); |
+ didDraw(rect); |
+ } else { |
+ FloatRect boundingRect = rect; |
+ boundingRect.inflate(state().m_lineWidth / 2); |
+ FloatRect dirtyRect; |
+ if (computeDirtyRect(boundingRect, &dirtyRect)) { |
+ c->strokeRect(rect, state().m_lineWidth); |
+ didDraw(dirtyRect); |
+ } |
} |
} |
@@ -1654,17 +1672,7 @@ template<class T> void CanvasRenderingContext2D::fullCanvasCompositedDrawImage( |
drawingContext()->endLayer(); |
} |
-static void fillPrimitive(const FloatRect& rect, GraphicsContext* context) |
-{ |
- context->fillRect(rect); |
-} |
- |
-static void fillPrimitive(const Path& path, GraphicsContext* context) |
-{ |
- context->fillPath(path); |
-} |
- |
-template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const T& area) |
+template<class T, class Functor> void CanvasRenderingContext2D::fullCanvasComposited(const T& area, Functor functor) |
{ |
ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); |
@@ -1673,7 +1681,7 @@ template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const |
c->beginLayer(1, state().m_globalComposite); |
CompositeOperator previousOperator = c->compositeOperation(); |
c->setCompositeOperation(CompositeSourceOver); |
- fillPrimitive(area, c); |
+ functor(area, c); |
c->setCompositeOperation(previousOperator); |
c->endLayer(); |
} |