Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 238793002: globalCompositeOperation is ignored in strokeText, fillText. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/canvas/canvas-composite-text-alpha-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 3529068fc8eb02e2a53845a328a82edda2395576..3e9dad6726eebad4c132854490418c8d340597bc 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -2225,21 +2225,40 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
if (!fill)
inflateStrokeRect(textRunPaintInfo.bounds);
- FloatRect dirtyRect;
- if (!computeDirtyRect(textRunPaintInfo.bounds, &dirtyRect))
- return;
-
c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke);
+
+ GraphicsContextStateSaver stateSaver(*c);
if (useMaxWidth) {
- GraphicsContextStateSaver stateSaver(*c);
c->translate(location.x(), location.y());
// We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) still work.
c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1));
- c->drawBidiText(font, textRunPaintInfo, FloatPoint(0, 0), Font::UseFallbackIfFontNotReady);
- } else
- c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFontNotReady);
+ location = FloatPoint();
+ }
- didDraw(dirtyRect);
+ FloatRect clipBounds;
+ if (!c->getTransformedClipBounds(&clipBounds)) {
+ return;
+ }
+
+ if (isFullCanvasCompositeMode(state().m_globalComposite)) {
+ c->beginLayer(1, state().m_globalComposite);
+ CompositeOperator previousOperator = c->compositeOperation();
+ c->setCompositeOperation(CompositeSourceOver);
+ c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFontNotReady);
+ c->setCompositeOperation(previousOperator);
+ c->endLayer();
+ didDraw(clipBounds);
+ } else if (state().m_globalComposite == CompositeCopy) {
+ clearCanvas();
+ c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFontNotReady);
+ didDraw(clipBounds);
+ } else {
+ FloatRect dirtyRect;
+ if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) {
+ c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFontNotReady);
+ didDraw(dirtyRect);
+ }
+ }
}
void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const
« no previous file with comments | « LayoutTests/fast/canvas/canvas-composite-text-alpha-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698