Changeset 64335 in webkit
- Timestamp:
- Jul 29, 2010 11:13:10 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64334 r64335 97 97 (WebCore::GraphicsContext::addInnerRoundedRectClip): Use the new appendWebCorePathToCairoContext helper instead 98 98 of addPath (which will blow away any path callers are building). 99 (WebCore::GraphicsContext::beginPath): Clear out m_pendingPath here instead of the main native context. 100 (WebCore::GraphicsContext::addPath): Add the path to m_pendingPath instead of the main native context. 101 Also ensure that the transformation matrix of the m_pendingPath is equal to that of the main 102 cairo context. 103 (WebCore::GraphicsContext::clipOut): Use the appendWebCorePathToCairoContext helper here. 104 (WebCore::GraphicsContext::fillRoundedRect): Ditto and remove an unnecessary beginPath call. 105 * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Add a new m_pendingPath member. 106 107 2010-07-29 Martin Robinson <mrobinson@igalia.com> 108 109 Reviewed by Dirk Schulze. 110 111 [Cairo] Bring behavior of paths on the Cairo GraphicsContext into line with the CoreGraphics port 112 https://bugs.webkit.org/show_bug.cgi?id=41732 113 114 Do not apply paths added to the Cairo GraphicsContext, until they are used. 115 This prevents drawing routines such as fillRect from interacting with any 116 path which callers are constructing on the GraphicsContext. 117 118 This behavior is necessary to close bug https://bugs.webkit.org/show_bug.cgi?id=41308 119 so tests for that issue will test this fix. 120 121 * platform/graphics/cairo/GraphicsContextCairo.cpp: 122 (WebCore::appendPathToCairoContext): Added. A helper method which adds a path 123 to a native Cairo context. 124 (WebCore::setPathOnCairoContext): Added. Like appendPathToCairoContext, but clears the 125 existing path first. 126 (WebCore::appendWebCorePathToCairoContext): Added. Like appendPathToCairoContext, but 127 operates on a WebCore path. 128 (WebCore::fillCurrentCairoPath): Added. Helper which fills the current cairo context path. 129 (WebCore::strokeCurrentCairoPath): Added. Helper which strokes the current cairo context path. 130 (WebCore::GraphicsContext::drawEllipse): Only clear the Cairo path if cairo_stroke 131 was not called, because cairo_stroke implicitly clears the path. 132 (WebCore::GraphicsContext::drawConvexPolygon): Ditto. 133 (WebCore::GraphicsContext::fillPath): Copy the path from m_pendingPath to the context 134 and clear m_pendingPath, instead of relying on the pre-existing context path. Do the 135 actual fill via the new helper. 136 (WebCore::GraphicsContext::strokePath): Ditto. 137 (WebCore::GraphicsContext::drawPath): Ditto. 138 (WebCore::GraphicsContext::fillRect): Use the new fillCurrentCairoPath helper. 139 (WebCore::GraphicsContext::drawFocusRing): Use the new appendWebCorePathToCairoContext helper instead 140 of addPath (which will blow away any path callers are building). 141 (WebCore::GraphicsContext::addInnerRoundedRectClip): Use the new appendWebCorePathToCairoContext helper instead 142 of addPath (which will blow away any path callers are building). 143 (WebCore::GraphicsContext::strokeRect): Use the new strokeCurrentCairoPath helper. 99 144 (WebCore::GraphicsContext::beginPath): Clear out m_pendingPath here instead of the main native context. 100 145 (WebCore::GraphicsContext::addPath): Add the path to m_pendingPath instead of the main native context. -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r64322 r64335 5 5 * Copyright (C) 2008 Nuanti Ltd. 6 6 * Copyright (C) 2009 Brent Fulgham <bfulgham@webkit.org> 7 * Copyright (C) 2010 Igalia S.L. 7 8 * 8 9 * Redistribution and use in source and binary forms, with or without … … 144 145 } 145 146 147 static void appendPathToCairoContext(cairo_t* to, cairo_t* from) 148 { 149 cairo_path_t* cairoPath = cairo_copy_path(from); 150 cairo_append_path(to, cairoPath); 151 cairo_path_destroy(cairoPath); 152 } 153 154 // We apply the pending path built via addPath to the Cairo context 155 // lazily. This prevents interaction between the path and other routines 156 // such as fillRect. 157 static void setPathOnCairoContext(cairo_t* to, cairo_t* from) 158 { 159 cairo_new_path(to); 160 appendPathToCairoContext(to, from); 161 } 162 163 static void appendWebCorePathToCairoContext(cairo_t* context, const Path& path) 164 { 165 appendPathToCairoContext(context, path.platformPath()->m_cr); 166 } 167 146 168 void GraphicsContext::calculateShadowBufferDimensions(IntSize& shadowBufferSize, FloatRect& shadowRect, float& kernelSize, const FloatRect& sourceRect, const FloatSize& shadowSize, float shadowBlur) 147 169 { … … 200 222 context->createPlatformShadow(shadowBuffer.release(), shadowColor, shadowRect, kernelSize); 201 223 #endif 224 } 225 226 static void fillCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext) 227 { 228 cairo_set_fill_rule(cairoContext, context->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); 229 drawPathShadow(context, gcp, true, false); 230 231 setPlatformFill(context, cairoContext, gcp); 232 cairo_new_path(cairoContext); 233 } 234 235 static void strokeCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext) 236 { 237 drawPathShadow(context, gcp, false, true); 238 setPlatformStroke(context, cairoContext, gcp); 239 cairo_new_path(cairoContext); 202 240 } 203 241 … … 381 419 cairo_set_line_width(cr, strokeThickness()); 382 420 cairo_stroke(cr); 383 } 384 385 cairo_new_path(cr); 421 } else 422 cairo_new_path(cr); 386 423 } 387 424 … … 499 536 cairo_set_line_width(cr, strokeThickness()); 500 537 cairo_stroke(cr); 501 } 502 503 cairo_new_path(cr); 538 } else 539 cairo_new_path(cr); 540 504 541 cairo_restore(cr); 505 542 } … … 523 560 cairo_t* cr = m_data->cr; 524 561 525 cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); 526 drawPathShadow(this, m_common, true, false); 527 528 setPlatformFill(this, cr, m_common); 529 cairo_new_path(cr); 562 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 563 fillCurrentCairoPath(this, m_common, cr); 530 564 } 531 565 … … 536 570 537 571 cairo_t* cr = m_data->cr; 538 drawPathShadow(this, m_common, false, true); 539 540 setPlatformStroke(this, cr, m_common); 541 cairo_new_path(cr); 542 572 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 573 strokeCurrentCairoPath(this, m_common, cr); 543 574 } 544 575 … … 549 580 550 581 cairo_t* cr = m_data->cr; 582 583 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 551 584 552 585 cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); … … 566 599 cairo_save(cr); 567 600 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 568 fill Path();601 fillCurrentCairoPath(this, m_common, cr); 569 602 cairo_restore(cr); 570 603 } … … 674 707 int radius = (width - 1) / 2; 675 708 for (unsigned i = 0; i < rectCount; i++) 676 a ddPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));709 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(rects[i], FloatSize(radius, radius))); 677 710 678 711 // Force the alpha to 50%. This matches what the Mac does with outline rings. … … 841 874 return; 842 875 876 cairo_t* cr = m_data->cr; 843 877 clip(rect); 844 878 … … 850 884 r.inflate(-thickness); 851 885 p.addEllipse(r); 852 addPath(p); 853 854 cairo_t* cr = m_data->cr; 886 appendWebCorePathToCairoContext(cr, p); 887 855 888 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 856 889 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); … … 963 996 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 964 997 cairo_set_line_width(cr, width); 965 stroke Path();998 strokeCurrentCairoPath(this, m_common, cr); 966 999 cairo_restore(cr); 967 1000 } … … 1080 1113 return; 1081 1114 1082 cairo_t* cr = m_data->cr; 1083 cairo_new_path(cr); 1115 cairo_new_path(m_data->m_pendingPath.m_cr); 1084 1116 } 1085 1117 … … 1089 1121 return; 1090 1122 1091 cairo_ t* cr = m_data->cr;1092 cairo_ path_t* p = cairo_copy_path(path.platformPath()->m_cr);1093 cairo_ append_path(cr, p);1094 cairo_path_destroy(p);1123 cairo_matrix_t currentMatrix; 1124 cairo_get_matrix(m_data->cr, ¤tMatrix); 1125 cairo_set_matrix(m_data->m_pendingPath.m_cr, ¤tMatrix); 1126 appendWebCorePathToCairoContext(m_data->m_pendingPath.m_cr, path); 1095 1127 } 1096 1128 … … 1125 1157 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); 1126 1158 cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); 1127 a ddPath(path);1159 appendWebCorePathToCairoContext(cr, path); 1128 1160 1129 1161 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); … … 1184 1216 cairo_t* cr = m_data->cr; 1185 1217 cairo_save(cr); 1186 beginPath(); 1187 addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 1218 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 1188 1219 setColor(cr, color); 1189 1220 drawPathShadow(this, m_common, true, false); -
trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r64322 r64335 96 96 cairo_t* cr; 97 97 Vector<float> layers; 98 CairoPath m_pendingPath; 98 99 99 100 #if PLATFORM(GTK)
Note: See TracChangeset
for help on using the changeset viewer.