Changeset 166836 in webkit


Ignore:
Timestamp:
Apr 5, 2014 12:57:00 PM (10 years ago)
Author:
krit@webkit.org
Message:

Canvas stroke and strokeRect with SourceIn, DestinationIn, SourceOut, DestinationAtop and Copy have errors
https://bugs.webkit.org/show_bug.cgi?id=66762

Reviewed by Andreas Kling.

Source/WebCore:

For fill operations we create a new ImageBuffer to ensure that the results are composited
correctly according to the Canvas spec. This patch creates a new transparency layer
for stroking on certain compositing operators to archive the same. This makes WebKit's
behavior interoperable with Firefox and IE as well.

Test: fast/fast/canvas/canvas-composite-stroke-alpha.html

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::strokeInternal):
(WebCore::CanvasRenderingContext2D::strokeRect):

LayoutTests:

330 tests based on canvas-composite-alpha to test correct compositing behavior with
strokeRect() and stroke().

  • fast/canvas/canvas-composite-stroke-alpha-expected.txt: Added.
  • fast/canvas/canvas-composite-stroke-alpha.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166833 r166836  
     12014-04-05  Dirk Schulze  <krit@webkit.org>
     2
     3        Canvas stroke and strokeRect with SourceIn, DestinationIn, SourceOut, DestinationAtop and Copy have errors
     4        https://bugs.webkit.org/show_bug.cgi?id=66762
     5
     6        Reviewed by Andreas Kling.
     7
     8        330 tests based on canvas-composite-alpha to test correct compositing behavior with
     9        strokeRect() and stroke().
     10
     11        * fast/canvas/canvas-composite-stroke-alpha-expected.txt: Added.
     12        * fast/canvas/canvas-composite-stroke-alpha.html: Added.
     13
    1142014-04-05  Jeongeun Kim  <je_julie.kim@samsung.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r166834 r166836  
     12014-04-05  Dirk Schulze  <krit@webkit.org>
     2
     3        Canvas stroke and strokeRect with SourceIn, DestinationIn, SourceOut, DestinationAtop and Copy have errors
     4        https://bugs.webkit.org/show_bug.cgi?id=66762
     5
     6        Reviewed by Andreas Kling.
     7
     8        For fill operations we create a new ImageBuffer to ensure that the results are composited
     9        correctly according to the Canvas spec. This patch creates a new transparency layer
     10        for stroking on certain compositing operators to archive the same. This makes WebKit's
     11        behavior interoperable with Firefox and IE as well.
     12
     13        Test: fast/fast/canvas/canvas-composite-stroke-alpha.html
     14
     15        * html/canvas/CanvasRenderingContext2D.cpp:
     16        (WebCore::CanvasRenderingContext2D::strokeInternal):
     17        (WebCore::CanvasRenderingContext2D::strokeRect):
     18
    1192014-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
    220
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r166785 r166836  
    971971
    972972    if (!path.isEmpty()) {
    973         FloatRect dirtyRect = path.fastBoundingRect();
    974         inflateStrokeRect(dirtyRect);
    975 
    976         c->strokePath(path);
    977         didDraw(dirtyRect);
     973        if (isFullCanvasCompositeMode(state().m_globalComposite)) {
     974            c->beginTransparencyLayer(1);
     975            c->strokePath(path);
     976            c->endTransparencyLayer();
     977            didDrawEntireCanvas();
     978        } else if (state().m_globalComposite == CompositeCopy) {
     979            clearCanvas();
     980            c->strokePath(path);
     981            didDrawEntireCanvas();
     982        } else {
     983            FloatRect dirtyRect = path.fastBoundingRect();
     984            inflateStrokeRect(dirtyRect);
     985            c->strokePath(path);
     986            didDraw(dirtyRect);
     987        }
    978988    }
    979989}
     
    11481158
    11491159    FloatRect rect(x, y, width, height);
    1150 
    1151     FloatRect boundingRect = rect;
    1152     boundingRect.inflate(state().m_lineWidth / 2);
    1153 
    1154     c->strokeRect(rect, state().m_lineWidth);
    1155     didDraw(boundingRect);
     1160    if (isFullCanvasCompositeMode(state().m_globalComposite)) {
     1161        c->beginTransparencyLayer(1);
     1162        c->strokeRect(rect, state().m_lineWidth);
     1163        c->endTransparencyLayer();
     1164        didDrawEntireCanvas();
     1165    } else if (state().m_globalComposite == CompositeCopy) {
     1166        clearCanvas();
     1167        c->strokeRect(rect, state().m_lineWidth);
     1168        didDrawEntireCanvas();
     1169    } else {
     1170        FloatRect boundingRect = rect;
     1171        boundingRect.inflate(state().m_lineWidth / 2);
     1172        c->strokeRect(rect, state().m_lineWidth);
     1173        didDraw(boundingRect);
     1174    }
    11561175}
    11571176
Note: See TracChangeset for help on using the changeset viewer.