Changeset 30533 in webkit
- Timestamp:
- Feb 23, 2008 8:15:23 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r30530 r30533 1 2008-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 1 48 2008-02-23 Dan Bernstein <mitz@apple.com> 2 49 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r30513 r30533 104 104 { 105 105 cairo_save(m_data->cr); 106 m_data->save(); 106 107 } 107 108 … … 109 110 { 110 111 cairo_restore(m_data->cr); 112 m_data->restore(); 111 113 } 112 114 … … 381 383 cairo_clip(cr); 382 384 cairo_set_fill_rule(cr, savedFillRule); 385 m_data->clip(rect); 383 386 } 384 387 … … 432 435 return; 433 436 434 #if PLATFORM(GTK)435 437 cairo_t* cr = m_data->cr; 436 438 cairo_save(cr); … … 443 445 cairo_set_source_rgb(cr, 1, 0, 0); 444 446 447 #if PLATFORM(GTK) 445 448 // We ignore most of the provided constants in favour of the platform style 446 449 pango_cairo_show_error_underline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness); 447 448 cairo_restore(cr);449 450 #else 450 451 notImplemented(); 451 452 #endif 453 454 cairo_restore(cr); 452 455 } 453 456 … … 482 485 cairo_t* cr = m_data->cr; 483 486 cairo_translate(cr, x, y); 487 m_data->translate(x, y); 484 488 } 485 489 … … 545 549 } 546 550 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.cpp550 551 void GraphicsContext::concatCTM(const AffineTransform& transform) 551 552 { … … 556 557 const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform); 557 558 cairo_transform(cr, matrix); 558 } 559 #endif 559 m_data->concatCTM(transform); 560 } 560 561 561 562 void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) … … 601 602 cairo_push_group(cr); 602 603 m_data->layers.append(opacity); 604 m_data->beginTransparencyLayer(); 603 605 } 604 606 … … 613 615 cairo_paint_with_alpha(cr, m_data->layers.last()); 614 616 m_data->layers.removeLast(); 617 m_data->endTransparencyLayer(); 615 618 } 616 619 … … 774 777 cairo_clip(cr); 775 778 cairo_set_fill_rule(cr, savedFillRule); 779 m_data->clip(path); 776 780 } 777 781 … … 799 803 800 804 cairo_rotate(m_data->cr, radians); 805 m_data->rotate(radians); 801 806 } 802 807 … … 807 812 808 813 cairo_scale(m_data->cr, size.width(), size.height()); 814 m_data->scale(size); 809 815 } 810 816 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r30513 r30533 63 63 #if PLATFORM(WIN) 64 64 // 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&); 65 73 void beginTransparencyLayer() { m_transparencyCount++; } 66 74 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() {} 67 87 #endif 68 88 -
trunk/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
r30513 r30533 169 169 } 170 170 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/180212 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 242 171 void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) 243 172 { -
trunk/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
r30513 r30533 93 93 } 94 94 95 void GraphicsContext ::concatCTM(const AffineTransform& transform)95 void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) 96 96 { 97 cairo_surface_t* surface = cairo_get_target( platformContext());97 cairo_surface_t* surface = cairo_get_target(cr); 98 98 HDC hdc = cairo_win32_surface_get_dc(surface); 99 99 SaveDC(hdc); 100 100 101 c airo_matrix_t mat;102 cairo_get_matrix(platformContext(), &mat); 101 const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform); 102 103 103 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; 110 110 111 111 ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY); -
trunk/WebCore/platform/graphics/win/GraphicsContextWin.cpp
r30513 r30533 27 27 #include "GraphicsContext.h" 28 28 29 #if PLATFORM(CG) 30 #include "GraphicsContextPlatformPrivateCG.h" 31 #elif PLATFORM(CAIRO) 32 #include "GraphicsContextPlatformPrivateCairo.h" 33 #endif 34 29 35 #include "AffineTransform.h" 30 36 #include "NotImplemented.h" … … 38 44 class SVGResourceImage; 39 45 46 void GraphicsContextPlatformPrivate::save() 47 { 48 if (!m_hdc) 49 return; 50 SaveDC(m_hdc); 51 } 52 53 void GraphicsContextPlatformPrivate::restore() 54 { 55 if (!m_hdc) 56 return; 57 RestoreDC(m_hdc, -1); 58 } 59 60 void 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 67 void GraphicsContextPlatformPrivate::clip(const Path&) 68 { 69 notImplemented(); 70 } 71 72 void 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 86 static const double deg2rad = 0.017453292519943295769; // pi/180 87 88 void 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 103 void 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 40 117 #if ENABLE(SVG) 41 118 GraphicsContext* contextForImage(SVGResourceImage*) -
trunk/WebCore/platform/win/DragImageCairoWin.cpp
r30513 r30533 48 48 notImplemented(); 49 49 50 DragImageRef temp; 51 return temp; 50 return 0; 52 51 } 53 52
Note: See TracChangeset
for help on using the changeset viewer.