⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 106729 in webkit


Ignore:
Timestamp:
Feb 3, 2012, 10:43:50 PM (15 years ago)
Author:
timothy_horton@apple.com
Message:

Canvas-into-canvas drawing should respect backing store scale ratio
https://bugs.webkit.org/show_bug.cgi?id=77784
<rdar://problem/10549729>

Reviewed by Dan Bernstein.

Respect the backing store scale ratio when drawing a canvas into another
canvas via ctx.drawImage(canvas, x, y). Previous behavior caused canvas
drawing to differ based on the size of the backing store, which is ideally
an implementation detail to authors.

Also, rename the source canvas arguments to CanvasRenderingContext2D::drawImage
to be more clear.

No new tests.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawImage):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106725 r106729  
     12012-02-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        Canvas-into-canvas drawing should respect backing store scale ratio
     4        https://bugs.webkit.org/show_bug.cgi?id=77784
     5        <rdar://problem/10549729>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        Respect the backing store scale ratio when drawing a canvas into another
     10        canvas via ctx.drawImage(canvas, x, y). Previous behavior caused canvas
     11        drawing to differ based on the size of the backing store, which is ideally
     12        an implementation detail to authors.
     13
     14        Also, rename the source canvas arguments to CanvasRenderingContext2D::drawImage
     15        to be more clear.
     16
     17        No new tests.
     18
     19        * html/canvas/CanvasRenderingContext2D.cpp:
     20        (WebCore::CanvasRenderingContext2D::drawImage):
     21
    1222012-02-03  Beth Dakin  <bdakin@apple.com>
    223
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r106695 r106729  
    13651365}
    13661366
    1367 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y, ExceptionCode& ec)
    1368 {
    1369     if (!canvas) {
     1367void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, float x, float y, ExceptionCode& ec)
     1368{
     1369    if (!sourceCanvas) {
    13701370        ec = TYPE_MISMATCH_ERR;
    13711371        return;
    13721372    }
    13731373
    1374     // In order to emulate drawing the result of toDataURL() into the canvas, we
    1375     // need to deflate the size of the source rectangle by the source canvas's
    1376     // backing store scale factor.
    1377     // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=15041 for motivation.
    1378 
    1379     FloatSize logicalSize = canvas->convertDeviceToLogical(canvas->size());
    1380 
    1381     drawImage(canvas, 0, 0, logicalSize.width(), logicalSize.height(), x, y, canvas->width(), canvas->height(), ec);
    1382 }
    1383 
    1384 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas,
     1374    drawImage(sourceCanvas, 0, 0, sourceCanvas->width(), sourceCanvas->height(), x, y, sourceCanvas->width(), sourceCanvas->height(), ec);
     1375}
     1376
     1377void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas,
    13851378    float x, float y, float width, float height, ExceptionCode& ec)
    13861379{
    1387     if (!canvas) {
     1380    if (!sourceCanvas) {
    13881381        ec = TYPE_MISMATCH_ERR;
    13891382        return;
    13901383    }
    1391     drawImage(canvas, FloatRect(0, 0, canvas->width(), canvas->height()), FloatRect(x, y, width, height), ec);
    1392 }
    1393 
    1394 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas,
     1384    drawImage(sourceCanvas, FloatRect(0, 0, sourceCanvas->width(), sourceCanvas->height()), FloatRect(x, y, width, height), ec);
     1385}
     1386
     1387void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas,
    13951388    float sx, float sy, float sw, float sh,
    13961389    float dx, float dy, float dw, float dh, ExceptionCode& ec)
    13971390{
    1398     drawImage(canvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
     1391    drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
    13991392}
    14001393
Note: See TracChangeset for help on using the changeset viewer.