Changeset 99803 in webkit
- Timestamp:
- Nov 9, 2011, 7:10:09 PM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/Gradient.h (modified) (2 diffs)
-
platform/graphics/cairo/GradientCairo.cpp (modified) (2 diffs)
-
platform/graphics/cairo/GraphicsContextCairo.cpp (modified) (2 diffs)
-
platform/graphics/cairo/PlatformContextCairo.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99800 r99803 1 2011-11-09 Martin Robinson <mrobinson@igalia.com> 2 3 [Cairo] Avoid clipping when painting more often 4 https://bugs.webkit.org/show_bug.cgi?id=71179 5 6 Reviewed by Xan Lopez. 7 8 No new tests. These changes are covered by existing tests. 9 10 * platform/graphics/Gradient.h: Add a Cairo-specific method 11 that gets the platform gradient with a particular alpha value. 12 * platform/graphics/cairo/GradientCairo.cpp: Now cache the alpha 13 value of the last created platform gradient. 14 (WebCore::Gradient::platformGradient): If the cached platform gradient 15 has a different alpha value than the one requested, destroy it and start 16 over. 17 * platform/graphics/cairo/GraphicsContextCairo.cpp: 18 (WebCore::drawPathShadow): Adjust the source to avoid calling 19 cairo_clip/cairo_paint_with_alpha and just do a fill. 20 (WebCore::shadowAndFillCurrentCairoPath): No need to clip here. Just 21 call cairo_fill. 22 * platform/graphics/cairo/PlatformContextCairo.cpp: 23 (WebCore::drawPatternToCairoContext): If we have a >= 1 alpha value 24 we can simply fill and avoid calling cairo_clip here. 25 (WebCore::prepareCairoContextSource): Remove TODO about recreating the 26 gradient. No longer need to reduce the gradient source. 27 1 28 2011-11-09 Alexey Proskuryakov <ap@apple.com> 2 29 -
trunk/Source/WebCore/platform/graphics/Gradient.h
r95922 r99803 139 139 void paint(CGContextRef); 140 140 void paint(GraphicsContext*); 141 #elif USE(CAIRO) 142 PlatformGradient platformGradient(float globalAlpha); 141 143 #endif 142 144 … … 164 166 165 167 PlatformGradient m_gradient; 168 169 #if USE(CAIRO) 170 float m_platformGradientAlpha; 171 #endif 172 166 173 }; 167 174 -
trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
r95901 r99803 45 45 cairo_pattern_t* Gradient::platformGradient() 46 46 { 47 if (m_gradient) 47 return platformGradient(1); 48 } 49 50 cairo_pattern_t* Gradient::platformGradient(float globalAlpha) 51 { 52 if (m_gradient && m_platformGradientAlpha == globalAlpha) 48 53 return m_gradient; 54 55 platformDestroy(); 56 m_platformGradientAlpha = globalAlpha; 49 57 50 58 if (m_radial) … … 55 63 Vector<ColorStop>::iterator stopIterator = m_stops.begin(); 56 64 while (stopIterator != m_stops.end()) { 57 cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop, stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha); 65 cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop, 66 stopIterator->red, stopIterator->green, stopIterator->blue, 67 stopIterator->alpha * globalAlpha); 58 68 ++stopIterator; 59 69 } -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r95685 r99803 135 135 cairo_append_path(cairoShadowContext, path.get()); 136 136 shadowContext->platformContext()->prepareForFilling(context->state(), PlatformContextCairo::NoAdjustment); 137 cairo_clip(cairoShadowContext); 138 cairo_paint(cairoShadowContext); 137 cairo_fill(cairoShadowContext); 139 138 cairo_restore(cairoShadowContext); 140 139 } … … 158 157 cairo_save(cr); 159 158 160 context->platformContext()->prepareForFilling(context->state(), PlatformContextCairo::NoAdjustment);161 162 159 drawPathShadow(context, Fill); 163 160 164 cairo_clip(cr); 165 cairo_paint_with_alpha(cr, context->platformContext()->globalAlpha()); 161 context->platformContext()->prepareForFilling(context->state(), PlatformContextCairo::AdjustPatternForGlobalAlpha); 162 cairo_fill(cr); 163 166 164 cairo_restore(cr); 167 165 } -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
r95901 r99803 144 144 cairo_set_source(cr, pattern); 145 145 cairo_rectangle(cr, 0, 0, destRect.width(), destRect.height()); 146 cairo_clip(cr); 147 cairo_paint_with_alpha(cr, alpha); 146 147 if (alpha < 1) { 148 cairo_clip(cr); 149 cairo_paint_with_alpha(cr, alpha); 150 } else 151 cairo_fill(cr); 148 152 } 149 153 … … 214 218 cairo_set_source(cr, cairoPattern.get()); 215 219 reduceSourceByAlpha(cr, globalAlpha); 216 } else if (gradient) { 217 cairo_set_source(cr, gradient->platformGradient()); 218 219 // FIXME: It would be faster to simply recreate the Cairo gradient and multiply the 220 // color stops by the global alpha. 221 reduceSourceByAlpha(cr, globalAlpha); 222 } else { // Solid color source. 220 } else if (gradient) 221 cairo_set_source(cr, gradient->platformGradient(globalAlpha)); 222 else { // Solid color source. 223 223 if (globalAlpha < 1) 224 224 setSourceRGBAFromColor(cr, colorWithOverrideAlpha(color.rgb(), color.alpha() / 255.f * globalAlpha));
Note:
See TracChangeset
for help on using the changeset viewer.