Changeset 194814 in webkit
- Timestamp:
- Jan 8, 2016, 5:41:27 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/GraphicsContext.cpp (modified) (30 diffs)
-
platform/graphics/GraphicsContext.h (modified) (9 diffs)
-
platform/graphics/displaylists/DisplayList.cpp (modified) (1 diff)
-
platform/graphics/displaylists/DisplayList.h (modified) (1 diff)
-
platform/graphics/displaylists/DisplayListRecorder.cpp (modified) (2 diffs)
-
platform/graphics/displaylists/DisplayListRecorder.h (modified) (1 diff)
-
platform/graphics/displaylists/DisplayListReplayer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194800 r194814 1 2016-01-08 Simon Fraser <simon.fraser@apple.com> 2 3 Add DisplayList hooks into GraphicsContext 4 https://bugs.webkit.org/show_bug.cgi?id=152932 5 6 Reviewed by Zalan Bujtas. 7 8 Add the hooks into GraphicsContext that call into the DisplayListRecorder if there 9 is one. 10 11 Rename size() to something less ambiguous. 12 13 Out-of-line some DisplayList functions so that the header doesn't need to see 14 DisplayListItems.h. 15 16 * platform/graphics/GraphicsContext.cpp: 17 (WebCore::GraphicsContext::save): 18 (WebCore::GraphicsContext::restore): 19 (WebCore::GraphicsContext::setStrokeThickness): 20 (WebCore::GraphicsContext::setStrokeStyle): 21 (WebCore::GraphicsContext::setStrokeColor): 22 (WebCore::GraphicsContext::setShadow): 23 (WebCore::GraphicsContext::setLegacyShadow): 24 (WebCore::GraphicsContext::clearShadow): 25 (WebCore::GraphicsContext::setFillColor): 26 (WebCore::GraphicsContext::setShadowsIgnoreTransforms): 27 (WebCore::GraphicsContext::setShouldAntialias): 28 (WebCore::GraphicsContext::setShouldSmoothFonts): 29 (WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts): 30 (WebCore::GraphicsContext::setImageInterpolationQuality): 31 (WebCore::GraphicsContext::setAntialiasedFontDilationEnabled): 32 (WebCore::GraphicsContext::setStrokePattern): 33 (WebCore::GraphicsContext::setFillPattern): 34 (WebCore::GraphicsContext::setStrokeGradient): 35 (WebCore::GraphicsContext::setFillRule): 36 (WebCore::GraphicsContext::setFillGradient): 37 (WebCore::GraphicsContext::beginTransparencyLayer): 38 (WebCore::GraphicsContext::endTransparencyLayer): 39 (WebCore::GraphicsContext::drawGlyphs): 40 (WebCore::GraphicsContext::drawImage): 41 (WebCore::GraphicsContext::drawTiledImage): 42 (WebCore::GraphicsContext::setTextDrawingMode): 43 (WebCore::GraphicsContext::fillRect): 44 (WebCore::GraphicsContext::fillRoundedRect): 45 (WebCore::GraphicsContext::setAlpha): 46 (WebCore::GraphicsContext::setCompositeOperation): 47 (WebCore::GraphicsContext::setDrawLuminanceMask): 48 (WebCore::GraphicsContext::applyDeviceScaleFactor): 49 (WebCore::GraphicsContext::applyState): 50 * platform/graphics/GraphicsContext.h: 51 (WebCore::GraphicsContext::setDisplayListRecorder): 52 (WebCore::GraphicsContext::isRecording): 53 (WebCore::GraphicsContext::setFillRule): Deleted. 54 (WebCore::GraphicsContext::setShadowsIgnoreTransforms): Deleted. 55 (WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts): Deleted. 56 (WebCore::GraphicsContext::setDrawLuminanceMask): Deleted. 57 * platform/graphics/displaylists/DisplayList.cpp: 58 (WebCore::DisplayList::DisplayList::clear): 59 (WebCore::DisplayList::DisplayList::removeItemsFromIndex): 60 * platform/graphics/displaylists/DisplayList.h: 61 (WebCore::DisplayList::DisplayList::itemCount): 62 (WebCore::DisplayList::DisplayList::clear): Deleted. 63 (WebCore::DisplayList::DisplayList::size): Deleted. 64 (WebCore::DisplayList::DisplayList::removeItemsFromIndex): Deleted. 65 * platform/graphics/displaylists/DisplayListRecorder.cpp: 66 (WebCore::DisplayList::Recorder::save): 67 (WebCore::DisplayList::Recorder::restore): 68 * platform/graphics/displaylists/DisplayListRecorder.h: 69 (WebCore::DisplayList::Recorder::itemCount): 70 (WebCore::DisplayList::Recorder::size): Deleted. 71 * platform/graphics/displaylists/DisplayListReplayer.cpp: 72 (WebCore::DisplayList::Replayer::replay): 73 1 74 2016-01-08 Brady Eidson <beidson@apple.com> 2 75 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r194798 r194814 29 29 #include "BidiResolver.h" 30 30 #include "BitmapImage.h" 31 #include "DisplayListRecorder.h" 31 32 #include "FloatRoundedRect.h" 32 33 #include "Gradient.h" … … 384 385 m_stack.append(m_state); 385 386 387 if (isRecording()) { 388 m_displayListRecorder->save(); 389 return; 390 } 391 386 392 savePlatformState(); 387 393 } … … 404 410 m_stack.clear(); 405 411 412 if (isRecording()) { 413 m_displayListRecorder->restore(); 414 return; 415 } 416 406 417 restorePlatformState(); 407 418 } … … 430 441 { 431 442 m_state.strokeThickness = thickness; 443 if (isRecording()) { 444 m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeThicknessChange); 445 return; 446 } 447 432 448 setPlatformStrokeThickness(thickness); 433 449 } … … 436 452 { 437 453 m_state.strokeStyle = style; 454 if (isRecording()) { 455 m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeStyleChange); 456 return; 457 } 438 458 setPlatformStrokeStyle(style); 439 459 } … … 444 464 m_state.strokeGradient = nullptr; 445 465 m_state.strokePattern = nullptr; 466 if (isRecording()) { 467 m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeColorChange); 468 return; 469 } 446 470 setPlatformStrokeColor(color); 447 471 } … … 452 476 m_state.shadowBlur = blur; 453 477 m_state.shadowColor = color; 478 #if USE(CG) 479 m_state.shadowsUseLegacyRadius = false; 480 #endif 481 if (isRecording()) { 482 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowChange); 483 return; 484 } 454 485 setPlatformShadow(offset, blur, color); 455 486 } … … 463 494 m_state.shadowsUseLegacyRadius = true; 464 495 #endif 496 if (isRecording()) { 497 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowChange); 498 return; 499 } 465 500 setPlatformShadow(offset, blur, color); 466 501 } … … 471 506 m_state.shadowBlur = 0; 472 507 m_state.shadowColor = Color(); 508 #if USE(CG) 509 m_state.shadowsUseLegacyRadius = false; 510 #endif 511 512 if (isRecording()) { 513 m_displayListRecorder->clearShadow(); 514 return; 515 } 473 516 clearPlatformShadow(); 474 517 } … … 506 549 m_state.fillGradient = nullptr; 507 550 m_state.fillPattern = nullptr; 551 552 if (isRecording()) { 553 m_displayListRecorder->updateState(m_state, GraphicsContextState::FillColorChange); 554 return; 555 } 556 508 557 setPlatformFillColor(color); 509 558 } 510 559 560 void GraphicsContext::setShadowsIgnoreTransforms(bool shadowsIgnoreTransforms) 561 { 562 m_state.shadowsIgnoreTransforms = shadowsIgnoreTransforms; 563 if (isRecording()) 564 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowsIgnoreTransformsChange); 565 } 566 511 567 void GraphicsContext::setShouldAntialias(bool shouldAntialias) 512 568 { 513 569 m_state.shouldAntialias = shouldAntialias; 570 571 if (isRecording()) { 572 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldAntialiasChange); 573 return; 574 } 575 514 576 setPlatformShouldAntialias(shouldAntialias); 515 577 } … … 518 580 { 519 581 m_state.shouldSmoothFonts = shouldSmoothFonts; 582 583 if (isRecording()) { 584 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldSmoothFontsChange); 585 return; 586 } 587 520 588 setPlatformShouldSmoothFonts(shouldSmoothFonts); 521 589 } 522 590 591 void GraphicsContext::setShouldSubpixelQuantizeFonts(bool shouldSubpixelQuantizeFonts) 592 { 593 m_state.shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts; 594 if (isRecording()) 595 m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldSubpixelQuantizeFontsChange); 596 } 597 523 598 void GraphicsContext::setImageInterpolationQuality(InterpolationQuality imageInterpolationQuality) 524 599 { … … 528 603 return; 529 604 605 if (isRecording()) { 606 m_displayListRecorder->updateState(m_state, GraphicsContextState::ImageInterpolationQualityChange); 607 return; 608 } 609 530 610 setPlatformImageInterpolationQuality(imageInterpolationQuality); 531 611 } … … 534 614 { 535 615 m_state.antialiasedFontDilationEnabled = antialiasedFontDilationEnabled; 616 if (isRecording()) 617 m_displayListRecorder->updateState(m_state, GraphicsContextState::AntialiasedFontDilationEnabledChange); 536 618 } 537 619 … … 540 622 m_state.strokeGradient = nullptr; 541 623 m_state.strokePattern = WTFMove(pattern); 624 if (isRecording()) 625 m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokePatternChange); 542 626 } 543 627 … … 546 630 m_state.fillGradient = nullptr; 547 631 m_state.fillPattern = WTFMove(pattern); 632 if (isRecording()) 633 m_displayListRecorder->updateState(m_state, GraphicsContextState::FillPatternChange); 548 634 } 549 635 … … 552 638 m_state.strokeGradient = WTFMove(gradient); 553 639 m_state.strokePattern = nullptr; 640 if (isRecording()) 641 m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeGradientChange); 642 } 643 644 void GraphicsContext::setFillRule(WindRule fillRule) 645 { 646 m_state.fillRule = fillRule; 647 if (isRecording()) 648 m_displayListRecorder->updateState(m_state, GraphicsContextState::FillRuleChange); 554 649 } 555 650 … … 558 653 m_state.fillGradient = WTFMove(gradient); 559 654 m_state.fillPattern = nullptr; 655 if (isRecording()) 656 m_displayListRecorder->updateState(m_state, GraphicsContextState::FillGradientChange); // FIXME: also fill pattern? 560 657 } 561 658 562 659 void GraphicsContext::beginTransparencyLayer(float opacity) 563 660 { 661 if (isRecording()) { 662 m_displayListRecorder->beginTransparencyLayer(opacity); 663 return; 664 } 564 665 beginPlatformTransparencyLayer(opacity); 565 666 ++m_transparencyCount; … … 568 669 void GraphicsContext::endTransparencyLayer() 569 670 { 671 if (isRecording()) { 672 m_displayListRecorder->endTransparencyLayer(); 673 return; 674 } 570 675 endPlatformTransparencyLayer(); 571 676 ASSERT(m_transparencyCount > 0); … … 585 690 if (paintingDisabled()) 586 691 return; 692 693 if (isRecording()) { 694 m_displayListRecorder->drawGlyphs(font, buffer, from, numGlyphs, point, fontCascade.fontDescription().fontSmoothing()); 695 return; 696 } 587 697 588 698 fontCascade.drawGlyphs(*this, font, buffer, from, numGlyphs, point); … … 652 762 return; 653 763 764 if (isRecording()) { 765 m_displayListRecorder->drawImage(image, destination, source, imagePaintingOptions); 766 return; 767 } 768 654 769 // FIXME (49002): Should be InterpolationLow 655 770 InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_useLowQualityScale ? InterpolationNone : imageInterpolationQuality()); … … 662 777 return; 663 778 779 if (isRecording()) { 780 m_displayListRecorder->drawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions); 781 return; 782 } 783 664 784 InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_useLowQualityScale ? InterpolationLow : imageInterpolationQuality()); 665 785 image.drawTiled(*this, destination, source, tileSize, spacing, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode); … … 671 791 if (paintingDisabled()) 672 792 return; 793 794 if (isRecording()) { 795 m_displayListRecorder->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions); 796 return; 797 } 673 798 674 799 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { … … 767 892 if (paintingDisabled()) 768 893 return; 894 895 if (isRecording()) { 896 m_displayListRecorder->updateState(m_state, GraphicsContextState::TextDrawingModeChange); 897 return; 898 } 769 899 setPlatformTextDrawingMode(mode); 770 900 } … … 774 904 if (paintingDisabled()) 775 905 return; 906 907 if (isRecording()) { 908 m_displayListRecorder->fillRect(rect, gradient); 909 return; 910 } 911 776 912 gradient.fill(this, rect); 777 913 } … … 781 917 if (paintingDisabled()) 782 918 return; 919 920 if (isRecording()) { 921 m_displayListRecorder->fillRect(rect, color, op, blendMode); 922 return; 923 } 783 924 784 925 CompositeOperator previousOperator = compositeOperation(); … … 792 933 if (paintingDisabled()) 793 934 return; 935 936 if (isRecording()) { 937 m_displayListRecorder->fillRoundedRect(rect, color, blendMode); 938 return; 939 } 794 940 795 941 if (rect.isRounded()) { … … 831 977 { 832 978 m_state.alpha = alpha; 979 if (isRecording()) { 980 m_displayListRecorder->updateState(m_state, GraphicsContextState::AlphaChange); 981 return; 982 } 833 983 setPlatformAlpha(alpha); 834 984 } … … 838 988 m_state.compositeOperator = compositeOperation; 839 989 m_state.blendMode = blendMode; 990 if (isRecording()) { 991 m_displayListRecorder->updateState(m_state, GraphicsContextState::CompositeOperationChange); 992 return; 993 } 840 994 setPlatformCompositeOperation(compositeOperation, blendMode); 995 } 996 997 void GraphicsContext::setDrawLuminanceMask(bool drawLuminanceMask) 998 { 999 m_state.drawLuminanceMask = drawLuminanceMask; 1000 if (isRecording()) 1001 m_displayListRecorder->updateState(m_state, GraphicsContextState::DrawLuminanceMaskChange); 841 1002 } 842 1003 … … 935 1096 { 936 1097 scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); 1098 1099 if (isRecording()) { 1100 m_displayListRecorder->applyDeviceScaleFactor(deviceScaleFactor); 1101 return; 1102 } 1103 937 1104 platformApplyDeviceScaleFactor(deviceScaleFactor); 938 1105 } … … 1014 1181 } 1015 1182 1016 } 1183 void GraphicsContext::applyState(const GraphicsContextState& state) 1184 { 1185 setPlatformShadow(state.shadowOffset, state.shadowBlur, state.shadowColor); 1186 setPlatformStrokeThickness(state.strokeThickness); 1187 setPlatformTextDrawingMode(state.textDrawingMode); 1188 setPlatformStrokeColor(state.strokeColor); 1189 setPlatformFillColor(state.fillColor); 1190 setPlatformStrokeStyle(state.strokeStyle); 1191 setPlatformAlpha(state.alpha); 1192 setPlatformCompositeOperation(state.compositeOperator, state.blendMode); 1193 setPlatformShouldAntialias(state.shouldAntialias); 1194 setPlatformShouldSmoothFonts(state.shouldSmoothFonts); 1195 } 1196 1197 } -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r194798 r194814 110 110 InterpolationHigh 111 111 }; 112 113 namespace DisplayList { 114 class Recorder; 115 } 112 116 113 117 struct GraphicsContextState { … … 247 251 public: 248 252 WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*); 253 GraphicsContext() = default; 249 254 WEBCORE_EXPORT ~GraphicsContext(); 250 255 … … 257 262 WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const; 258 263 259 bool paintingDisabled() const { return !m_data ; }264 bool paintingDisabled() const { return !m_data && !isRecording(); } 260 265 bool updatingControlTints() const { return m_nonPaintingReasons == NonPaintingReasons::UpdatingControlTints; } 266 267 void setDisplayListRecorder(DisplayList::Recorder* recorder) { m_displayListRecorder = recorder; } 268 bool isRecording() const { return m_displayListRecorder; } 261 269 262 270 void setStrokeThickness(float); … … 275 283 Gradient* strokeGradient() const { return m_state.strokeGradient.get(); } 276 284 277 void setFillRule(WindRule fillRule) { m_state.fillRule = fillRule; }285 void setFillRule(WindRule); 278 286 WindRule fillRule() const { return m_state.fillRule; } 279 287 … … 287 295 Gradient* fillGradient() const { return m_state.fillGradient.get(); } 288 296 289 void setShadowsIgnoreTransforms(bool shadowsIgnoreTransforms) { m_state.shadowsIgnoreTransforms = shadowsIgnoreTransforms; }297 void setShadowsIgnoreTransforms(bool); 290 298 bool shadowsIgnoreTransforms() const { return m_state.shadowsIgnoreTransforms; } 291 299 … … 301 309 // Normally CG enables subpixel-quantization because it improves the performance of aligning glyphs. 302 310 // In some cases we have to disable to to ensure a high-quality output of the glyphs. 303 void setShouldSubpixelQuantizeFonts(bool shouldSubpixelQuantizeFonts) { m_state.shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts; }311 void setShouldSubpixelQuantizeFonts(bool); 304 312 bool shouldSubpixelQuantizeFonts() const { return m_state.shouldSubpixelQuantizeFonts; } 305 313 … … 394 402 void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady); 395 403 404 void applyState(const GraphicsContextState&); 405 396 406 enum RoundingMode { 397 407 RoundAllSides, … … 453 463 BlendMode blendModeOperation() const { return m_state.blendMode; } 454 464 455 void setDrawLuminanceMask(bool drawLuminanceMask) { m_state.drawLuminanceMask = drawLuminanceMask; }465 void setDrawLuminanceMask(bool); 456 466 bool drawLuminanceMask() const { return m_state.drawLuminanceMask; } 457 467 … … 603 613 604 614 GraphicsContextPlatformPrivate* m_data { nullptr }; 615 DisplayList::Recorder* m_displayListRecorder { nullptr }; 605 616 606 617 GraphicsContextState m_state; -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp
r194708 r194814 49 49 #endif 50 50 51 void DisplayList::clear() 52 { 53 m_list.clear(); 54 } 55 56 void DisplayList::removeItemsFromIndex(size_t index) 57 { 58 m_list.resize(index); 59 } 60 51 61 void DisplayList::dump(TextStream& ts) const 52 62 { -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h
r194708 r194814 59 59 } 60 60 61 void clear() { m_list.clear(); }62 size_t size() const { return m_list.size(); }61 void clear(); 62 void removeItemsFromIndex(size_t); 63 63 64 void removeItemsFromIndex(size_t index) 65 { 66 m_list.resize(index); 67 } 68 64 size_t itemCount() const { return m_list.size(); } 69 65 size_t sizeInBytes() const; 70 66 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
r194708 r194814 144 144 { 145 145 appendItem(Save::create()); 146 m_stateStack.append(m_stateStack.last().cloneForSave(m_displayList. size() - 1));146 m_stateStack.append(m_stateStack.last().cloneForSave(m_displayList.itemCount() - 1)); 147 147 } 148 148 … … 169 169 if (saveIndex) { 170 170 Save& saveItem = downcast<Save>(m_displayList.itemAt(saveIndex)); 171 saveItem.setRestoreIndex(m_displayList. size() - 1);171 saveItem.setRestoreIndex(m_displayList.itemCount() - 1); 172 172 } 173 173 } -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
r194708 r194814 121 121 void applyDeviceScaleFactor(float); 122 122 123 size_t size() const { return m_displayList.size(); }123 size_t itemCount() const { return m_displayList.itemCount(); } 124 124 125 125 private: -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp
r194708 r194814 51 51 UNUSED_PARAM(initialClip); 52 52 53 size_t numItems = m_displayList. size();53 size_t numItems = m_displayList.itemCount(); 54 54 for (size_t i = 0; i < numItems; ++i) { 55 55 auto& item = m_displayList.list()[i].get();
Note:
See TracChangeset
for help on using the changeset viewer.