Changeset 30533 in webkit


Ignore:
Timestamp:
Feb 23, 2008 8:15:23 PM (16 years ago)
Author:
pewtermoose@webkit.org
Message:

2008-02-23 Brent Fulgham <bfulgham@gmail.com>

Reviewed by Adam and Darin.

http://bugs.webkit.org/show_bug.cgi?id=17442
Correct the Windows Cairo implementation of GraphicsContext so
that Windows 'WorldTransform' is kept in sync with the Cairo
transormations.

Also corrects an uninitialized variable in the Cairo Windows
image drag handler.

WARNING: NO TEST CASES ADDED OR CHANGED

  • platform/graphics/cairo/GraphicsContextCairo.cpp: Modify methods to call GraphicsContextPlatformPrivate calls, just as is done for the CoreGraphics version. These calls are nop's for everything but Windows. (WebCore::GraphicsContext::savePlatformState): (WebCore::GraphicsContext::restorePlatformState): (WebCore::GraphicsContext::clip): (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar): (WebCore::GraphicsContext::translate): (WebCore::GraphicsContext::concatCTM): Re-enable for Windows (WebCore::GraphicsContext::beginTransparencyLayer): (WebCore::GraphicsContext::endTransparencyLayer): (WebCore::GraphicsContext::rotate): (WebCore::GraphicsContext::scale):
  • platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
  • platform/graphics/win/GraphicsContextCGWin.cpp: Move common code for handling WorldTransform calls to parent class.
  • platform/graphics/win/GraphicsContextCairoWin.cpp: Add common code for handling WorldTransform calls. (WebCore::GraphicsContextPlatformPrivate::concatCTM): Change implementation so that it only handles WorldTransform. The Cairo update is done in GraphicsContextCairo.cpp
  • platform/graphics/win/GraphicsContextWin.cpp: Call platform-private methods to keep WorldTransform in sync. (WebCore::GraphicsContextPlatformPrivate::save): (WebCore::GraphicsContextPlatformPrivate::restore): (WebCore::GraphicsContextPlatformPrivate::clip): (WebCore::GraphicsContextPlatformPrivate::scale): (WebCore::GraphicsContextPlatformPrivate::rotate): (WebCore::GraphicsContextPlatformPrivate::translate):
  • platform/win/DragImageCairoWin.cpp: (WebCore::createDragImageFromImage): Correct uninitialized value
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30530 r30533  
     12008-02-23  Brent Fulgham  <bfulgham@gmail.com>
     2
     3        Reviewed by Adam and Darin.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=17442
     6        Correct the Windows Cairo implementation of GraphicsContext so
     7        that Windows 'WorldTransform' is kept in sync with the Cairo
     8        transormations.
     9
     10        Also corrects an uninitialized variable in the Cairo Windows
     11        image drag handler.
     12
     13        WARNING: NO TEST CASES ADDED OR CHANGED
     14
     15        * platform/graphics/cairo/GraphicsContextCairo.cpp:  Modify
     16          methods to call GraphicsContextPlatformPrivate calls, just
     17          as is done for the CoreGraphics version.  These calls are
     18          nop's for everything but Windows.
     19        (WebCore::GraphicsContext::savePlatformState):
     20        (WebCore::GraphicsContext::restorePlatformState):
     21        (WebCore::GraphicsContext::clip):
     22        (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar):
     23        (WebCore::GraphicsContext::translate):
     24        (WebCore::GraphicsContext::concatCTM): Re-enable for Windows
     25        (WebCore::GraphicsContext::beginTransparencyLayer):
     26        (WebCore::GraphicsContext::endTransparencyLayer):
     27        (WebCore::GraphicsContext::rotate):
     28        (WebCore::GraphicsContext::scale):
     29        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
     30        * platform/graphics/win/GraphicsContextCGWin.cpp:  Move common
     31          code for handling WorldTransform calls to parent class.
     32        * platform/graphics/win/GraphicsContextCairoWin.cpp:  Add common
     33          code for handling WorldTransform calls.
     34          (WebCore::GraphicsContextPlatformPrivate::concatCTM):  Change
     35          implementation so that it only handles WorldTransform.  The
     36          Cairo update is done in GraphicsContextCairo.cpp
     37        * platform/graphics/win/GraphicsContextWin.cpp:  Call platform-private
     38          methods to keep WorldTransform in sync.
     39        (WebCore::GraphicsContextPlatformPrivate::save):
     40        (WebCore::GraphicsContextPlatformPrivate::restore):
     41        (WebCore::GraphicsContextPlatformPrivate::clip):
     42        (WebCore::GraphicsContextPlatformPrivate::scale):
     43        (WebCore::GraphicsContextPlatformPrivate::rotate):
     44        (WebCore::GraphicsContextPlatformPrivate::translate):
     45        * platform/win/DragImageCairoWin.cpp:
     46        (WebCore::createDragImageFromImage):  Correct uninitialized value
     47
    1482008-02-23  Dan Bernstein  <mitz@apple.com>
    249
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r30513 r30533  
    104104{
    105105    cairo_save(m_data->cr);
     106    m_data->save();
    106107}
    107108
     
    109110{
    110111    cairo_restore(m_data->cr);
     112    m_data->restore();
    111113}
    112114
     
    381383    cairo_clip(cr);
    382384    cairo_set_fill_rule(cr, savedFillRule);
     385    m_data->clip(rect);
    383386}
    384387
     
    432435        return;
    433436
    434 #if PLATFORM(GTK)
    435437    cairo_t* cr = m_data->cr;
    436438    cairo_save(cr);
     
    443445        cairo_set_source_rgb(cr, 1, 0, 0);
    444446
     447#if PLATFORM(GTK)
    445448    // We ignore most of the provided constants in favour of the platform style
    446449    pango_cairo_show_error_underline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
    447 
    448     cairo_restore(cr);
    449450#else
    450451    notImplemented();
    451452#endif
     453
     454    cairo_restore(cr);
    452455}
    453456
     
    482485    cairo_t* cr = m_data->cr;
    483486    cairo_translate(cr, x, y);
     487    m_data->translate(x, y);
    484488}
    485489
     
    545549}
    546550
    547 #if PLATFORM(GTK)
    548 // FIXME:  This should be moved to something like GraphicsContextCairoGTK.cpp,
    549 // as there is a Windows implementation in platform/graphics/win/GraphicsContextCairoWin.cpp
    550551void GraphicsContext::concatCTM(const AffineTransform& transform)
    551552{
     
    556557    const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);
    557558    cairo_transform(cr, matrix);
    558 }
    559 #endif
     559    m_data->concatCTM(transform);
     560}
    560561
    561562void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
     
    601602    cairo_push_group(cr);
    602603    m_data->layers.append(opacity);
     604    m_data->beginTransparencyLayer();
    603605}
    604606
     
    613615    cairo_paint_with_alpha(cr, m_data->layers.last());
    614616    m_data->layers.removeLast();
     617    m_data->endTransparencyLayer();
    615618}
    616619
     
    774777    cairo_clip(cr);
    775778    cairo_set_fill_rule(cr, savedFillRule);
     779    m_data->clip(path);
    776780}
    777781
     
    799803
    800804    cairo_rotate(m_data->cr, radians);
     805    m_data->rotate(radians);
    801806}
    802807
     
    807812
    808813    cairo_scale(m_data->cr, size.width(), size.height());
     814    m_data->scale(size);
    809815}
    810816
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h

    r30513 r30533  
    6363#if PLATFORM(WIN)
    6464    // On Windows, we need to update the HDC for form controls to draw in the right place.
     65    void save();
     66    void restore();
     67    void clip(const IntRect&);
     68    void clip(const Path&);
     69    void scale(const FloatSize&);
     70    void rotate(float);
     71    void translate(float, float);
     72    void concatCTM(const AffineTransform&);
    6573    void beginTransparencyLayer() { m_transparencyCount++; }
    6674    void endTransparencyLayer() { m_transparencyCount--; }
     75#else
     76    // On everything else, we do nothing.
     77    void save() {}
     78    void restore() {}
     79    void clip(const IntRect&) {}
     80    void clip(const Path&) {}
     81    void scale(const FloatSize&) {}
     82    void rotate(float) {}
     83    void translate(float, float) {}
     84    void concatCTM(const AffineTransform&) {}
     85    void beginTransparencyLayer() {}
     86    void endTransparencyLayer() {}
    6787#endif
    6888
  • trunk/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r30513 r30533  
    169169}
    170170
    171 void GraphicsContextPlatformPrivate::save()
    172 {
    173     if (!m_hdc)
    174         return;
    175     SaveDC(m_hdc);
    176 }
    177 
    178 void GraphicsContextPlatformPrivate::restore()
    179 {
    180     if (!m_hdc)
    181         return;
    182     RestoreDC(m_hdc, -1);
    183 }
    184 
    185 void GraphicsContextPlatformPrivate::clip(const IntRect& clipRect)
    186 {
    187     if (!m_hdc)
    188         return;
    189     IntersectClipRect(m_hdc, clipRect.x(), clipRect.y(), clipRect.right(), clipRect.bottom());
    190 }
    191 
    192 void GraphicsContextPlatformPrivate::clip(const Path&)
    193 {
    194     notImplemented();
    195 }
    196 
    197 void GraphicsContextPlatformPrivate::scale(const FloatSize& size)
    198 {
    199     if (!m_hdc)
    200         return;
    201     XFORM xform;
    202     xform.eM11 = size.width();
    203     xform.eM12 = 0.0f;
    204     xform.eM21 = 0.0f;
    205     xform.eM22 = size.height();
    206     xform.eDx = 0.0f;
    207     xform.eDy = 0.0f;
    208     ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
    209 }
    210 
    211 static const double deg2rad = 0.017453292519943295769; // pi/180
    212 
    213 void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
    214 {
    215     float radiansAngle = degreesAngle * deg2rad;
    216     float cosAngle = cosf(radiansAngle);
    217     float sinAngle = sinf(radiansAngle);
    218     XFORM xform;
    219     xform.eM11 = cosAngle;
    220     xform.eM12 = -sinAngle;
    221     xform.eM21 = sinAngle;
    222     xform.eM22 = cosAngle;
    223     xform.eDx = 0.0f;
    224     xform.eDy = 0.0f;
    225     ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
    226 }
    227 
    228 void GraphicsContextPlatformPrivate::translate(float x , float y)
    229 {
    230     if (!m_hdc)
    231         return;
    232     XFORM xform;
    233     xform.eM11 = 1.0f;
    234     xform.eM12 = 0.0f;
    235     xform.eM21 = 0.0f;
    236     xform.eM22 = 1.0f;
    237     xform.eDx = x;
    238     xform.eDy = y;
    239     ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
    240 }
    241 
    242171void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform)
    243172{
  • trunk/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp

    r30513 r30533  
    9393}
    9494
    95 void GraphicsContext::concatCTM(const AffineTransform& transform)
     95void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform)
    9696{
    97     cairo_surface_t* surface = cairo_get_target(platformContext());
     97    cairo_surface_t* surface = cairo_get_target(cr);
    9898    HDC hdc = cairo_win32_surface_get_dc(surface);   
    9999    SaveDC(hdc);
    100100
    101     cairo_matrix_t mat;
    102     cairo_get_matrix(platformContext(), &mat);
     101    const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);
     102
    103103    XFORM xform;
    104     xform.eM11 = mat.xx;
    105     xform.eM12 = mat.xy;
    106     xform.eM21 = mat.yx;
    107     xform.eM22 = mat.yy;
    108     xform.eDx = mat.x0;
    109     xform.eDy = mat.y0;
     104    xform.eM11 = matrix->xx;
     105    xform.eM12 = matrix->xy;
     106    xform.eM21 = matrix->yx;
     107    xform.eM22 = matrix->yy;
     108    xform.eDx = matrix->x0;
     109    xform.eDy = matrix->y0;
    110110
    111111    ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
  • trunk/WebCore/platform/graphics/win/GraphicsContextWin.cpp

    r30513 r30533  
    2727#include "GraphicsContext.h"
    2828
     29#if PLATFORM(CG)
     30#include "GraphicsContextPlatformPrivateCG.h"
     31#elif PLATFORM(CAIRO)
     32#include "GraphicsContextPlatformPrivateCairo.h"
     33#endif
     34
    2935#include "AffineTransform.h"
    3036#include "NotImplemented.h"
     
    3844class SVGResourceImage;
    3945
     46void GraphicsContextPlatformPrivate::save()
     47{
     48    if (!m_hdc)
     49        return;
     50    SaveDC(m_hdc);
     51}
     52
     53void GraphicsContextPlatformPrivate::restore()
     54{
     55    if (!m_hdc)
     56        return;
     57    RestoreDC(m_hdc, -1);
     58}
     59
     60void GraphicsContextPlatformPrivate::clip(const IntRect& clipRect)
     61{
     62    if (!m_hdc)
     63        return;
     64    IntersectClipRect(m_hdc, clipRect.x(), clipRect.y(), clipRect.right(), clipRect.bottom());
     65}
     66
     67void GraphicsContextPlatformPrivate::clip(const Path&)
     68{
     69    notImplemented();
     70}
     71
     72void GraphicsContextPlatformPrivate::scale(const FloatSize& size)
     73{
     74    if (!m_hdc)
     75        return;
     76    XFORM xform;
     77    xform.eM11 = size.width();
     78    xform.eM12 = 0.0f;
     79    xform.eM21 = 0.0f;
     80    xform.eM22 = size.height();
     81    xform.eDx = 0.0f;
     82    xform.eDy = 0.0f;
     83    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
     84}
     85
     86static const double deg2rad = 0.017453292519943295769; // pi/180
     87
     88void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
     89{
     90    float radiansAngle = degreesAngle * deg2rad;
     91    float cosAngle = cosf(radiansAngle);
     92    float sinAngle = sinf(radiansAngle);
     93    XFORM xform;
     94    xform.eM11 = cosAngle;
     95    xform.eM12 = -sinAngle;
     96    xform.eM21 = sinAngle;
     97    xform.eM22 = cosAngle;
     98    xform.eDx = 0.0f;
     99    xform.eDy = 0.0f;
     100    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
     101}
     102
     103void GraphicsContextPlatformPrivate::translate(float x , float y)
     104{
     105    if (!m_hdc)
     106        return;
     107    XFORM xform;
     108    xform.eM11 = 1.0f;
     109    xform.eM12 = 0.0f;
     110    xform.eM21 = 0.0f;
     111    xform.eM22 = 1.0f;
     112    xform.eDx = x;
     113    xform.eDy = y;
     114    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
     115}
     116
    40117#if ENABLE(SVG)
    41118GraphicsContext* contextForImage(SVGResourceImage*)
  • trunk/WebCore/platform/win/DragImageCairoWin.cpp

    r30513 r30533  
    4848    notImplemented();
    4949
    50     DragImageRef temp;
    51     return temp;
     50    return 0;
    5251}
    5352   
Note: See TracChangeset for help on using the changeset viewer.