Changeset 30513 in webkit
- Timestamp:
- Feb 22, 2008 8:18:40 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r30512 r30513 146 146 * platform/win/BString.h: 147 147 * platform/win/PasteboardWin.cpp: 148 149 2008-02-22 Brent Fulgham <bfulgham@gmail.com>150 151 Reviewed by Adam Roben.152 153 http://bugs.webkit.org/show_bug.cgi?id=17442154 Correct the Windows Cairo implementation of GraphicsContext so155 that Windows 'WorldTransform' is kept in sync with the Cairo156 transformations.157 158 Also corrects an uninitialized variable in the Cairo Windows159 image drag handler.160 161 * platform/graphics/cairo/GraphicsContextCairo.cpp: Modify162 methods to call GraphicsContextPlatformPrivate calls, just163 as is done for the CoreGraphics version. These calls are164 nop's for everything but Windows.165 (WebCore::GraphicsContext::savePlatformState):166 (WebCore::GraphicsContext::restorePlatformState):167 (WebCore::GraphicsContext::clip):168 (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar):169 (WebCore::GraphicsContext::translate):170 (WebCore::GraphicsContext::concatCTM): Re-enable for Windows171 (WebCore::GraphicsContext::beginTransparencyLayer):172 (WebCore::GraphicsContext::endTransparencyLayer):173 (WebCore::GraphicsContext::rotate):174 (WebCore::GraphicsContext::scale):175 * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:176 * platform/graphics/win/GraphicsContextCGWin.cpp: Move common177 code for handling WorldTransform calls to parent class.178 * platform/graphics/win/GraphicsContextCairoWin.cpp: Add common179 code for handling WorldTransform calls.180 (WebCore::GraphicsContextPlatformPrivate::concatCTM): Change181 implementation so that it only handles WorldTransform. The182 Cairo update is done in GraphicsContextCairo.cpp183 * platform/graphics/win/GraphicsContextWin.cpp: Call platform-private184 methods to keep WorldTransform in sync.185 (WebCore::GraphicsContextPlatformPrivate::save):186 (WebCore::GraphicsContextPlatformPrivate::restore):187 (WebCore::GraphicsContextPlatformPrivate::clip):188 (WebCore::GraphicsContextPlatformPrivate::scale):189 (WebCore::GraphicsContextPlatformPrivate::rotate):190 (WebCore::GraphicsContextPlatformPrivate::translate):191 * platform/win/DragImageCairoWin.cpp:192 (WebCore::createDragImageFromImage): Correct uninitialized value193 148 194 149 2008-02-22 Sam Weinig <sam@webkit.org> -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r30500 r30513 104 104 { 105 105 cairo_save(m_data->cr); 106 m_data->save();107 106 } 108 107 … … 110 109 { 111 110 cairo_restore(m_data->cr); 112 m_data->restore();113 111 } 114 112 … … 383 381 cairo_clip(cr); 384 382 cairo_set_fill_rule(cr, savedFillRule); 385 m_data->clip(rect);386 383 } 387 384 … … 435 432 return; 436 433 434 #if PLATFORM(GTK) 437 435 cairo_t* cr = m_data->cr; 438 436 cairo_save(cr); … … 445 443 cairo_set_source_rgb(cr, 1, 0, 0); 446 444 447 #if PLATFORM(GTK)448 445 // We ignore most of the provided constants in favour of the platform style 449 446 pango_cairo_show_error_underline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness); 447 448 cairo_restore(cr); 450 449 #else 451 450 notImplemented(); 452 451 #endif 453 454 cairo_restore(cr);455 452 } 456 453 … … 485 482 cairo_t* cr = m_data->cr; 486 483 cairo_translate(cr, x, y); 487 m_data->translate(x, y);488 484 } 489 485 … … 549 545 } 550 546 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 551 550 void GraphicsContext::concatCTM(const AffineTransform& transform) 552 551 { … … 557 556 const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform); 558 557 cairo_transform(cr, matrix); 559 m_data->concatCTM(transform); 560 } 558 } 559 #endif 561 560 562 561 void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) … … 602 601 cairo_push_group(cr); 603 602 m_data->layers.append(opacity); 604 m_data->beginTransparencyLayer();605 603 } 606 604 … … 615 613 cairo_paint_with_alpha(cr, m_data->layers.last()); 616 614 m_data->layers.removeLast(); 617 m_data->endTransparencyLayer();618 615 } 619 616 … … 777 774 cairo_clip(cr); 778 775 cairo_set_fill_rule(cr, savedFillRule); 779 m_data->clip(path);780 776 } 781 777 … … 803 799 804 800 cairo_rotate(m_data->cr, radians); 805 m_data->rotate(radians);806 801 } 807 802 … … 812 807 813 808 cairo_scale(m_data->cr, size.width(), size.height()); 814 m_data->scale(size);815 809 } 816 810 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r30500 r30513 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&);73 65 void beginTransparencyLayer() { m_transparencyCount++; } 74 66 void endTransparencyLayer() { m_transparencyCount--; } -
trunk/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
r30500 r30513 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/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 171 242 void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) 172 243 { -
trunk/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
r30500 r30513 93 93 } 94 94 95 void GraphicsContext PlatformPrivate::concatCTM(const AffineTransform& transform)95 void GraphicsContext::concatCTM(const AffineTransform& transform) 96 96 { 97 cairo_surface_t* surface = cairo_get_target( cr);97 cairo_surface_t* surface = cairo_get_target(platformContext()); 98 98 HDC hdc = cairo_win32_surface_get_dc(surface); 99 99 SaveDC(hdc); 100 100 101 c onst cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);102 101 cairo_matrix_t mat; 102 cairo_get_matrix(platformContext(), &mat); 103 103 XFORM xform; 104 xform.eM11 = mat rix->xx;105 xform.eM12 = mat rix->xy;106 xform.eM21 = mat rix->yx;107 xform.eM22 = mat rix->yy;108 xform.eDx = mat rix->x0;109 xform.eDy = mat rix->y0;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; 110 110 111 111 ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY); -
trunk/WebCore/platform/graphics/win/GraphicsContextWin.cpp
r30500 r30513 27 27 #include "GraphicsContext.h" 28 28 29 #if PLATFORM(CG)30 #include "GraphicsContextPlatformPrivateCG.h"31 #elif PLATFORM(CAIRO)32 #include "GraphicsContextPlatformPrivateCairo.h"33 #endif34 35 29 #include "AffineTransform.h" 36 30 #include "NotImplemented.h" … … 44 38 class SVGResourceImage; 45 39 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/18087 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 117 40 #if ENABLE(SVG) 118 41 GraphicsContext* contextForImage(SVGResourceImage*) -
trunk/WebCore/platform/win/DragImageCairoWin.cpp
r30500 r30513 48 48 notImplemented(); 49 49 50 return 0; 50 DragImageRef temp; 51 return temp; 51 52 } 52 53
Note: See TracChangeset
for help on using the changeset viewer.