Changeset 64318 in webkit
- Timestamp:
- Jul 29, 2010 4:17:46 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64315 r64318 1 2010-07-29 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Dirk Schulze. 4 5 [Cairo] Bring behavior of paths on the Cairo GraphicsContext into line with the CoreGraphics port 6 https://bugs.webkit.org/show_bug.cgi?id=41732 7 8 Do not apply paths added to the Cairo GraphicsContext, until they are used. 9 This prevents drawing routines such as fillRect from interacting with any 10 path which callers are constructing on the GraphicsContext. 11 12 This behavior is necessary to close bug https://bugs.webkit.org/show_bug.cgi?id=41308 13 so tests for that issue will test this fix. 14 15 * platform/graphics/cairo/GraphicsContextCairo.cpp: 16 (WebCore::appendPathToCairoContext): Added. A helper method which adds a path 17 to a native Cairo context. 18 (WebCore::setPathOnCairoContext): Added. Like appendPathToCairoContext, but clears the 19 existing path first. 20 (WebCore::appendWebCorePathToCairoContext): Added. Like appendPathToCairoContext, but 21 operates on a WebCore path. 22 (WebCore::GraphicsContext::drawEllipse): Only clear the Cairo path if cairo_stroke 23 was not called, because cairo_stroke implicitly clears the path. 24 (WebCore::GraphicsContext::drawConvexPolygon): Ditto. 25 (WebCore::GraphicsContext::fillPath): Copy the path from m_pendingPath to the context 26 and clear m_pendingPath, instead of relying on the pre-existing context path. 27 (WebCore::GraphicsContext::strokePath): Ditto. 28 (WebCore::GraphicsContext::drawPath): Ditto. 29 (WebCore::GraphicsContext::drawFocusRing): Use the new appendWebCorePathToCairoContext helper instead 30 of addPath (which will blow away any path callers are building). 31 (WebCore::GraphicsContext::addInnerRoundedRectClip): Use the new appendWebCorePathToCairoContext helper instead 32 of addPath (which will blow away any path callers are building). 33 (WebCore::GraphicsContext::beginPath): Clear out m_pendingPath here instead of the main native context. 34 (WebCore::GraphicsContext::addPath): Add the path to m_pendingPath instead of the main native context. 35 Also ensure that the transformation matrix of the m_pendingPath is equal to that of the main 36 cairo context. 37 (WebCore::GraphicsContext::clipOut): Use the appendWebCorePathToCairoContext helper here. 38 (WebCore::GraphicsContext::fillRoundedRect): Ditto and remove an unnecessary beginPath call. 39 * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Add a new m_pendingPath member. 40 1 41 2010-07-29 Martin Robinson <mrobinson@igalia.com> 2 42 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r64315 r64318 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 { … … 381 403 cairo_set_line_width(cr, strokeThickness()); 382 404 cairo_stroke(cr); 383 } 384 385 cairo_new_path(cr); 405 } else 406 cairo_new_path(cr); 386 407 } 387 408 … … 499 520 cairo_set_line_width(cr, strokeThickness()); 500 521 cairo_stroke(cr); 501 } 502 503 cairo_new_path(cr); 522 } else 523 cairo_new_path(cr); 524 504 525 cairo_restore(cr); 505 526 } … … 523 544 cairo_t* cr = m_data->cr; 524 545 546 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 547 525 548 cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); 526 549 drawPathShadow(this, m_common, true, false); … … 536 559 537 560 cairo_t* cr = m_data->cr; 561 562 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 563 538 564 drawPathShadow(this, m_common, false, true); 539 565 … … 549 575 550 576 cairo_t* cr = m_data->cr; 577 578 setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr); 551 579 552 580 cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); … … 674 702 int radius = (width - 1) / 2; 675 703 for (unsigned i = 0; i < rectCount; i++) 676 a ddPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));704 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(rects[i], FloatSize(radius, radius))); 677 705 678 706 // Force the alpha to 50%. This matches what the Mac does with outline rings. … … 841 869 return; 842 870 871 cairo_t* cr = m_data->cr; 843 872 clip(rect); 844 873 … … 850 879 r.inflate(-thickness); 851 880 p.addEllipse(r); 852 addPath(p); 853 854 cairo_t* cr = m_data->cr; 881 appendWebCorePathToCairoContext(cr, p); 882 855 883 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); 856 884 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); … … 1080 1108 return; 1081 1109 1082 cairo_t* cr = m_data->cr; 1083 cairo_new_path(cr); 1110 cairo_new_path(m_data->m_pendingPath.m_cr); 1084 1111 } 1085 1112 … … 1089 1116 return; 1090 1117 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);1118 cairo_matrix_t currentMatrix; 1119 cairo_get_matrix(m_data->cr, ¤tMatrix); 1120 cairo_set_matrix(m_data->m_pendingPath.m_cr, ¤tMatrix); 1121 appendWebCorePathToCairoContext(m_data->m_pendingPath.m_cr, path); 1095 1122 } 1096 1123 … … 1125 1152 cairo_clip_extents(cr, &x1, &y1, &x2, &y2); 1126 1153 cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); 1127 a ddPath(path);1154 appendWebCorePathToCairoContext(cr, path); 1128 1155 1129 1156 cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); … … 1184 1211 cairo_t* cr = m_data->cr; 1185 1212 cairo_save(cr); 1186 beginPath(); 1187 addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 1213 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 1188 1214 setColor(cr, color); 1189 1215 drawPathShadow(this, m_common, true, false); -
trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r54137 r64318 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.