Changeset 24090 in webkit


Ignore:
Timestamp:
Jul 7, 2007 1:14:41 PM (17 years ago)
Author:
darin
Message:

LayoutTests:

Reviewed by Darin.

Testcase for:
http://bugs.webkit.org/show_bug.cgi?id=8994
Canvas doesn't reset on resize

  • fast/canvas/canvas-resize-reset-expected.checksum: Added.
  • fast/canvas/canvas-resize-reset-expected.png: Added.
  • fast/canvas/canvas-resize-reset-expected.txt: Added.
  • fast/canvas/canvas-resize-reset.html: Added.

WebCore:

Reviewed and tweaked by Darin.

http://bugs.webkit.org/show_bug.cgi?id=8994
Canvas doesn't reset on resize

Also reset the rendering context when resetting the canvas.

  • html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::reset): (WebCore::HTMLCanvasElement::drawingContext):
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r24089 r24090  
     12007-07-07  Rob Buis  <buis@kde.org>
     2
     3        Reviewed by Darin.
     4
     5        Testcase for:
     6        http://bugs.webkit.org/show_bug.cgi?id=8994
     7        Canvas doesn't reset on resize
     8
     9        * fast/canvas/canvas-resize-reset-expected.checksum: Added.
     10        * fast/canvas/canvas-resize-reset-expected.png: Added.
     11        * fast/canvas/canvas-resize-reset-expected.txt: Added.
     12        * fast/canvas/canvas-resize-reset.html: Added.
     13
    1142007-07-07  Alexey Proskuryakov  <ap@webkit.org>
    215
  • trunk/WebCore/ChangeLog

    r24088 r24090  
     12007-07-07  Rob Buis  <buis@kde.org>
     2
     3        Reviewed and tweaked by Darin.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=8994
     6        Canvas doesn't reset on resize
     7
     8        Also reset the rendering context when resetting the canvas.
     9
     10        * html/HTMLCanvasElement.cpp:
     11        (WebCore::HTMLCanvasElement::reset):
     12        (WebCore::HTMLCanvasElement::drawingContext):
     13
    1142007-07-07  Alexey Proskuryakov  <ap@webkit.org>
    215
  • trunk/WebCore/html/CanvasRenderingContext2D.cpp

    r23935 r24090  
    436436    if (!c)
    437437        return;
     438    if (state().m_path.isEmpty())
     439        return;
    438440    // FIXME: Do this through platform-independent GraphicsContext API.
    439441#if PLATFORM(CG)
     
    472474    GraphicsContext* c = drawingContext();
    473475    if (!c)
     476        return;
     477    if (state().m_path.isEmpty())
    474478        return;
    475479    // FIXME: Do this through platform-independent GraphicsContext API.
  • trunk/WebCore/html/HTMLCanvasElement.cpp

    r21749 r24090  
    3939#include "RenderHTMLCanvas.h"
    4040#include "Settings.h"
     41#include <math.h>
    4142
    4243#if PLATFORM(QT)
     
    4546#endif
    4647
    47 #include <math.h>
    48 
    49 
    5048namespace WebCore {
    5149
     
    5351
    5452// These values come from the WhatWG spec.
    55 const int defaultWidth = 300;
    56 const int defaultHeight = 150;
     53static const int defaultWidth = 300;
     54static const int defaultHeight = 150;
    5755
    5856// Firefox limits width/height to 32767 pixels, but slows down dramatically before it
    59 // reaches that limit we limit by area instead, giving us larger max dimensions, in exchange
    60 // for reduce maximum canvas size.
    61 const float maxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pixels
     57// reaches that limit. We limit by area instead, giving us larger maximum dimensions,
     58// in exchange for a smaller maximum canvas size.
     59static const float maxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pixels
    6260
    6361HTMLCanvasElement::HTMLCanvasElement(Document* doc)
     
    178176    delete m_drawingContext;
    179177    m_drawingContext = 0;
     178    if (m_2DContext)
     179        m_2DContext->reset();
    180180
    181181    if (RenderObject* ro = renderer())
     
    218218    float wf = ceilf(unscaledWidth * pageScaleFactor);
    219219    float hf = ceilf(unscaledHeight * pageScaleFactor);
    220    
     220
    221221    if (!(wf >= 1 && hf >= 1 && wf * hf <= maxCanvasArea))
    222222        return;
    223        
     223
    224224    unsigned w = static_cast<unsigned>(wf);
    225225    unsigned h = static_cast<unsigned>(hf);
    226    
     226
     227#if PLATFORM(CG)
    227228    size_t bytesPerRow = w * 4;
    228229    if (bytesPerRow / 4 != w) // check for overflow
    229230        return;
    230 #if PLATFORM(CG)
    231231    m_data = fastCalloc(h, bytesPerRow);
    232 #elif PLATFORM(QT)
    233     m_data = new QPixmap(w, h);
    234 #endif
    235232    if (!m_data)
    236233        return;
    237 #if PLATFORM(CG)
    238234    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    239235    CGContextRef bitmapContext = CGBitmapContextCreate(m_data, w, h, 8, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
     
    243239    CGContextRelease(bitmapContext);
    244240#elif PLATFORM(QT)
     241    m_data = new QPixmap(w, h);
     242    if (!m_data)
     243        return;
    245244    m_data->fill(Qt::white);
    246245    m_painter = new QPainter(m_data);
     
    263262    if (!context)
    264263        return 0;
    265    
     264
    266265    CGContextRef contextRef = context->platformContext();
    267266    if (!contextRef)
    268267        return 0;
    269    
     268
    270269    CGContextFlush(contextRef);
    271    
     270
    272271    return CGBitmapContextCreateImage(contextRef);
    273272}
    274 #elif PLATFORM(QT)
     273
     274#elif PLATFORM(QT)
     275
    275276QPixmap HTMLCanvasElement::createPlatformImage() const
    276277{
Note: See TracChangeset for help on using the changeset viewer.