Changeset 194798 in webkit
- Timestamp:
- Jan 8, 2016, 3:26:48 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
page/FrameView.cpp (modified) (1 diff)
-
platform/graphics/GraphicsContext.cpp (modified) (4 diffs)
-
platform/graphics/GraphicsContext.h (modified) (6 diffs)
-
platform/graphics/cairo/GraphicsContextCairo.cpp (modified) (2 diffs)
-
platform/graphics/cg/GraphicsContextCG.cpp (modified) (18 diffs)
-
platform/graphics/win/GraphicsContextCGWin.cpp (modified) (2 diffs)
-
platform/graphics/win/GraphicsContextCairoWin.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194796 r194798 1 2016-01-08 Simon Fraser <simon.fraser@apple.com> 2 3 Consider painting to be disabled on a GraphicsContext with no platform data, and make updatingControlTints() immutable state 4 https://bugs.webkit.org/show_bug.cgi?id=152927 5 6 Reviewed by Tim Horton. 7 8 GraphicsContext had setters for paintingDisabled and updatingControlTints, but neither 9 were changed dynamically. 10 11 We can eliminate paintingDisabled by simply considering a GraphicsContext that was 12 created with no platform context to be paint-disabled. 13 14 We make updatingControlTints immutable state by providing a constructor that takes 15 a "NonPaintingReasons" enum, and doesn't create platform data. 16 17 More functions in platform code were protected by if (paintingDisabled())... 18 19 * page/FrameView.cpp: 20 (WebCore::FrameView::paintControlTints): 21 * platform/graphics/GraphicsContext.cpp: 22 (WebCore::GraphicsContext::GraphicsContext): 23 (WebCore::GraphicsContext::fillRoundedRect): 24 (WebCore::GraphicsContext::setUpdatingControlTints): Deleted. 25 (WebCore::GraphicsContext::clip): Deleted. 26 * platform/graphics/GraphicsContext.h: 27 (WebCore::GraphicsContext::paintingDisabled): 28 (WebCore::GraphicsContext::updatingControlTints): 29 (WebCore::GraphicsContextState::GraphicsContextState): Deleted. 30 (WebCore::GraphicsContext::setPaintingDisabled): Deleted. 31 * platform/graphics/cairo/GraphicsContextCairo.cpp: 32 (WebCore::GraphicsContext::GraphicsContext): 33 (WebCore::GraphicsContext::platformInit): 34 * platform/graphics/cg/GraphicsContextCG.cpp: 35 (WebCore::GraphicsContext::platformInit): 36 (WebCore::GraphicsContext::savePlatformState): 37 (WebCore::GraphicsContext::restorePlatformState): 38 (WebCore::GraphicsContext::drawNativeImage): 39 (WebCore::GraphicsContext::drawPattern): 40 (WebCore::GraphicsContext::drawRect): 41 (WebCore::GraphicsContext::applyStrokePattern): 42 (WebCore::GraphicsContext::applyFillPattern): 43 (WebCore::GraphicsContext::clip): 44 (WebCore::GraphicsContext::clipBounds): 45 (WebCore::GraphicsContext::setLineDash): 46 (WebCore::GraphicsContext::roundToDevicePixels): 47 (WebCore::GraphicsContext::setPlatformImageInterpolationQuality): 48 (WebCore::GraphicsContext::setIsCALayerContext): 49 (WebCore::GraphicsContext::isCALayerContext): 50 (WebCore::GraphicsContext::setIsAcceleratedContext): 51 (WebCore::GraphicsContext::isAcceleratedContext): 52 (WebCore::GraphicsContext::platformApplyDeviceScaleFactor): 53 * platform/graphics/win/GraphicsContextCGWin.cpp: 54 (WebCore::GraphicsContext::platformInit): 55 (WebCore::GraphicsContext::GraphicsContext): Deleted. 56 * platform/graphics/win/GraphicsContextCairoWin.cpp: 57 (WebCore::GraphicsContext::platformInit): 58 (WebCore::GraphicsContext::GraphicsContext): Deleted. 59 1 60 2016-01-08 Anders Carlsson <andersca@apple.com> 2 61 -
trunk/Source/WebCore/page/FrameView.cpp
r194667 r194798 3898 3898 layout(); 3899 3899 3900 GraphicsContext context((PlatformGraphicsContext*)nullptr); 3901 context.setUpdatingControlTints(true); 3900 GraphicsContext context(GraphicsContext::NonPaintingReasons::UpdatingControlTints); 3902 3901 if (platformWidget()) { 3903 3902 // FIXME: consult paintsEntireContents(). -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r194775 r194798 360 360 } 361 361 362 GraphicsContext::GraphicsContext(NonPaintingReasons nonPaintingReasons) 363 : m_nonPaintingReasons(nonPaintingReasons) 364 { 365 } 362 366 363 367 GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContext) 364 : m_updatingControlTints(false)365 , m_transparencyCount(0)366 368 { 367 369 platformInit(platformGraphicsContext); … … 571 573 } 572 574 573 void GraphicsContext::setUpdatingControlTints(bool b)574 {575 setPaintingDisabled(b);576 m_updatingControlTints = b;577 }578 579 575 float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, int from, int to) 580 576 { … … 733 729 } 734 730 735 void GraphicsContext::clip(const IntRect& rect)736 {737 clip(FloatRect(rect));738 }739 740 731 void GraphicsContext::clipRoundedRect(const FloatRoundedRect& rect) 741 732 { … … 799 790 void GraphicsContext::fillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) 800 791 { 792 if (paintingDisabled()) 793 return; 794 801 795 if (rect.isRounded()) { 802 796 setCompositeOperation(compositeOperation(), blendMode); -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r194757 r194798 117 117 , antialiasedFontDilationEnabled(true) 118 118 , shouldSubpixelQuantizeFonts(true) 119 , paintingDisabled(false)120 119 , shadowsIgnoreTransforms(false) 121 120 #if USE(CG) … … 184 183 bool antialiasedFontDilationEnabled : 1; 185 184 bool shouldSubpixelQuantizeFonts : 1; 186 bool paintingDisabled : 1;187 185 bool shadowsIgnoreTransforms : 1; 188 186 #if USE(CG) … … 250 248 WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*); 251 249 WEBCORE_EXPORT ~GraphicsContext(); 250 251 enum class NonPaintingReasons { 252 NoReasons, 253 UpdatingControlTints 254 }; 255 GraphicsContext(NonPaintingReasons); 252 256 253 257 WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const; 258 259 bool paintingDisabled() const { return !m_data; } 260 bool updatingControlTints() const { return m_nonPaintingReasons == NonPaintingReasons::UpdatingControlTints; } 254 261 255 262 void setStrokeThickness(float); … … 368 375 InterpolationQuality imageInterpolationQuality() const { return m_state.imageInterpolationQuality; } 369 376 370 WEBCORE_EXPORT void clip(const IntRect&);371 377 WEBCORE_EXPORT void clip(const FloatRect&); 372 378 void clipRoundedRect(const FloatRoundedRect&); … … 408 414 static void updateDocumentMarkerResources(); 409 415 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle); 410 411 void setPaintingDisabled(bool paintingDisabled) { m_state.paintingDisabled = paintingDisabled; }412 bool paintingDisabled() const { return m_state.paintingDisabled; }413 414 void setUpdatingControlTints(bool);415 bool updatingControlTints() const { return m_updatingControlTints; }416 416 417 417 WEBCORE_EXPORT void beginTransparencyLayer(float opacity); … … 602 602 FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&, float width, bool printing, Color&); 603 603 604 GraphicsContextPlatformPrivate* m_data ;604 GraphicsContextPlatformPrivate* m_data { nullptr }; 605 605 606 606 GraphicsContextState m_state; 607 607 Vector<GraphicsContextState, 1> m_stack; 608 bool m_updatingControlTints; 609 unsigned m_transparencyCount; 608 609 const NonPaintingReasons m_nonPaintingReasons { NonPaintingReasons::NoReasons }; 610 unsigned m_transparencyCount { 0 }; 610 611 }; 611 612 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r194757 r194798 176 176 177 177 GraphicsContext::GraphicsContext(cairo_t* cr) 178 : m_updatingControlTints(false) 179 , m_transparencyCount(0) 180 { 178 { 179 if (!cr) 180 return; 181 181 182 m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr)); 182 183 } … … 184 185 void GraphicsContext::platformInit(PlatformContextCairo* platformContext) 185 186 { 187 if (!platformContext) 188 return; 189 186 190 m_data = new GraphicsContextPlatformPrivate(platformContext); 187 if (platformContext) 188 m_data->syncContext(platformContext->cr()); 189 else 190 setPaintingDisabled(true); 191 m_data->syncContext(platformContext->cr()); 191 192 } 192 193 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r194757 r194798 116 116 void GraphicsContext::platformInit(CGContextRef cgContext) 117 117 { 118 if (!cgContext) 119 return; 120 118 121 m_data = new GraphicsContextPlatformPrivate(cgContext); 119 setPaintingDisabled(!cgContext); 120 if (cgContext) { 121 // Make sure the context starts in sync with our state. 122 setPlatformFillColor(fillColor()); 123 setPlatformStrokeColor(strokeColor()); 124 setPlatformStrokeThickness(strokeThickness()); 125 m_state.imageInterpolationQuality = convertInterpolationQuality(CGContextGetInterpolationQuality(platformContext())); 126 } 122 // Make sure the context starts in sync with our state. 123 setPlatformFillColor(fillColor()); 124 setPlatformStrokeColor(strokeColor()); 125 setPlatformStrokeThickness(strokeThickness()); 126 m_state.imageInterpolationQuality = convertInterpolationQuality(CGContextGetInterpolationQuality(platformContext())); 127 127 } 128 128 … … 141 141 void GraphicsContext::savePlatformState() 142 142 { 143 ASSERT(!paintingDisabled()); 143 144 // Note: Do not use this function within this class implementation, since we want to avoid the extra 144 145 // save of the secondary context (in GraphicsContextPlatformPrivateCG.h). … … 149 150 void GraphicsContext::restorePlatformState() 150 151 { 152 ASSERT(!paintingDisabled()); 151 153 // Note: Do not use this function within this class implementation, since we want to avoid the extra 152 154 // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h). … … 158 160 void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation) 159 161 { 162 if (paintingDisabled()) 163 return; 164 160 165 RetainPtr<CGImageRef> image(imagePtr); 161 166 … … 272 277 void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode) 273 278 { 274 if ( !patternTransform.isInvertible())279 if (paintingDisabled() || !patternTransform.isInvertible()) 275 280 return; 276 281 … … 372 377 void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness) 373 378 { 374 // FIXME: this function does not handle patterns and gradients 375 // like drawPath does, it probably should. 376 if (paintingDisabled()) 377 return; 378 379 if (paintingDisabled()) 380 return; 381 382 // FIXME: this function does not handle patterns and gradients like drawPath does, it probably should. 379 383 ASSERT(!rect.isEmpty()); 380 384 … … 553 557 void GraphicsContext::applyStrokePattern() 554 558 { 559 if (paintingDisabled()) 560 return; 561 555 562 CGContextRef cgContext = platformContext(); 556 563 AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext)); … … 569 576 void GraphicsContext::applyFillPattern() 570 577 { 578 if (paintingDisabled()) 579 return; 580 571 581 CGContextRef cgContext = platformContext(); 572 582 AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext)); … … 922 932 if (paintingDisabled()) 923 933 return; 934 924 935 CGContextClipToRect(platformContext(), rect); 925 936 m_data->clip(rect); … … 966 977 IntRect GraphicsContext::clipBounds() const 967 978 { 979 if (paintingDisabled()) 980 return IntRect(); 981 968 982 return enclosingIntRect(CGContextGetClipBoundingBox(platformContext())); 969 983 } … … 1173 1187 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) 1174 1188 { 1189 if (paintingDisabled()) 1190 return; 1191 1175 1192 if (dashOffset < 0) { 1176 1193 float length = 0; … … 1278 1295 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode roundingMode) 1279 1296 { 1297 if (paintingDisabled()) 1298 return rect; 1299 1280 1300 // It is not enough just to round to pixels in device space. The rotation part of the 1281 1301 // affine transform matrix to device space can mess with this conversion if we have a … … 1391 1411 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality mode) 1392 1412 { 1413 ASSERT(!paintingDisabled()); 1414 1393 1415 CGInterpolationQuality quality = kCGInterpolationDefault; 1394 1416 switch (mode) { … … 1414 1436 void GraphicsContext::setIsCALayerContext(bool isLayerContext) 1415 1437 { 1438 if (paintingDisabled()) 1439 return; 1440 1416 1441 if (isLayerContext) 1417 1442 m_data->m_contextFlags |= IsLayerCGContext; … … 1422 1447 bool GraphicsContext::isCALayerContext() const 1423 1448 { 1449 if (paintingDisabled()) 1450 return false; 1451 1424 1452 return m_data->m_contextFlags & IsLayerCGContext; 1425 1453 } … … 1427 1455 void GraphicsContext::setIsAcceleratedContext(bool isAccelerated) 1428 1456 { 1457 if (paintingDisabled()) 1458 return; 1459 1429 1460 if (isAccelerated) 1430 1461 m_data->m_contextFlags |= IsAcceleratedCGContext; … … 1435 1466 bool GraphicsContext::isAcceleratedContext() const 1436 1467 { 1468 if (paintingDisabled()) 1469 return false; 1470 1437 1471 return m_data->m_contextFlags & IsAcceleratedCGContext; 1438 1472 } … … 1614 1648 void GraphicsContext::platformApplyDeviceScaleFactor(float deviceScaleFactor) 1615 1649 { 1650 if (paintingDisabled()) 1651 return; 1652 1616 1653 // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it. 1617 1654 // Failing to change the base level CTM will cause certain CG features, such as focus rings, -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
r194421 r194798 69 69 70 70 GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha) 71 : m_updatingControlTints(false),72 m_transparencyCount(0)73 71 { 74 72 platformInit(hdc, hasAlpha); … … 77 75 void GraphicsContext::platformInit(HDC hdc, bool hasAlpha) 78 76 { 77 if (!hdc) 78 return; 79 79 80 m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha)); 80 81 CGContextRelease(m_data->m_cgContext.get()); 81 82 m_data->m_hdc = hdc; 82 setPaintingDisabled(!m_data->m_cgContext);83 83 if (m_data->m_cgContext) { 84 84 // Make sure the context starts in sync with our state. -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
r192140 r194798 68 68 69 69 GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha) 70 : m_updatingControlTints(false),71 m_transparencyCount(0)72 70 { 73 71 platformInit(dc, hasAlpha); … … 76 74 void GraphicsContext::platformInit(HDC dc, bool hasAlpha) 77 75 { 78 cairo_t* cr = 0; 79 if (dc) 80 cr = createCairoContextWithHDC(dc, hasAlpha); 81 else 82 setPaintingDisabled(true); 76 if (!dc) 77 return; 78 79 cairo_t* cr = createCairoContextWithHDC(dc, hasAlpha); 83 80 84 81 m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
Note:
See TracChangeset
for help on using the changeset viewer.