Changeset 82962 in webkit
- Timestamp:
- Apr 5, 2011 11:40:21 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 28 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r82956 r82962 1 2011-04-05 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Eric Seidel. 4 5 [Cairo] Better separate the concerns of GraphicsContextCairo 6 https://bugs.webkit.org/show_bug.cgi?id=55150 7 8 Add a PlatformContextCairo which right now stores the cairo_t* for a 9 GraphicsContextCairo. Later patches will move logic for tracking ContextShadow 10 and image masking layers into this PlatformContextCairo class. 11 12 No new tests. This patch is only a code cleanup. 13 14 * GNUmakefile.am: 15 * platform/graphics/GraphicsContext.h: The platform context is no longer a 16 cairo_t, but our new class the PlatformContextCairo. 17 * platform/graphics/cairo/ContextShadowCairo.cpp: Updated to reflect new class.j 18 * platform/graphics/cairo/FontCairo.cpp: Ditto. 19 * platform/graphics/cairo/GradientCairo.cpp: Ditto. 20 * platform/graphics/cairo/GraphicsContextCairo.cpp: Mostly mechanical 21 changes which now reference platformContext()->cr() to get the cairo_t. 22 * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Now hold the 23 PlatformContextCairo instead of the cairo_t. 24 * platform/graphics/cairo/ImageBufferCairo.cpp: Update to reflect new class. 25 * platform/graphics/cairo/ImageCairo.cpp: Ditto. 26 * platform/graphics/cairo/PathCairo.cpp: Ditto. 27 * platform/graphics/cairo/PlatformContextCairo.cpp: Added. 28 * platform/graphics/cairo/PlatformContextCairo.h: Added. 29 * platform/graphics/gtk/FontGtk.cpp: Update to reflect new class. 30 * platform/graphics/gtk/IconGtk.cpp: Ditto. 31 * platform/graphics/win/GraphicsContextCairoWin.cpp: Now fill out 32 m_data with a private section containing the platform context instead of 33 just a cairo_t. 34 * platform/gtk/RenderThemeGtk.cpp: Update to reflect new class. 35 * platform/gtk/WidgetRenderingContext.cpp: Ditto. 36 (WebCore::WidgetRenderingContext::~WidgetRenderingContext): Ditto. 37 * plugins/gtk/PluginViewGtk.cpp: Ditto. 38 1 39 2011-04-05 David Dorwin <ddorwin@chromium.org> 2 40 -
trunk/Source/WebCore/GNUmakefile.am
r82899 r82962 3775 3775 Source/WebCore/platform/graphics/cairo/PathCairo.cpp \ 3776 3776 Source/WebCore/platform/graphics/cairo/PatternCairo.cpp \ 3777 Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp \ 3778 Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h \ 3777 3779 Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp \ 3778 3780 Source/WebCore/platform/graphics/cairo/RefPtrCairo.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r82899 r82962 28629 28629 </File> 28630 28630 <File 28631 RelativePath="..\platform\graphics\cairo\PlatformContextCairo.cpp" 28632 > 28633 <FileConfiguration 28634 Name="Debug|Win32" 28635 ExcludedFromBuild="true" 28636 > 28637 <Tool 28638 Name="VCCLCompilerTool" 28639 /> 28640 </FileConfiguration> 28641 <FileConfiguration 28642 Name="Release|Win32" 28643 ExcludedFromBuild="true" 28644 > 28645 <Tool 28646 Name="VCCLCompilerTool" 28647 /> 28648 </FileConfiguration> 28649 <FileConfiguration 28650 Name="Debug_All|Win32" 28651 ExcludedFromBuild="true" 28652 > 28653 <Tool 28654 Name="VCCLCompilerTool" 28655 /> 28656 </FileConfiguration> 28657 <FileConfiguration 28658 Name="Production|Win32" 28659 ExcludedFromBuild="true" 28660 > 28661 <Tool 28662 Name="VCCLCompilerTool" 28663 /> 28664 </FileConfiguration> 28665 </File> 28666 <File 28631 28667 RelativePath="..\platform\graphics\cairo\RefPtrCairo.cpp" 28632 28668 > -
trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp
r82561 r82962 35 35 #include "PaintInfo.h" 36 36 #include "Page.h" 37 #include "PlatformContextCairo.h" 37 38 #include "RenderBox.h" 38 39 #include "RenderObject.h" … … 284 285 applyEdjeStateFromForm(entry->o, controlStatesForRenderer(object)); 285 286 286 cairo = info.context->platformContext() ;287 cairo = info.context->platformContext()->cr(); 287 288 ASSERT(cairo); 288 289 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r82640 r82962 43 43 namespace WebCore { 44 44 class ContextShadow; 45 class PlatformContextCairo; 45 46 } 46 typedef struct _cairo PlatformGraphicsContext;47 typedef WebCore::PlatformContextCairo PlatformGraphicsContext; 47 48 #elif PLATFORM(OPENVG) 48 49 namespace WebCore { … … 491 492 492 493 #if PLATFORM(CAIRO) 494 GraphicsContext(cairo_t*); 493 495 void pushImageMask(cairo_surface_t*, const FloatRect&); 494 496 #endif -
trunk/Source/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
r82553 r82962 35 35 #include "OwnPtrCairo.h" 36 36 #include "Path.h" 37 #include "PlatformContextCairo.h" 37 38 #include "Timer.h" 38 39 #include <cairo.h> … … 89 90 90 91 double x1, x2, y1, y2; 91 cairo_clip_extents(context->platformContext() , &x1, &y1, &x2, &y2);92 cairo_clip_extents(context->platformContext()->cr(), &x1, &y1, &x2, &y2); 92 93 IntRect layerRect = calculateLayerBoundingRect(context, layerArea, IntRect(x1, y1, x2 - x1, y2 - y1)); 93 94 … … 121 122 } 122 123 123 cairo_t* cr = context->platformContext() ;124 cairo_t* cr = context->platformContext()->cr(); 124 125 cairo_save(cr); 125 126 setSourceRGBAFromColor(cr, m_color); … … 199 200 max(bottomLeftRadius.height(), bottomRightRadius.height()); 200 201 201 cairo_t* cr = context->platformContext() ;202 cairo_t* cr = context->platformContext()->cr(); 202 203 203 204 // drawShadowedRect still does not work with rotations. -
trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
r82553 r82962 37 37 #include "Gradient.h" 38 38 #include "GraphicsContext.h" 39 #include "PlatformContextCairo.h" 39 40 #include "ImageBuffer.h" 40 41 #include "Pattern.h" … … 65 66 } 66 67 67 static void drawGlyphsShadow(GraphicsContext* graphicsContext, c airo_t* context, const FloatPoint& point, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs)68 static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs) 68 69 { 69 70 ContextShadow* shadow = graphicsContext->contextShadow(); … … 75 76 if (!shadow->mustUseContextShadow(graphicsContext)) { 76 77 // Optimize non-blurry shadows, by just drawing text without the ContextShadow. 78 cairo_t* context = graphicsContext->platformContext()->cr(); 77 79 cairo_save(context); 78 80 cairo_translate(context, shadow->m_offset.width(), shadow->m_offset.height()); … … 107 109 } 108 110 109 cairo_t* cr= context->platformContext();110 drawGlyphsShadow(context, cr,point, font, glyphs, numGlyphs);111 PlatformContextCairo* platformContext = context->platformContext(); 112 drawGlyphsShadow(context, point, font, glyphs, numGlyphs); 111 113 114 cairo_t* cr = platformContext->cr(); 112 115 cairo_save(cr); 113 116 prepareContextForGlyphDrawing(cr, font, point); -
trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
r82553 r82962 30 30 #include "CSSParser.h" 31 31 #include "GraphicsContext.h" 32 #include "PlatformContextCairo.h" 32 33 #include <cairo.h> 33 34 … … 88 89 void Gradient::fill(GraphicsContext* context, const FloatRect& rect) 89 90 { 90 cairo_t* cr = context->platformContext() ;91 cairo_t* cr = context->platformContext()->cr(); 91 92 92 93 context->save(); -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r82553 r82962 48 48 #include "Path.h" 49 49 #include "Pattern.h" 50 #include "PlatformContextCairo.h" 50 51 #include "RefPtrCairo.h" 51 52 #include "SimpleFontData.h" … … 149 150 150 151 // Calculate the extents of the rendered solid paths. 151 cairo_t* cairoContext = context->platformContext() ;152 cairo_t* cairoContext = context->platformContext()->cr(); 152 153 OwnPtr<cairo_path_t> path(cairo_copy_path(cairoContext)); 153 154 … … 200 201 } 201 202 202 void GraphicsContext::platformInit(PlatformGraphicsContext* cr) 203 { 204 m_data = new GraphicsContextPlatformPrivate; 205 m_data->cr = cairo_reference(cr); 206 m_data->syncContext(cr); 207 setPaintingDisabled(!cr); 203 GraphicsContext::GraphicsContext(cairo_t* cr) 204 : m_updatingControlTints(false) 205 { 206 m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr)); 207 } 208 209 void GraphicsContext::platformInit(PlatformContextCairo* platformContext) 210 { 211 m_data = new GraphicsContextPlatformPrivate(platformContext); 212 if (platformContext) 213 m_data->syncContext(platformContext->cr()); 214 else 215 setPaintingDisabled(true); 208 216 } 209 217 … … 215 223 AffineTransform GraphicsContext::getCTM() const 216 224 { 217 cairo_t* cr = platformContext() ;225 cairo_t* cr = platformContext()->cr(); 218 226 cairo_matrix_t m; 219 227 cairo_get_matrix(cr, &m); … … 221 229 } 222 230 223 cairo_t* GraphicsContext::platformContext() const224 { 225 return m_data-> cr;231 PlatformContextCairo* GraphicsContext::platformContext() const 232 { 233 return m_data->platformContext; 226 234 } 227 235 228 236 void GraphicsContext::savePlatformState() 229 237 { 230 cairo_save( m_data->cr);238 cairo_save(platformContext()->cr()); 231 239 m_data->save(); 232 240 m_data->shadowStack.append(m_data->shadow); … … 236 244 void GraphicsContext::restorePlatformState() 237 245 { 238 cairo_t* cr = m_data->cr; 246 cairo_t* cr = platformContext()->cr(); 247 239 248 const ImageMaskInformation& maskInformation = m_data->maskImageStack.last(); 240 249 if (maskInformation.isValid()) { … … 252 261 } 253 262 254 cairo_restore( m_data->cr);263 cairo_restore(cr); 255 264 m_data->restore(); 256 265 } … … 262 271 return; 263 272 264 cairo_t* cr = m_data->cr;273 cairo_t* cr = platformContext()->cr(); 265 274 cairo_save(cr); 266 275 … … 290 299 return; 291 300 292 cairo_t* cr = m_data->cr;301 cairo_t* cr = platformContext()->cr(); 293 302 cairo_save(cr); 294 303 … … 377 386 return; 378 387 379 cairo_t* cr = m_data->cr;388 cairo_t* cr = platformContext()->cr(); 380 389 cairo_save(cr); 381 390 float yRadius = .5 * rect.height(); … … 416 425 float falen = fa + angleSpan; 417 426 418 cairo_t* cr = m_data->cr;427 cairo_t* cr = platformContext()->cr(); 419 428 cairo_save(cr); 420 429 … … 493 502 return; 494 503 495 cairo_t* cr = m_data->cr;504 cairo_t* cr = platformContext()->cr(); 496 505 497 506 cairo_save(cr); … … 523 532 return; 524 533 525 cairo_t* cr = m_data->cr;534 cairo_t* cr = platformContext()->cr(); 526 535 527 536 cairo_new_path(cr); … … 543 552 return; 544 553 545 cairo_t* cr = m_data->cr;554 cairo_t* cr = platformContext()->cr(); 546 555 setPathOnCairoContext(cr, path.platformPath()->context()); 547 556 fillCurrentCairoPath(this, cr); … … 553 562 return; 554 563 555 cairo_t* cr = m_data->cr;564 cairo_t* cr = platformContext()->cr(); 556 565 setPathOnCairoContext(cr, path.platformPath()->context()); 557 566 strokeCurrentCairoPath(this, cr); … … 563 572 return; 564 573 565 cairo_t* cr = m_data->cr;574 cairo_t* cr = platformContext()->cr(); 566 575 cairo_save(cr); 567 576 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); … … 579 588 580 589 if (color.alpha()) 581 fillRectSourceOver( m_data->cr, rect, color);590 fillRectSourceOver(platformContext()->cr(), rect, color); 582 591 } 583 592 … … 587 596 return; 588 597 589 cairo_t* cr = m_data->cr;598 cairo_t* cr = platformContext()->cr(); 590 599 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 591 600 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); … … 601 610 return; 602 611 603 cairo_t* cr = m_data->cr;612 cairo_t* cr = platformContext()->cr(); 604 613 setPathOnCairoContext(cr, path.platformPath()->context()); 605 614 cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); … … 639 648 adjustFocusRingLineWidth(width); 640 649 641 cairo_t* cr = m_data->cr;650 cairo_t* cr = platformContext()->cr(); 642 651 cairo_save(cr); 643 652 appendWebCorePathToCairoContext(cr, path); … … 656 665 unsigned rectCount = rects.size(); 657 666 658 cairo_t* cr = m_data->cr;667 cairo_t* cr = platformContext()->cr(); 659 668 cairo_save(cr); 660 669 cairo_push_group(cr); … … 733 742 return; 734 743 735 cairo_t* cr = m_data->cr;744 cairo_t* cr = platformContext()->cr(); 736 745 cairo_save(cr); 737 746 … … 763 772 double x = frect.x(); 764 773 double y = frect.y(); 765 cairo_t* cr = m_data->cr;774 cairo_t* cr = platformContext()->cr(); 766 775 cairo_user_to_device(cr, &x, &y); 767 776 x = round(x); … … 800 809 return; 801 810 802 cairo_t* cr = m_data->cr;811 cairo_t* cr = platformContext()->cr(); 803 812 cairo_translate(cr, x, y); 804 813 m_data->translate(x, y); … … 822 831 return; 823 832 824 cairo_set_line_width( m_data->cr, strokeThickness);833 cairo_set_line_width(platformContext()->cr(), strokeThickness); 825 834 } 826 835 … … 836 845 case NoStroke: 837 846 // FIXME: is it the right way to emulate NoStroke? 838 cairo_set_line_width( m_data->cr, 0);847 cairo_set_line_width(platformContext()->cr(), 0); 839 848 break; 840 849 case SolidStroke: 841 cairo_set_dash( m_data->cr, 0, 0, 0);850 cairo_set_dash(platformContext()->cr(), 0, 0, 0); 842 851 break; 843 852 case DottedStroke: 844 cairo_set_dash( m_data->cr, dotPattern, 2, 0);853 cairo_set_dash(platformContext()->cr(), dotPattern, 2, 0); 845 854 break; 846 855 case DashedStroke: 847 cairo_set_dash( m_data->cr, dashPattern, 2, 0);856 cairo_set_dash(platformContext()->cr(), dashPattern, 2, 0); 848 857 break; 849 858 } … … 860 869 return; 861 870 862 cairo_t* cr = m_data->cr;871 cairo_t* cr = platformContext()->cr(); 863 872 const cairo_matrix_t matrix = cairo_matrix_t(transform); 864 873 cairo_transform(cr, &matrix); … … 871 880 return; 872 881 873 cairo_t* cr = m_data->cr;882 cairo_t* cr = platformContext()->cr(); 874 883 const cairo_matrix_t matrix = cairo_matrix_t(transform); 875 884 cairo_set_matrix(cr, &matrix); … … 882 891 return; 883 892 884 cairo_t* cr = m_data->cr;893 cairo_t* cr = platformContext()->cr(); 885 894 clip(rect); 886 895 … … 929 938 return; 930 939 931 cairo_t* cr = m_data->cr;940 cairo_t* cr = platformContext()->cr(); 932 941 cairo_push_group(cr); 933 942 m_data->layers.append(opacity); … … 940 949 return; 941 950 942 cairo_t* cr = m_data->cr;951 cairo_t* cr = platformContext()->cr(); 943 952 944 953 cairo_pop_group_to_source(cr); … … 953 962 return; 954 963 955 cairo_t* cr = m_data->cr;964 cairo_t* cr = platformContext()->cr(); 956 965 957 966 cairo_save(cr); … … 967 976 return; 968 977 969 cairo_t* cr = m_data->cr;978 cairo_t* cr = platformContext()->cr(); 970 979 cairo_save(cr); 971 980 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); … … 992 1001 break; 993 1002 } 994 cairo_set_line_cap( m_data->cr, cairoCap);1003 cairo_set_line_cap(platformContext()->cr(), cairoCap); 995 1004 } 996 1005 997 1006 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) 998 1007 { 999 cairo_set_dash( m_data->cr, dashes.data(), dashes.size(), dashOffset);1008 cairo_set_dash(platformContext()->cr(), dashes.data(), dashes.size(), dashOffset); 1000 1009 } 1001 1010 … … 1017 1026 break; 1018 1027 } 1019 cairo_set_line_join( m_data->cr, cairoJoin);1028 cairo_set_line_join(platformContext()->cr(), cairoJoin); 1020 1029 } 1021 1030 … … 1025 1034 return; 1026 1035 1027 cairo_set_miter_limit( m_data->cr, miter);1036 cairo_set_miter_limit(platformContext()->cr(), miter); 1028 1037 } 1029 1038 … … 1043 1052 return; 1044 1053 1045 cairo_set_operator( m_data->cr, toCairoOperator(op));1054 cairo_set_operator(platformContext()->cr(), toCairoOperator(op)); 1046 1055 } 1047 1056 … … 1051 1060 return; 1052 1061 1053 cairo_t* cr = m_data->cr;1062 cairo_t* cr = platformContext()->cr(); 1054 1063 OwnPtr<cairo_path_t> p(cairo_copy_path(path.platformPath()->context())); 1055 1064 cairo_append_path(cr, p.get()); … … 1071 1080 return; 1072 1081 1073 cairo_t* cr = m_data->cr;1082 cairo_t* cr = platformContext()->cr(); 1074 1083 double x1, y1, x2, y2; 1075 1084 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); … … 1088 1097 return; 1089 1098 1090 cairo_rotate( m_data->cr, radians);1099 cairo_rotate(platformContext()->cr(), radians); 1091 1100 m_data->rotate(radians); 1092 1101 } … … 1097 1106 return; 1098 1107 1099 cairo_scale( m_data->cr, size.width(), size.height());1108 cairo_scale(platformContext()->cr(), size.width(), size.height()); 1100 1109 m_data->scale(size); 1101 1110 } … … 1106 1115 return; 1107 1116 1108 cairo_t* cr = m_data->cr;1117 cairo_t* cr = platformContext()->cr(); 1109 1118 double x1, y1, x2, y2; 1110 1119 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); … … 1133 1142 m_data->shadow.drawRectShadow(this, r, topLeft, topRight, bottomLeft, bottomRight); 1134 1143 1135 cairo_t* cr = m_data->cr;1144 cairo_t* cr = platformContext()->cr(); 1136 1145 cairo_save(cr); 1137 1146 Path path; … … 1171 1180 // enables standard 'grayscale' antialiasing); false to explicitly disable 1172 1181 // antialiasing. This is the same strategy as used in drawConvexPolygon(). 1173 cairo_set_antialias( m_data->cr, enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);1182 cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); 1174 1183 } 1175 1184 … … 1197 1206 // is now, but they are isolated in another group. To make this work, we're 1198 1207 // going to blit the current surface contents onto the new group once we push it. 1199 cairo_t* cr = m_data->cr;1208 cairo_t* cr = platformContext()->cr(); 1200 1209 cairo_surface_t* currentTarget = cairo_get_target(cr); 1201 1210 cairo_surface_flush(currentTarget); -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r82553 r82962 32 32 33 33 #include "ContextShadow.h" 34 #include "PlatformContextCairo.h" 34 35 #include "RefPtrCairo.h" 35 36 #include <cairo.h> … … 68 69 class GraphicsContextPlatformPrivate { 69 70 public: 70 GraphicsContextPlatformPrivate( )71 : cr(0)71 GraphicsContextPlatformPrivate(PlatformContextCairo* newPlatformContext) 72 : platformContext(newPlatformContext) 72 73 #if PLATFORM(GTK) 73 74 , expose(0) … … 81 82 } 82 83 83 ~GraphicsContextPlatformPrivate()84 virtual ~GraphicsContextPlatformPrivate() 84 85 { 85 cairo_destroy(cr);86 86 } 87 87 … … 100 100 void beginTransparencyLayer() { m_transparencyCount++; } 101 101 void endTransparencyLayer() { m_transparencyCount--; } 102 void syncContext( PlatformGraphicsContext* cr);102 void syncContext(cairo_t* cr); 103 103 #else 104 104 // On everything else, we do nothing. … … 115 115 void beginTransparencyLayer() {} 116 116 void endTransparencyLayer() {} 117 void syncContext( PlatformGraphicsContext* cr) {}117 void syncContext(cairo_t* cr) {} 118 118 #endif 119 119 120 cairo_t* cr;120 PlatformContextCairo* platformContext; 121 121 Vector<float> layers; 122 123 122 ContextShadow shadow; 124 123 Vector<ContextShadow> shadowStack; … … 134 133 }; 135 134 135 // This is a specialized private section for the Cairo GraphicsContext, which knows how 136 // to clean up the heap allocated PlatformContextCairo that we must use for the top-level 137 // GraphicsContext. 138 class GraphicsContextPlatformPrivateToplevel : public GraphicsContextPlatformPrivate { 139 public: 140 GraphicsContextPlatformPrivateToplevel(PlatformContextCairo* platformContext) 141 : GraphicsContextPlatformPrivate(platformContext) 142 { 143 } 144 145 virtual ~GraphicsContextPlatformPrivateToplevel() 146 { 147 delete platformContext; 148 } 149 }; 150 151 136 152 } // namespace WebCore 137 153 -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r82553 r82962 38 38 #include "NotImplemented.h" 39 39 #include "Pattern.h" 40 #include "PlatformContextCairo.h" 40 41 #include "PlatformString.h" 42 #include "RefPtrCairo.h" 41 43 #include <cairo.h> 42 44 #include <wtf/Vector.h> … … 67 69 ImageBufferData::ImageBufferData(const IntSize& size) 68 70 : m_surface(0) 71 , m_platformContext(0) 69 72 { 70 73 } … … 81 84 return; // create will notice we didn't set m_initialized and fail. 82 85 83 cairo_t* cr = cairo_create(m_data.m_surface);84 m_ context.set(new GraphicsContext(cr));85 cairo_destroy(cr); // The context is now owned by the GraphicsContext.86 RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface)); 87 m_data.m_platformContext.setCr(cr.get()); 88 m_context.set(new GraphicsContext(&m_data.m_platformContext)); 86 89 success = true; 87 90 } … … 302 305 String ImageBuffer::toDataURL(const String& mimeType, const double*) const 303 306 { 304 cairo_surface_t* image = cairo_get_target(context()->platformContext() );307 cairo_surface_t* image = cairo_get_target(context()->platformContext()->cr()); 305 308 if (!image) 306 309 return "data:,"; -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferData.h
r82553 r82962 27 27 #define ImageBufferData_h 28 28 29 #include "cairo.h" 29 #include "PlatformContextCairo.h" 30 31 typedef struct _cairo_surface cairo_surface_t; 30 32 31 33 namespace WebCore { … … 38 40 39 41 cairo_surface_t* m_surface; 42 PlatformContextCairo m_platformContext; 40 43 }; 41 44 -
trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
r82553 r82962 37 37 #include "FloatRect.h" 38 38 #include "GraphicsContext.h" 39 #include "PlatformContextCairo.h" 39 40 #include "ImageBuffer.h" 40 41 #include "ImageObserver.h" … … 115 116 IntSize selfSize = size(); 116 117 117 cairo_t* cr = context->platformContext() ;118 cairo_t* cr = context->platformContext()->cr(); 118 119 context->save(); 119 120 … … 170 171 return; 171 172 172 cairo_t* cr = context->platformContext(); 173 173 cairo_t* cr = context->platformContext()->cr(); 174 174 drawPatternToCairoContext(cr, image, size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect); 175 175 -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
r82961 r82962 1 1 /* 2 * Copyright (C) 20 08 Google Inc. All rights reserved.2 * Copyright (C) 2011 Igalia S.L. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #i fndef ImageBufferData_h27 # define ImageBufferData_h26 #include "config.h" 27 #include "PlatformContextCairo.h" 28 28 29 #include "cairo.h"29 #include <cairo.h> 30 30 31 31 namespace WebCore { 32 32 33 class IntSize; 33 PlatformContextCairo::PlatformContextCairo(cairo_t* cr) 34 : m_cr(cr) 35 { 36 } 34 37 35 class ImageBufferData { 36 public: 37 ImageBufferData(const IntSize&); 38 39 cairo_surface_t* m_surface; 40 }; 41 42 } // namespace WebCore 43 44 #endif // ImageBufferData_h 38 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h
r82961 r82962 1 1 /* 2 * Copyright (C) 20 08 Google Inc. All rights reserved.2 * Copyright (C) 2011 Igalia S.L. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #ifndef ImageBufferData_h27 #define ImageBufferData_h26 #ifndef PlatformContextCairo_h 27 #define PlatformContextCairo_h 28 28 29 #include "cairo.h" 29 #include "ContextShadow.h" 30 #include "RefPtrCairo.h" 30 31 31 32 namespace WebCore { 32 33 33 class IntSize; 34 // Much like PlatformContextSkia in the Skia port, this class holds information that 35 // would normally be private to GraphicsContext, except that we want to allow access 36 // to it in Font and Image code. This allows us to separate the concerns of Cairo-specific 37 // code from the platform-independent GraphicsContext. 34 38 35 class ImageBufferData { 39 class PlatformContextCairo { 40 WTF_MAKE_NONCOPYABLE(PlatformContextCairo); 36 41 public: 37 ImageBufferData(const IntSize&); 42 PlatformContextCairo(cairo_t*); 43 cairo_t* cr() { return m_cr.get(); } 44 void setCr(cairo_t* cr) { m_cr = cr; } 38 45 39 cairo_surface_t* m_surface; 46 private: 47 RefPtr<cairo_t> m_cr; 40 48 }; 41 49 42 } 50 } // namespace WebCore 43 51 44 #endif // ImageBufferData_h52 #endif // PlatformContextCairo_h -
trunk/Source/WebCore/platform/graphics/gtk/FontGtk.cpp
r82772 r82962 39 39 #include "GraphicsContext.h" 40 40 #include "NotImplemented.h" 41 #include "PlatformContextCairo.h" 41 42 #include "SimpleFontData.h" 42 43 #include "TextRun.h" … … 218 219 } 219 220 220 static void drawGlyphsShadow(GraphicsContext* graphicsContext, c airo_t* context, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)221 static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion) 221 222 { 222 223 ContextShadow* shadow = graphicsContext->contextShadow(); … … 230 231 // Optimize non-blurry shadows, by just drawing text without the ContextShadow. 231 232 if (!shadow->mustUseContextShadow(graphicsContext)) { 233 cairo_t* context = graphicsContext->platformContext()->cr(); 232 234 cairo_save(context); 233 235 cairo_translate(context, totalOffset.x(), totalOffset.y()); … … 253 255 // drawn. Since ContextShadow expects a consistent transform, we have to undo the 254 256 // translation before calling endShadowLayer as well. 257 cairo_t* context = graphicsContext->platformContext()->cr(); 255 258 cairo_save(context); 256 259 cairo_translate(context, totalOffset.x(), totalOffset.y()); … … 273 276 #endif 274 277 275 cairo_t* cr = context->platformContext() ;278 cairo_t* cr = context->platformContext()->cr(); 276 279 PangoLayout* layout = pango_cairo_create_layout(cr); 277 280 setPangoAttributes(this, run, layout); … … 292 295 partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1); 293 296 294 drawGlyphsShadow(context, cr,point, layoutLine, partialRegion);297 drawGlyphsShadow(context, point, layoutLine, partialRegion); 295 298 296 299 cairo_save(cr); -
trunk/Source/WebCore/platform/graphics/gtk/IconGtk.cpp
r82553 r82962 34 34 #include "MIMETypeRegistry.h" 35 35 #include "PassRefPtr.h" 36 #include "PlatformContextCairo.h" 37 #include <gtk/gtk.h> 36 38 #include <wtf/text/CString.h> 37 38 #include <gtk/gtk.h>39 39 40 40 namespace WebCore { … … 118 118 119 119 // TODO: Scale/clip the image if necessary. 120 cairo_t* cr = context->platformContext() ;120 cairo_t* cr = context->platformContext()->cr(); 121 121 cairo_save(cr); 122 122 gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y()); -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
r82640 r82962 73 73 void GraphicsContext::platformInit(HDC dc, bool hasAlpha) 74 74 { 75 m_data = new GraphicsContextPlatformPrivate; 75 cairo_t* cr = 0; 76 if (dc) 77 cr = createCairoContextWithHDC(dc, hasAlpha); 78 else 79 setPaintingDisabled(true); 76 80 77 if (dc) { 78 m_data->cr = createCairoContextWithHDC(dc, hasAlpha); 79 m_data->m_hdc = dc; 80 } else { 81 setPaintingDisabled(true); 82 m_data->cr = 0; 83 m_data->m_hdc = 0; 84 } 85 86 if (m_data->cr) { 81 m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr)); 82 m_data->m_hdc = dc; 83 if (platformContext()->cr()) { 87 84 // Make sure the context starts in sync with our state. 88 85 setPlatformFillColor(fillColor(), fillColorSpace()); … … 97 94 } 98 95 99 static void drawBitmapToContext(GraphicsContextPlatformPrivate* context, c onst DIBPixelData& pixelData, const IntSize& translate)96 static void drawBitmapToContext(GraphicsContextPlatformPrivate* context, cairo_t* cr, const DIBPixelData& pixelData, const IntSize& translate) 100 97 { 101 98 // Need to make a cairo_surface_t out of the bitmap's pixel buffer and then draw … … 109 106 // Flip the target surface so that when we set the srcImage as 110 107 // the surface it will draw right-side-up. 111 cairo_save(c ontext->cr);112 cairo_translate(c ontext->cr, static_cast<double>(translate.width()), static_cast<double>(translate.height()));113 cairo_scale(c ontext->cr, 1, -1);114 cairo_set_source_surface(c ontext->cr, surface, 0, 0);108 cairo_save(cr); 109 cairo_translate(cr, static_cast<double>(translate.width()), static_cast<double>(translate.height())); 110 cairo_scale(cr, 1, -1); 111 cairo_set_source_surface(cr, surface, 0, 0); 115 112 116 113 if (context->layers.size()) 117 cairo_paint_with_alpha(c ontext->cr, context->layers.last());114 cairo_paint_with_alpha(cr, context->layers.last()); 118 115 else 119 cairo_paint(c ontext->cr);116 cairo_paint(cr); 120 117 121 118 // Delete all our junk. 122 119 cairo_surface_destroy(surface); 123 cairo_restore(c ontext->cr);120 cairo_restore(cr); 124 121 } 125 122 … … 147 144 setRGBABitmapAlpha(bytes, pixelData.size().height() * pixelData.bytesPerRow(), 255); 148 145 149 drawBitmapToContext(m_data, p ixelData, IntSize(dstRect.x(), dstRect.height() + dstRect.y()));146 drawBitmapToContext(m_data, platformContext()->cr(), pixelData, IntSize(dstRect.x(), dstRect.height() + dstRect.y())); 150 147 151 148 ::DeleteDC(hdc); … … 154 151 void GraphicsContext::drawWindowsBitmap(WindowsBitmap* bitmap, const IntPoint& point) 155 152 { 156 drawBitmapToContext(m_data, bitmap->windowsDIB(), IntSize(point.x(), bitmap->size().height() + point.y()));153 drawBitmapToContext(m_data, platformContext()->cr(), bitmap->windowsDIB(), IntSize(point.x(), bitmap->size().height() + point.y())); 157 154 } 158 155 159 void GraphicsContextPlatformPrivate::syncContext( PlatformGraphicsContext* cr)156 void GraphicsContextPlatformPrivate::syncContext(cairo_t* cr) 160 157 { 161 158 if (!cr) -
trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp
r82553 r82962 35 35 #include "MediaControlElements.h" 36 36 #include "PaintInfo.h" 37 #include "PlatformContextCairo.h" 37 38 #include "RenderBox.h" 38 39 #include "RenderObject.h" … … 235 236 } 236 237 237 cairo_t* cr = context->platformContext() ;238 cairo_t* cr = context->platformContext()->cr(); 238 239 cairo_save(cr); 239 240 gdk_cairo_set_source_pixbuf(cr, icon, iconRect.x(), iconRect.y()); -
trunk/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp
r82553 r82962 34 34 #include "GraphicsContext.h" 35 35 #include "GtkVersioning.h" 36 #include "PlatformContextCairo.h" 36 37 #include "RefPtrCairo.h" 37 38 #include "RenderThemeGtk.h" … … 129 130 130 131 // FIXME: It's unclear if it is necessary to preserve the current source here. 131 cairo_t* cairoContext = m_graphicsContext->platformContext() ;132 cairo_t* cairoContext = m_graphicsContext->platformContext()->cr(); 132 133 RefPtr<cairo_pattern_t> previousSource(cairo_get_source(cairoContext)); 133 134 -
trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp
r82553 r82962 30 30 #include "CachedImage.h" 31 31 #include "GraphicsContext.h" 32 #include "GraphicsContextPlatformPrivateCairo.h" 32 33 #include "Image.h" 33 34 #include "RetainPtr.h" 34 35 35 #include <cairo-win32.h> 36 #include "GraphicsContextPlatformPrivateCairo.h"37 38 36 #include <windows.h> 39 40 extern "C" {41 typedef struct _cairo* CairoContextRef;42 }43 37 44 38 namespace WebCore { 45 39 46 void deallocContext( CairoContextReftarget)40 void deallocContext(PlatformContextCairo* target) 47 41 { 48 cairo_destroy(target);42 delete target; 49 43 } 50 44 51 HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef)45 HBITMAP allocImage(HDC dc, IntSize size, PlatformContextCairo** targetRef) 52 46 { 53 47 BitmapInfo bmpInfo = BitmapInfo::create(size); … … 73 67 } 74 68 75 *targetRef = cairo_create(bitmapContext);76 cairo_surface_destroy 69 cairo_t* cr = cairo_create(bitmapContext); 70 cairo_surface_destroy(bitmapContext); 77 71 78 72 // At this point, we have a Cairo surface that points to a Windows DIB. The DIB interprets … … 84 78 cairo_matrix_t matrix; 85 79 cairo_matrix_init(&matrix, 1.0, 0.0, 0.0, -1.0, 0.0, size.height()); 86 cairo_set_matrix(*targetRef, &matrix); 80 cairo_set_matrix(cr, &matrix); 81 82 *targetRef = new PlatformGraphicsContext(cr); 83 cairo_destroy(cr); 87 84 88 85 return hbmp; … … 122 119 goto exit; 123 120 124 CairoContextReftargetContext;121 PlatformContextCairo* targetContext; 125 122 hbmp = allocImage(dstDC, dstSize, &targetContext); 126 123 if (!hbmp) … … 132 129 // so that when we set the srcImage as the surface it will draw 133 130 // right-side-up. 134 cairo_translate(targetContext, 0, dstSize.height()); 135 cairo_scale(targetContext, scale.width(), -scale.height()); 136 cairo_set_source_surface (targetContext, srcImage, 0.0, 0.0); 131 cairo_t* cr = targetContext->cr(); 132 cairo_translate(cr, 0, dstSize.height()); 133 cairo_scale(cr, scale.width(), -scale.height()); 134 cairo_set_source_surface(cr, srcImage, 0.0, 0.0); 137 135 138 136 // Now we can paint and get the correct result 139 cairo_paint( targetContext);137 cairo_paint(cr); 140 138 141 cairo_surface_destroy 142 cairo_destroy(targetContext);139 cairo_surface_destroy(srcImage); 140 deallocContext(targetContext); 143 141 ::DeleteObject(image); 144 142 image = 0; … … 161 159 goto exit; 162 160 163 CairoContextRefdrawContext = 0;161 PlatformContextCairo* drawContext = 0; 164 162 hbmp = allocImage(workingDC, img->size(), &drawContext); 165 163 if (!hbmp) … … 171 169 } 172 170 173 cairo_set_source_rgb (drawContext, 1.0, 0.0, 1.0); 174 cairo_fill_preserve (drawContext); 171 cairo_t* cr = drawContext->cr(); 172 cairo_set_source_rgb(cr, 1.0, 0.0, 1.0); 173 cairo_fill_preserve(cr); 175 174 176 175 cairo_surface_t* srcImage = img->nativeImageForCurrentFrame(); 177 176 178 177 // Draw the image. 179 cairo_set_source_surface( drawContext, srcImage, 0.0, 0.0);180 cairo_paint( drawContext);178 cairo_set_source_surface(cr, srcImage, 0.0, 0.0); 179 cairo_paint(cr); 181 180 182 cairo_destroy(drawContext);181 deallocContext(drawContext); 183 182 184 183 exit: -
trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp
r82833 r82962 49 49 #include "MouseEvent.h" 50 50 #include "Page.h" 51 #include "PlatformContextCairo.h" 51 52 #include "PlatformKeyboardEvent.h" 52 53 #include "PlatformMouseEvent.h" … … 218 219 219 220 // This Would not work without double buffering, but we always use it. 220 cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext() ),221 cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()->cr()), 221 222 -m_windowRect.x(), -m_windowRect.y()); 222 223 cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE); … … 245 246 XSync(m_pluginDisplay, false); // sync changes by plugin 246 247 247 cairo_t* cr = context->platformContext() ;248 cairo_t* cr = context->platformContext()->cr(); 248 249 cairo_save(cr); 249 250 -
trunk/Source/WebCore/plugins/win/PluginViewWin.cpp
r82553 r82962 84 84 85 85 #if PLATFORM(CAIRO) 86 #include "PlatformContextCairo.h" 86 87 #include <cairo-win32.h> 87 88 #endif … … 573 574 // plugin region will be overwritten with any clear regions specified in the 574 575 // cairo-controlled portions of the rendering. 575 PlatformGraphicsContext* ctx = context->platformContext(); 576 cairo_show_page(ctx); 576 cairo_show_page(context->platformContext()->cr()); 577 577 #endif 578 578 -
trunk/Source/WebKit/gtk/ChangeLog
r82952 r82962 1 2011-04-05 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Eric Seidel. 4 5 [Cairo] Better separate the concerns of GraphicsContextCairo 6 https://bugs.webkit.org/show_bug.cgi?id=55150 7 8 Add a PlatformContextCairo which right now stores the cairo_t* for a 9 GraphicsContextCairo. Later patches will move logic for tracking ContextShadow 10 and image masking layers into this PlatformContextCairo class. 11 12 * webkit/webkitwebframe.cpp: 13 (draw_page_callback): 14 * webkit/webkitwebview.cpp: 15 (webkit_web_view_expose_event): 16 (webkit_web_view_draw): 17 1 18 2011-04-04 MORITA Hajime <morrita@google.com> 2 19 -
trunk/Source/WebKit/gtk/webkit/webkitwebframe.cpp
r82553 r82962 45 45 #include "JSDOMWindow.h" 46 46 #include "JSElement.h" 47 #include "PlatformContextCairo.h" 47 48 #include "PrintContext.h" 48 49 #include "RenderListItem.h" … … 766 767 } 767 768 768 static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data) 769 { 770 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); 771 772 if (page_nr >= static_cast<gint>(printContext->pageCount())) 769 static void draw_page_callback(GtkPrintOperation*, GtkPrintContext* gtkPrintContext, gint pageNumber, PrintContext* corePrintContext) 770 { 771 if (pageNumber >= static_cast<gint>(corePrintContext->pageCount())) 773 772 return; 774 773 775 cairo_t* cr = gtk_print_context_get_cairo_context(context); 776 GraphicsContext ctx(cr); 777 float width = gtk_print_context_get_width(context); 778 printContext->spoolPage(ctx, page_nr, width); 774 cairo_t* cr = gtk_print_context_get_cairo_context(gtkPrintContext); 775 float pageWidth = gtk_print_context_get_width(gtkPrintContext); 776 777 PlatformContextCairo platformContext(cr); 778 GraphicsContext graphicsContext(&platformContext); 779 corePrintContext->spoolPage(graphicsContext, pageNumber, pageWidth); 779 780 } 780 781 -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r82878 r82962 670 670 671 671 RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window)); 672 GraphicsContext ctx(cr.get());673 ctx.setGdkExposeEvent(event);672 GraphicsContext gc(cr.get()); 673 gc.setGdkExposeEvent(event); 674 674 675 675 int rectCount; … … 680 680 paintRects.append(IntRect(rects.get()[i])); 681 681 682 paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects);682 paintWebView(frame, priv->transparent, gc, static_cast<IntRect>(event->area), paintRects); 683 683 } 684 684 … … 697 697 Frame* frame = core(webView)->mainFrame(); 698 698 if (frame->contentRenderer() && frame->view()) { 699 GraphicsContext ctx(cr);699 GraphicsContext gc(cr); 700 700 IntRect rect = clipRect; 701 701 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); … … 708 708 rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i]))); 709 709 } 710 paintWebView(frame, priv->transparent, ctx, rect, rects);710 paintWebView(frame, priv->transparent, gc, rect, rects); 711 711 712 712 cairo_rectangle_list_destroy(rectList); -
trunk/Source/WebKit/win/ChangeLog
r82952 r82962 1 2011-04-05 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Eric Seidel. 4 5 [Cairo] Better separate the concerns of GraphicsContextCairo 6 https://bugs.webkit.org/show_bug.cgi?id=55150 7 8 * WebFrame.cpp: 9 (hdcFromContext): Modify this method to take PlatformContextCairo 10 instead of a cairo_t. 11 (WebFrame::spoolPage): Update to reflect new platform context. 12 (WebFrame::spoolPages): Ditto. 13 * WebFrame.h: Ditto. 14 1 15 2011-04-04 MORITA Hajime <morrita@google.com> 2 16 -
trunk/Source/WebKit/win/WebFrame.cpp
r82553 r82962 108 108 #include <CoreGraphics/CoreGraphics.h> 109 109 #elif PLATFORM(CAIRO) 110 #include "PlatformContextCairo.h" 110 111 #include <cairo-win32.h> 111 112 #endif … … 2187 2188 static HDC hdcFromContext(PlatformGraphicsContext* pctx) 2188 2189 { 2189 cairo_surface_t* surface = cairo_get_target(pctx); 2190 return cairo_win32_surface_get_dc(surface); 2190 return cairo_win32_surface_get_dc(cairo_get_target(pctx->cr())); 2191 2191 } 2192 2192 … … 2243 2243 GetWorldTransform(hdc, &original); 2244 2244 2245 cairo_t* cr = pctx->cr(); 2245 2246 bool preview = (hdc != printDC); 2246 2247 if (preview) { … … 2249 2250 // drawing completes so that we can scale our GDI-based header/footer calls. This is a 2250 2251 // workaround for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161) 2251 scaled = buildXFORMFromCairo(hdc, pctx);2252 scaled = buildXFORMFromCairo(hdc, cr); 2252 2253 } 2253 2254 … … 2259 2260 // We cannot scale the display HDC because the print surface also scales fonts, 2260 2261 // resulting in invalid printing (and print preview) 2261 cairo_scale( pctx, scale, scale);2262 cairo_translate( pctx, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);2262 cairo_scale(cr, scale, scale); 2263 cairo_translate(cr, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight); 2263 2264 2264 2265 // Modify Cairo (only) to account for page position. 2265 cairo_translate( pctx, -pageRect.x(), -pageRect.y());2266 cairo_translate(cr, -pageRect.x(), -pageRect.y()); 2266 2267 coreFrame->view()->paintContents(spoolCtx, pageRect); 2267 cairo_translate( pctx, pageRect.x(), pageRect.y());2268 cairo_translate(cr, pageRect.x(), pageRect.y()); 2268 2269 2269 2270 if (preview) { … … 2286 2287 SetWorldTransform(hdc, &original); 2287 2288 2288 cairo_show_page( pctx);2289 ASSERT(!cairo_status( pctx));2289 cairo_show_page(cr); 2290 ASSERT(!cairo_status(cr)); 2290 2291 spoolCtx->restore(); 2291 2292 } … … 2339 2340 printSurface = cairo_win32_printing_surface_create(targetDC); // metafile 2340 2341 2341 PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)cairo_create(printSurface);2342 if (! pctx) {2342 cairo_t* cr = cairo_create(printSurface); 2343 if (!cr) { 2343 2344 cairo_surface_destroy(printSurface); 2344 2345 return E_FAIL; 2345 2346 } 2346 2347 2348 PlatformContextCairo platformContext(cr); 2349 PlatformGraphicsContext* pctx = &platformContext; 2350 cairo_destroy(cr); 2351 2347 2352 if (ctx) { 2348 2353 // If this is a preview, the Windows HDC was sent with scaling information. 2349 2354 // Retrieve it and reset it so that it draws properly. This is a workaround 2350 2355 // for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161) 2351 setCairoTransformToPreviewHDC( pctx, targetDC);2356 setCairoTransformToPreviewHDC(cr, targetDC); 2352 2357 } 2353 2358 … … 2393 2398 2394 2399 #if PLATFORM(CAIRO) 2395 cairo_destroy(pctx);2396 2400 cairo_surface_finish(printSurface); 2397 2401 ASSERT(!cairo_surface_status(printSurface)); -
trunk/Source/WebKit/win/WebFrame.h
r82553 r82962 63 63 typedef struct CGContext PlatformGraphicsContext; 64 64 #elif PLATFORM(CAIRO) 65 typedef struct _cairo PlatformGraphicsContext; 65 namespace WebCore { 66 class PlatformContextCairo; 67 } 68 typedef class WebCore::PlatformContextCairo PlatformGraphicsContext; 66 69 #endif 67 70 -
trunk/Source/WebKit2/Shared/WebGraphicsContext.cpp
r82553 r82962 27 27 #include "WebGraphicsContext.h" 28 28 29 #if PLATFORM(GTK) 30 #include <WebCore/PlatformContextCairo.h> 31 #endif 32 29 33 using namespace WebCore; 30 34 … … 35 39 : m_platformContext(graphicsContext->platformContext()) 36 40 #elif PLATFORM(GTK) 37 : m_platformContext(graphicsContext->platformContext() )41 : m_platformContext(graphicsContext->platformContext()->cr()) 38 42 #endif 39 43 {
Note: See TracChangeset
for help on using the changeset viewer.