Skip to content

Commit

Permalink
Canvas does not show results of CanvasRenderingContext2D.putImageData…
Browse files Browse the repository at this point in the history
… until forced re-render.

https://bugs.webkit.org/show_bug.cgi?id=259584
rdar://112901862

Reviewed by Tim Nguyen.

The commit in 263694@main caused a regression when calculating the dirty region
of a putImageDataUpdate. It accidentally removed a reference marker on a parameter.

* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::computeImageDataRect): Make sure the destRect parameter is a reference because it is updated.
(WebCore::CanvasRenderingContext2DBase::putImageData): Leave a fixme!

Canonical link: https://commits.webkit.org/266397@main
  • Loading branch information
grorg committed Jul 28, 2023
1 parent 9b97e10 commit fdd0bc1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void CanvasRenderingContext2DBase::clip(Path2D& path, CanvasFillRule windingRule
clipInternal(path.path(), windingRule);
}

static inline IntRect computeImageDataRect(const ImageBuffer& buffer, int width, int height, IntRect destRect, const IntSize& destOffset)
static inline IntRect computeImageDataRect(const ImageBuffer& buffer, int width, int height, IntRect& destRect, const IntSize& destOffset)
{
destRect.intersect(IntRect { 0, 0, width, height });
destRect.move(destOffset);
Expand Down Expand Up @@ -2381,6 +2381,8 @@ void CanvasRenderingContext2DBase::putImageData(ImageData& data, int dx, int dy,

IntSize destOffset { dx, dy };
IntRect destRect { dirtyX, dirtyY, dirtyWidth, dirtyHeight };
// FIXME: computeImageDataRect also updates destRect. Maybe return a tuple? Or move
// the calculation of the real destRect to here.
IntRect sourceRect = computeImageDataRect(*buffer, data.width(), data.height(), destRect, destOffset);

if (!sourceRect.isEmpty())
Expand Down

0 comments on commit fdd0bc1

Please sign in to comment.