Changeset 227065 in webkit
- Timestamp:
- Jan 17, 2018, 5:06:01 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r227061 r227065 1 2018-01-17 Zan Dobersek <zdobersek@igalia.com> 2 3 [Cairo] Don't mirror global alpha and image interpolation quality state values in PlatformContextCairo 4 https://bugs.webkit.org/show_bug.cgi?id=181725 5 6 Reviewed by Carlos Garcia Campos. 7 8 Don't duplicate global alpha and image interpolation quality state 9 values on the PlatformContextCairo. Instead, retrieve them from 10 the managing GraphicsContextState when necessary. 11 12 For Cairo operations, the FillSource and StrokeSource containers now 13 store the global alpha value, using it during the operation executions. 14 For drawNativeImage(), the global alpha and interpolation quality values 15 are passed through arguments. 16 17 In PlatformContextCairo, the two values are no longer stored on the 18 internally-managed stack, and the getter-setter pairs for the two values 19 are removed. In drawSurfaceToContext(), the two values are now expected 20 to be passed through the method arguments. 21 22 No new tests -- no change in behavior. 23 24 * platform/graphics/cairo/CairoOperations.cpp: 25 (WebCore::Cairo::prepareForFilling): 26 (WebCore::Cairo::prepareForStroking): 27 (WebCore::Cairo::drawPathShadow): 28 (WebCore::Cairo::fillCurrentCairoPath): 29 (WebCore::Cairo::FillSource::FillSource): 30 (WebCore::Cairo::StrokeSource::StrokeSource): 31 (WebCore::Cairo::strokeRect): 32 (WebCore::Cairo::strokePath): 33 (WebCore::Cairo::drawGlyphs): 34 (WebCore::Cairo::drawNativeImage): 35 (WebCore::Cairo::State::setGlobalAlpha): Deleted. 36 (WebCore::Cairo::State::setImageInterpolationQuality): Deleted. 37 * platform/graphics/cairo/CairoOperations.h: 38 * platform/graphics/cairo/GraphicsContextCairo.cpp: 39 (WebCore::GraphicsContext::drawNativeImage): 40 (WebCore::GraphicsContext::setPlatformAlpha): 41 (WebCore::GraphicsContext::setPlatformImageInterpolationQuality): 42 * platform/graphics/cairo/PlatformContextCairo.cpp: 43 (WebCore::PlatformContextCairo::save): 44 (WebCore::PlatformContextCairo::drawSurfaceToContext): 45 (WebCore::PlatformContextCairo::State::State): Deleted. 46 (WebCore::PlatformContextCairo::setImageInterpolationQuality): Deleted. 47 (WebCore::PlatformContextCairo::imageInterpolationQuality const): Deleted. 48 (WebCore::PlatformContextCairo::globalAlpha const): Deleted. 49 (WebCore::PlatformContextCairo::setGlobalAlpha): Deleted. 50 * platform/graphics/cairo/PlatformContextCairo.h: 51 * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: 52 (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame): 53 1 54 2018-01-17 Philippe Normand <pnormand@igalia.com> 2 55 -
trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
r227055 r227065 114 114 } 115 115 116 static void prepareForFilling(cairo_t* cr, const Cairo::FillSource& fillSource, float globalAlpha,PatternAdjustment patternAdjustment)116 static void prepareForFilling(cairo_t* cr, const Cairo::FillSource& fillSource, PatternAdjustment patternAdjustment) 117 117 { 118 118 cairo_set_fill_rule(cr, fillSource.fillRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); … … 125 125 126 126 prepareCairoContextSource(cr, fillSource.pattern.object.get(), gradient, 127 fillSource.color, adjustForAlpha ? globalAlpha : 1);127 fillSource.color, adjustForAlpha ? fillSource.globalAlpha : 1); 128 128 129 129 if (fillSource.pattern.object) { … … 133 133 } 134 134 135 void prepareForStroking(cairo_t* cr, const Cairo::StrokeSource& strokeSource, float globalAlpha,AlphaPreservation alphaPreservation)135 void prepareForStroking(cairo_t* cr, const Cairo::StrokeSource& strokeSource, AlphaPreservation alphaPreservation) 136 136 { 137 137 bool preserveAlpha = alphaPreservation == PreserveAlpha; … … 142 142 143 143 prepareCairoContextSource(cr, strokeSource.pattern.get(), gradient, 144 strokeSource.color, preserveAlpha ? globalAlpha : 1);144 strokeSource.color, preserveAlpha ? strokeSource.globalAlpha : 1); 145 145 } 146 146 … … 201 201 cairo_save(cairoShadowContext); 202 202 cairo_append_path(cairoShadowContext, path.get()); 203 prepareForFilling(cairoShadowContext, fillSource, shadowContext->platformContext()->globalAlpha(),NoAdjustment);203 prepareForFilling(cairoShadowContext, fillSource, NoAdjustment); 204 204 cairo_fill(cairoShadowContext); 205 205 cairo_restore(cairoShadowContext); … … 208 208 if (drawingStyle & Stroke) { 209 209 cairo_append_path(cairoShadowContext, path.get()); 210 prepareForStroking(cairoShadowContext, strokeSource, shadowContext->platformContext()->globalAlpha(),DoNotPreserveAlpha);210 prepareForStroking(cairoShadowContext, strokeSource, DoNotPreserveAlpha); 211 211 cairo_stroke(cairoShadowContext); 212 212 } … … 226 226 cairo_save(cr); 227 227 228 prepareForFilling(cr, fillSource, platformContext.globalAlpha(),AdjustPatternForGlobalAlpha);228 prepareForFilling(cr, fillSource, AdjustPatternForGlobalAlpha); 229 229 cairo_fill(cr); 230 230 … … 431 431 } 432 432 433 void setGlobalAlpha(PlatformContextCairo& platformContext, float alpha)434 {435 platformContext.setGlobalAlpha(alpha);436 }437 438 433 void setCompositeOperation(PlatformContextCairo& platformContext, CompositeOperator compositeOperation, BlendMode blendMode) 439 434 { … … 447 442 // antialiasing. 448 443 cairo_set_antialias(platformContext.cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); 449 }450 451 void setImageInterpolationQuality(PlatformContextCairo& platformContext, InterpolationQuality quality)452 {453 platformContext.setImageInterpolationQuality(quality);454 444 } 455 445 … … 523 513 524 514 FillSource::FillSource(const GraphicsContextState& state) 515 : globalAlpha(state.alpha) 516 , fillRule(state.fillRule) 525 517 { 526 518 if (state.fillPattern) { … … 538 530 } else 539 531 color = state.fillColor; 540 541 fillRule = state.fillRule;542 532 } 543 533 544 534 StrokeSource::StrokeSource(const GraphicsContextState& state) 535 : globalAlpha(state.alpha) 545 536 { 546 537 if (state.strokePattern) … … 721 712 cairo_set_line_width(cr, lineWidth); 722 713 drawPathShadow(platformContext, { }, strokeSource, shadowState, targetContext, Stroke); 723 prepareForStroking(cr, strokeSource, platformContext.globalAlpha(),PreserveAlpha);714 prepareForStroking(cr, strokeSource, PreserveAlpha); 724 715 cairo_stroke(cr); 725 716 … … 733 724 setPathOnCairoContext(cr, path.platformPath()->context()); 734 725 drawPathShadow(platformContext, { }, strokeSource, shadowState, targetContext, Stroke); 735 prepareForStroking(cr, strokeSource, platformContext.globalAlpha(),PreserveAlpha);726 prepareForStroking(cr, strokeSource, PreserveAlpha); 736 727 cairo_stroke(cr); 737 728 } … … 756 747 757 748 if (textDrawingMode & TextModeFill) { 758 prepareForFilling(cr, fillSource, platformContext.globalAlpha(),AdjustPatternForGlobalAlpha);749 prepareForFilling(cr, fillSource, AdjustPatternForGlobalAlpha); 759 750 drawGlyphsToContext(cr, scaledFont, syntheticBoldOffset, glyphs); 760 751 } … … 765 756 // See https://bugs.webkit.org/show_bug.cgi?id=33759. 766 757 if (textDrawingMode & TextModeStroke && strokeThickness < 2 * xOffset) { 767 prepareForStroking(cr, strokeSource, platformContext.globalAlpha(),PreserveAlpha);758 prepareForStroking(cr, strokeSource, PreserveAlpha); 768 759 cairo_set_line_width(cr, strokeThickness); 769 760 … … 777 768 } 778 769 779 void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOperator, BlendMode blendMode, ImageOrientation orientation, const ShadowState& shadowState, GraphicsContext& targetContext)770 void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOperator, BlendMode blendMode, ImageOrientation orientation, InterpolationQuality imageInterpolationQuality, float globalAlpha, const ShadowState& shadowState, GraphicsContext& targetContext) 780 771 { 781 772 platformContext.save(); … … 800 791 } 801 792 802 platformContext.drawSurfaceToContext(surface, dst, srcRect, shadowState, targetContext);793 platformContext.drawSurfaceToContext(surface, dst, srcRect, imageInterpolationQuality, globalAlpha, shadowState, targetContext); 803 794 platformContext.restore(); 804 795 } -
trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h
r227051 r227065 60 60 void setStrokeStyle(PlatformContextCairo&, StrokeStyle); 61 61 62 void setGlobalAlpha(PlatformContextCairo&, float);63 62 void setCompositeOperation(PlatformContextCairo&, CompositeOperator, BlendMode); 64 63 void setShouldAntialias(PlatformContextCairo&, bool); 65 void setImageInterpolationQuality(PlatformContextCairo&, InterpolationQuality);66 64 67 65 void setCTM(PlatformContextCairo&, const AffineTransform&); … … 79 77 explicit FillSource(const GraphicsContextState&); 80 78 79 float globalAlpha { 0 }; 81 80 struct { 82 81 RefPtr<cairo_pattern_t> object; … … 99 98 explicit StrokeSource(const GraphicsContextState&); 100 99 100 float globalAlpha { 0 }; 101 101 RefPtr<cairo_pattern_t> pattern; 102 102 struct { … … 136 136 void drawGlyphs(PlatformContextCairo&, const FillSource&, const StrokeSource&, const ShadowState&, const FloatPoint&, cairo_scaled_font_t*, double, const Vector<cairo_glyph_t>&, float, TextDrawingModeFlags, float, const FloatSize&, const Color&, GraphicsContext&); 137 137 138 void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode, ImageOrientation, const ShadowState&, GraphicsContext&);138 void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode, ImageOrientation, InterpolationQuality, float, const ShadowState&, GraphicsContext&); 139 139 void drawPattern(PlatformContextCairo&, cairo_surface_t*, const IntSize&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, CompositeOperator, BlendMode); 140 140 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r227051 r227065 140 140 141 141 ASSERT(hasPlatformContext()); 142 Cairo::drawNativeImage(*platformContext(), image.get(), destRect, srcRect, compositeOperator, blendMode, orientation, Cairo::ShadowState(state()), *this); 142 auto& state = this->state(); 143 Cairo::drawNativeImage(*platformContext(), image.get(), destRect, srcRect, compositeOperator, blendMode, orientation, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state), *this); 143 144 } 144 145 … … 574 575 } 575 576 576 void GraphicsContext::setPlatformAlpha(float alpha) 577 { 578 Cairo::State::setGlobalAlpha(*platformContext(), alpha); 577 void GraphicsContext::setPlatformAlpha(float) 578 { 579 579 } 580 580 … … 697 697 } 698 698 699 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality) 700 { 701 ASSERT(hasPlatformContext()); 702 Cairo::State::setImageInterpolationQuality(*platformContext(), quality); 699 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality) 700 { 703 701 } 704 702 -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
r227055 r227065 63 63 class PlatformContextCairo::State { 64 64 public: 65 State() 66 : m_globalAlpha(1) 67 , m_imageInterpolationQuality(InterpolationDefault) 68 { 69 } 70 71 State(float globalAlpha, InterpolationQuality imageInterpolationQuality) 72 : m_globalAlpha(globalAlpha) 73 , m_imageInterpolationQuality(imageInterpolationQuality) 74 { 75 // We do not copy m_imageMaskInformation because otherwise it would be applied 76 // more than once during subsequent calls to restore(). 77 } 65 State() = default; 78 66 79 67 ImageMaskInformation m_imageMaskInformation; 80 float m_globalAlpha;81 InterpolationQuality m_imageInterpolationQuality;82 68 }; 83 69 … … 109 95 void PlatformContextCairo::save() 110 96 { 111 m_stateStack.append(State( m_state->m_globalAlpha, m_state->m_imageInterpolationQuality));97 m_stateStack.append(State()); 112 98 m_state = &m_stateStack.last(); 113 99 … … 158 144 } 159 145 160 void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, const Cairo::ShadowState& shadowState, GraphicsContext& context)146 void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, InterpolationQuality imageInterpolationQuality, float globalAlpha, const Cairo::ShadowState& shadowState, GraphicsContext& context) 161 147 { 162 148 // Avoid invalid cairo matrix with small values. … … 195 181 196 182 ASSERT(m_state); 197 switch ( m_state->m_imageInterpolationQuality) {183 switch (imageInterpolationQuality) { 198 184 case InterpolationNone: 199 185 case InterpolationLow: … … 228 214 229 215 cairo_save(m_cr.get()); 230 drawPatternToCairoContext(m_cr.get(), pattern.get(), destRect, globalAlpha ());216 drawPatternToCairoContext(m_cr.get(), pattern.get(), destRect, globalAlpha); 231 217 cairo_restore(m_cr.get()); 232 218 } 233 219 234 void PlatformContextCairo::setImageInterpolationQuality(InterpolationQuality quality)235 {236 ASSERT(m_state);237 m_state->m_imageInterpolationQuality = quality;238 }239 240 InterpolationQuality PlatformContextCairo::imageInterpolationQuality() const241 {242 ASSERT(m_state);243 return m_state->m_imageInterpolationQuality;244 }245 246 247 float PlatformContextCairo::globalAlpha() const248 {249 return m_state->m_globalAlpha;250 }251 252 void PlatformContextCairo::setGlobalAlpha(float globalAlpha)253 {254 m_state->m_globalAlpha = globalAlpha;255 }256 257 220 } // namespace WebCore 258 221 -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h
r227055 r227065 65 65 void save(); 66 66 void restore(); 67 void setGlobalAlpha(float);68 float globalAlpha() const;69 67 70 68 void pushImageMask(cairo_surface_t*, const FloatRect&); 71 WEBCORE_EXPORT void drawSurfaceToContext(cairo_surface_t*, const FloatRect& destRect, const FloatRect& srcRect, const Cairo::ShadowState&, GraphicsContext&); 72 73 void setImageInterpolationQuality(InterpolationQuality); 74 InterpolationQuality imageInterpolationQuality() const; 69 WEBCORE_EXPORT void drawSurfaceToContext(cairo_surface_t*, const FloatRect& destRect, const FloatRect& srcRect, InterpolationQuality, float globalAlpha, const Cairo::ShadowState&, GraphicsContext&); 75 70 76 71 private: -
trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
r227051 r227065 2975 2975 if (image) { 2976 2976 WebCore::PlatformContextCairo* ctxt = context.platformContext(); 2977 ctxt->drawSurfaceToContext(image, destRect, srcRect, Cairo::ShadowState(context.state()), context); 2977 auto& state = context.state(); 2978 ctxt->drawSurfaceToContext(image, destRect, srcRect, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state), context); 2978 2979 cairo_surface_destroy(image); 2979 2980 } -
trunk/Source/WebKit/ChangeLog
r227058 r227065 1 2018-01-17 Zan Dobersek <zdobersek@igalia.com> 2 3 [Cairo] Don't mirror global alpha and image interpolation quality state values in PlatformContextCairo 4 https://bugs.webkit.org/show_bug.cgi?id=181725 5 6 Reviewed by Carlos Garcia Campos. 7 8 * Shared/cairo/ShareableBitmapCairo.cpp: 9 (WebKit::ShareableBitmap::paint): 10 Adjust the PlatformContextCairo::drawSurfaceToContext() invocation. 11 * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp: 12 (WebKit::convertCairoSurfaceToShareableBitmap): Ditto. 13 1 14 2018-01-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 15 -
trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp
r227051 r227065 76 76 FloatRect srcRectScaled(srcRect); 77 77 srcRectScaled.scale(scaleFactor); 78 context.platformContext()->drawSurfaceToContext(surface.get(), destRect, srcRectScaled, Cairo::ShadowState(context.state()), context); 78 auto& state = context.state(); 79 context.platformContext()->drawSurfaceToContext(surface.get(), destRect, srcRectScaled, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state), context); 79 80 } 80 81 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
r227051 r227065 55 55 auto graphicsContext = bitmap->createGraphicsContext(); 56 56 57 graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), Cairo::ShadowState(graphicsContext->state()), *graphicsContext); 57 auto& state = graphicsContext->state(); 58 graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state), *graphicsContext); 58 59 return bitmap; 59 60 }
Note:
See TracChangeset
for help on using the changeset viewer.