Changeset 82496 in webkit
- Timestamp:
- Mar 30, 2011 1:56:40 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r82494 r82496 1 2011-03-30 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Dirk Schulze. 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-03-30 Patrick Gansterer <paroga@webkit.org> 2 40 -
trunk/Source/WebCore/GNUmakefile.am
r82465 r82496 3761 3761 Source/WebCore/platform/graphics/cairo/PathCairo.cpp \ 3762 3762 Source/WebCore/platform/graphics/cairo/PatternCairo.cpp \ 3763 Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp \ 3764 Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h \ 3763 3765 Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp \ 3764 3766 Source/WebCore/platform/graphics/cairo/RefPtrCairo.h \ -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r81161 r82496 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
r75237 r82496 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
r74947 r82496 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
r60760 r82496 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
r79592 r82496 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 { 205 m_data = new GraphicsContextPlatformPrivate(new PlatformContextCairo(cr)); 206 } 207 208 void GraphicsContext::platformInit(PlatformContextCairo* platformContext) 209 { 210 m_data = new GraphicsContextPlatformPrivate(platformContext); 211 if (platformContext) 212 m_data->syncContext(platformContext->cr()); 213 else 214 setPaintingDisabled(true); 208 215 } 209 216 … … 215 222 AffineTransform GraphicsContext::getCTM() const 216 223 { 217 cairo_t* cr = platformContext() ;224 cairo_t* cr = platformContext()->cr(); 218 225 cairo_matrix_t m; 219 226 cairo_get_matrix(cr, &m); … … 221 228 } 222 229 223 cairo_t* GraphicsContext::platformContext() const224 { 225 return m_data-> cr;230 PlatformContextCairo* GraphicsContext::platformContext() const 231 { 232 return m_data->platformContext; 226 233 } 227 234 228 235 void GraphicsContext::savePlatformState() 229 236 { 230 cairo_save( m_data->cr);237 cairo_save(platformContext()->cr()); 231 238 m_data->save(); 232 239 m_data->shadowStack.append(m_data->shadow); … … 236 243 void GraphicsContext::restorePlatformState() 237 244 { 238 cairo_t* cr = m_data->cr; 245 cairo_t* cr = platformContext()->cr(); 246 239 247 const ImageMaskInformation& maskInformation = m_data->maskImageStack.last(); 240 248 if (maskInformation.isValid()) { … … 252 260 } 253 261 254 cairo_restore( m_data->cr);262 cairo_restore(cr); 255 263 m_data->restore(); 256 264 } … … 262 270 return; 263 271 264 cairo_t* cr = m_data->cr;272 cairo_t* cr = platformContext()->cr(); 265 273 cairo_save(cr); 266 274 … … 290 298 return; 291 299 292 cairo_t* cr = m_data->cr;300 cairo_t* cr = platformContext()->cr(); 293 301 cairo_save(cr); 294 302 … … 377 385 return; 378 386 379 cairo_t* cr = m_data->cr;387 cairo_t* cr = platformContext()->cr(); 380 388 cairo_save(cr); 381 389 float yRadius = .5 * rect.height(); … … 416 424 float falen = fa + angleSpan; 417 425 418 cairo_t* cr = m_data->cr;426 cairo_t* cr = platformContext()->cr(); 419 427 cairo_save(cr); 420 428 … … 493 501 return; 494 502 495 cairo_t* cr = m_data->cr;503 cairo_t* cr = platformContext()->cr(); 496 504 497 505 cairo_save(cr); … … 523 531 return; 524 532 525 cairo_t* cr = m_data->cr;533 cairo_t* cr = platformContext()->cr(); 526 534 527 535 cairo_new_path(cr); … … 543 551 return; 544 552 545 cairo_t* cr = m_data->cr;553 cairo_t* cr = platformContext()->cr(); 546 554 setPathOnCairoContext(cr, path.platformPath()->context()); 547 555 fillCurrentCairoPath(this, cr); … … 553 561 return; 554 562 555 cairo_t* cr = m_data->cr;563 cairo_t* cr = platformContext()->cr(); 556 564 setPathOnCairoContext(cr, path.platformPath()->context()); 557 565 strokeCurrentCairoPath(this, cr); … … 563 571 return; 564 572 565 cairo_t* cr = m_data->cr;573 cairo_t* cr = platformContext()->cr(); 566 574 cairo_save(cr); 567 575 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); … … 579 587 580 588 if (color.alpha()) 581 fillRectSourceOver( m_data->cr, rect, color);589 fillRectSourceOver(platformContext()->cr(), rect, color); 582 590 } 583 591 … … 587 595 return; 588 596 589 cairo_t* cr = m_data->cr;597 cairo_t* cr = platformContext()->cr(); 590 598 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 591 599 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); … … 601 609 return; 602 610 603 cairo_t* cr = m_data->cr;611 cairo_t* cr = platformContext()->cr(); 604 612 setPathOnCairoContext(cr, path.platformPath()->context()); 605 613 cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); … … 639 647 adjustFocusRingLineWidth(width); 640 648 641 cairo_t* cr = m_data->cr;649 cairo_t* cr = platformContext()->cr(); 642 650 cairo_save(cr); 643 651 appendWebCorePathToCairoContext(cr, path); … … 656 664 unsigned rectCount = rects.size(); 657 665 658 cairo_t* cr = m_data->cr;666 cairo_t* cr = platformContext()->cr(); 659 667 cairo_save(cr); 660 668 cairo_push_group(cr); … … 733 741 return; 734 742 735 cairo_t* cr = m_data->cr;743 cairo_t* cr = platformContext()->cr(); 736 744 cairo_save(cr); 737 745 … … 763 771 double x = frect.x(); 764 772 double y = frect.y(); 765 cairo_t* cr = m_data->cr;773 cairo_t* cr = platformContext()->cr(); 766 774 cairo_user_to_device(cr, &x, &y); 767 775 x = round(x); … … 800 808 return; 801 809 802 cairo_t* cr = m_data->cr;810 cairo_t* cr = platformContext()->cr(); 803 811 cairo_translate(cr, x, y); 804 812 m_data->translate(x, y); … … 822 830 return; 823 831 824 cairo_set_line_width( m_data->cr, strokeThickness);832 cairo_set_line_width(platformContext()->cr(), strokeThickness); 825 833 } 826 834 … … 836 844 case NoStroke: 837 845 // FIXME: is it the right way to emulate NoStroke? 838 cairo_set_line_width( m_data->cr, 0);846 cairo_set_line_width(platformContext()->cr(), 0); 839 847 break; 840 848 case SolidStroke: 841 cairo_set_dash( m_data->cr, 0, 0, 0);849 cairo_set_dash(platformContext()->cr(), 0, 0, 0); 842 850 break; 843 851 case DottedStroke: 844 cairo_set_dash( m_data->cr, dotPattern, 2, 0);852 cairo_set_dash(platformContext()->cr(), dotPattern, 2, 0); 845 853 break; 846 854 case DashedStroke: 847 cairo_set_dash( m_data->cr, dashPattern, 2, 0);855 cairo_set_dash(platformContext()->cr(), dashPattern, 2, 0); 848 856 break; 849 857 } … … 860 868 return; 861 869 862 cairo_t* cr = m_data->cr;870 cairo_t* cr = platformContext()->cr(); 863 871 const cairo_matrix_t matrix = cairo_matrix_t(transform); 864 872 cairo_transform(cr, &matrix); … … 871 879 return; 872 880 873 cairo_t* cr = m_data->cr;881 cairo_t* cr = platformContext()->cr(); 874 882 const cairo_matrix_t matrix = cairo_matrix_t(transform); 875 883 cairo_set_matrix(cr, &matrix); … … 882 890 return; 883 891 884 cairo_t* cr = m_data->cr;892 cairo_t* cr = platformContext()->cr(); 885 893 clip(rect); 886 894 … … 929 937 return; 930 938 931 cairo_t* cr = m_data->cr;939 cairo_t* cr = platformContext()->cr(); 932 940 cairo_push_group(cr); 933 941 m_data->layers.append(opacity); … … 940 948 return; 941 949 942 cairo_t* cr = m_data->cr;950 cairo_t* cr = platformContext()->cr(); 943 951 944 952 cairo_pop_group_to_source(cr); … … 953 961 return; 954 962 955 cairo_t* cr = m_data->cr;963 cairo_t* cr = platformContext()->cr(); 956 964 957 965 cairo_save(cr); … … 967 975 return; 968 976 969 cairo_t* cr = m_data->cr;977 cairo_t* cr = platformContext()->cr(); 970 978 cairo_save(cr); 971 979 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); … … 992 1000 break; 993 1001 } 994 cairo_set_line_cap( m_data->cr, cairoCap);1002 cairo_set_line_cap(platformContext()->cr(), cairoCap); 995 1003 } 996 1004 997 1005 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) 998 1006 { 999 cairo_set_dash( m_data->cr, dashes.data(), dashes.size(), dashOffset);1007 cairo_set_dash(platformContext()->cr(), dashes.data(), dashes.size(), dashOffset); 1000 1008 } 1001 1009 … … 1017 1025 break; 1018 1026 } 1019 cairo_set_line_join( m_data->cr, cairoJoin);1027 cairo_set_line_join(platformContext()->cr(), cairoJoin); 1020 1028 } 1021 1029 … … 1025 1033 return; 1026 1034 1027 cairo_set_miter_limit( m_data->cr, miter);1035 cairo_set_miter_limit(platformContext()->cr(), miter); 1028 1036 } 1029 1037 … … 1043 1051 return; 1044 1052 1045 cairo_set_operator( m_data->cr, toCairoOperator(op));1053 cairo_set_operator(platformContext()->cr(), toCairoOperator(op)); 1046 1054 } 1047 1055 … … 1051 1059 return; 1052 1060 1053 cairo_t* cr = m_data->cr;1061 cairo_t* cr = platformContext()->cr(); 1054 1062 OwnPtr<cairo_path_t> p(cairo_copy_path(path.platformPath()->context())); 1055 1063 cairo_append_path(cr, p.get()); … … 1071 1079 return; 1072 1080 1073 cairo_t* cr = m_data->cr;1081 cairo_t* cr = platformContext()->cr(); 1074 1082 double x1, y1, x2, y2; 1075 1083 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); … … 1088 1096 return; 1089 1097 1090 cairo_rotate( m_data->cr, radians);1098 cairo_rotate(platformContext()->cr(), radians); 1091 1099 m_data->rotate(radians); 1092 1100 } … … 1097 1105 return; 1098 1106 1099 cairo_scale( m_data->cr, size.width(), size.height());1107 cairo_scale(platformContext()->cr(), size.width(), size.height()); 1100 1108 m_data->scale(size); 1101 1109 } … … 1106 1114 return; 1107 1115 1108 cairo_t* cr = m_data->cr;1116 cairo_t* cr = platformContext()->cr(); 1109 1117 double x1, y1, x2, y2; 1110 1118 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); … … 1133 1141 m_data->shadow.drawRectShadow(this, r, topLeft, topRight, bottomLeft, bottomRight); 1134 1142 1135 cairo_t* cr = m_data->cr;1143 cairo_t* cr = platformContext()->cr(); 1136 1144 cairo_save(cr); 1137 1145 Path path; … … 1171 1179 // enables standard 'grayscale' antialiasing); false to explicitly disable 1172 1180 // antialiasing. This is the same strategy as used in drawConvexPolygon(). 1173 cairo_set_antialias( m_data->cr, enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);1181 cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); 1174 1182 } 1175 1183 … … 1197 1205 // is now, but they are isolated in another group. To make this work, we're 1198 1206 // going to blit the current surface contents onto the new group once we push it. 1199 cairo_t* cr = m_data->cr;1207 cairo_t* cr = platformContext()->cr(); 1200 1208 cairo_surface_t* currentTarget = cairo_get_target(cr); 1201 1209 cairo_surface_flush(currentTarget); -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r79592 r82496 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) … … 83 84 ~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 ~GraphicsContextPlatformPrivateToplevel() 146 { 147 delete platformContext; 148 } 149 }; 150 151 136 152 } // namespace WebCore 137 153 -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r79592 r82496 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
r37948 r82496 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
r74947 r82496 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
r82495 r82496 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
r82495 r82496 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
r80744 r82496 36 36 #include "CairoUtilities.h" 37 37 #include "ContextShadow.h" 38 #include "PlatformContextCairo.h" 38 39 #include "GraphicsContext.h" 39 40 #include "NotImplemented.h" … … 221 222 } 222 223 223 static void drawGlyphsShadow(GraphicsContext* graphicsContext, c airo_t* context, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)224 static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion) 224 225 { 225 226 ContextShadow* shadow = graphicsContext->contextShadow(); … … 233 234 // Optimize non-blurry shadows, by just drawing text without the ContextShadow. 234 235 if (!shadow->mustUseContextShadow(graphicsContext)) { 236 cairo_t* context = graphicsContext->platformContext()->cr(); 235 237 cairo_save(context); 236 238 cairo_translate(context, totalOffset.x(), totalOffset.y()); … … 256 258 // drawn. Since ContextShadow expects a consistent transform, we have to undo the 257 259 // translation before calling endShadowLayer as well. 260 cairo_t* context = graphicsContext->platformContext()->cr(); 258 261 cairo_save(context); 259 262 cairo_translate(context, totalOffset.x(), totalOffset.y()); … … 276 279 #endif 277 280 278 cairo_t* cr = context->platformContext() ;281 cairo_t* cr = context->platformContext()->cr(); 279 282 PangoLayout* layout = pango_cairo_create_layout(cr); 280 283 setPangoAttributes(this, run, layout); … … 295 298 partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1); 296 299 297 drawGlyphsShadow(context, cr,point, layoutLine, partialRegion);300 drawGlyphsShadow(context, point, layoutLine, partialRegion); 298 301 299 302 cairo_save(cr); -
trunk/Source/WebCore/platform/graphics/gtk/IconGtk.cpp
r56825 r82496 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
r73728 r82496 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()); … … 132 129 // so that when we set the srcImage as the surface it will draw 133 130 // right-side-up. 134 cairo_save(m_data->cr); 135 cairo_translate(m_data->cr, dstRect.x(), dstRect.height() + dstRect.y()); 136 cairo_scale(m_data->cr, 1.0, -1.0); 137 cairo_set_source_surface(m_data->cr, image, 0, 0); 131 cairo_t* cr = platformContext()->cr(); 132 cairo_save(cr); 133 cairo_translate(cr, dstRect.x(), dstRect.height() + dstRect.y()); 134 cairo_scale(cr, 1, -1); 135 cairo_set_source_surface(cr, image, 0, 0); 138 136 139 137 if (m_data->layers.size()) 140 cairo_paint_with_alpha( m_data->cr, m_data->layers.last());138 cairo_paint_with_alpha(cr, m_data->layers.last()); 141 139 else 142 cairo_paint( m_data->cr);140 cairo_paint(cr); 143 141 144 142 // Delete all our junk. … … 146 144 ::DeleteDC(hdc); 147 145 ::DeleteObject(bitmap); 148 cairo_restore( m_data->cr);146 cairo_restore(cr); 149 147 } 150 148 151 void GraphicsContextPlatformPrivate::syncContext( PlatformGraphicsContext* cr)149 void GraphicsContextPlatformPrivate::syncContext(cairo_t* cr) 152 150 { 153 151 if (!cr) -
trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp
r77726 r82496 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
r77993 r82496 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/plugins/gtk/PluginViewGtk.cpp
r80430 r82496 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
r79988 r82496 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
r82219 r82496 1 2011-03-30 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Dirk Schulze. 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-03-29 Philippe Normand <pnormand@igalia.com> 2 19 -
trunk/Source/WebKit/gtk/webkit/webkitwebframe.cpp
r77714 r82496 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
r81600 r82496 711 711 712 712 RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window)); 713 GraphicsContext ctx(cr.get());714 ctx.setGdkExposeEvent(event);713 GraphicsContext gc(cr.get()); 714 gc.setGdkExposeEvent(event); 715 715 716 716 int rectCount; … … 721 721 paintRects.append(IntRect(rects.get()[i])); 722 722 723 paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects);723 paintWebView(frame, priv->transparent, gc, static_cast<IntRect>(event->area), paintRects); 724 724 } 725 725 … … 738 738 Frame* frame = core(webView)->mainFrame(); 739 739 if (frame->contentRenderer() && frame->view()) { 740 GraphicsContext ctx(cr);740 GraphicsContext gc(cr); 741 741 IntRect rect = clipRect; 742 742 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); … … 749 749 rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i]))); 750 750 } 751 paintWebView(frame, priv->transparent, ctx, rect, rects);751 paintWebView(frame, priv->transparent, gc, rect, rects); 752 752 753 753 cairo_rectangle_list_destroy(rectList); -
trunk/Source/WebKit/win/ChangeLog
r82493 r82496 1 2011-03-30 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Dirk Schulze. 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-03-30 Steve Falkenburg <sfalken@apple.com> 2 16 -
trunk/Source/WebKit/win/WebFrame.cpp
r82294 r82496 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
r82294 r82496 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
Note: See TracChangeset
for help on using the changeset viewer.