Changeset 194816 in webkit
- Timestamp:
- Jan 8, 2016, 10:07:33 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/GraphicsContext.cpp (modified) (1 diff)
-
platform/graphics/cairo/GraphicsContextCairo.cpp (modified) (42 diffs)
-
platform/graphics/cg/GraphicsContextCG.cpp (modified) (56 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194814 r194816 1 2016-01-08 Simon Fraser <simon.fraser@apple.com> 2 3 Add display-list drawing hooks to platform-specific GraphicsContext files 4 https://bugs.webkit.org/show_bug.cgi?id=152940 5 6 Reviewed by Zalan Bujtas. 7 8 Call into the display list recorder for top-level entrypoints implemented in platform-specific 9 files. 10 11 The convention is that if a function begins with "platform", it's not a top-level 12 entry point, and should only be called when there's a platform context (i.e. not 13 recording, and not paintingDisabled). 14 15 A few instances are stubbed out until we have a more complete display list implementation. 16 17 * platform/graphics/GraphicsContext.cpp: 18 (WebCore::GraphicsContext::drawText): 19 * platform/graphics/cairo/GraphicsContextCairo.cpp: 20 (WebCore::GraphicsContext::getCTM): 21 (WebCore::GraphicsContext::savePlatformState): 22 (WebCore::GraphicsContext::restorePlatformState): 23 (WebCore::GraphicsContext::drawRect): 24 (WebCore::GraphicsContext::drawNativeImage): 25 (WebCore::GraphicsContext::drawLine): 26 (WebCore::GraphicsContext::drawEllipse): 27 (WebCore::GraphicsContext::drawConvexPolygon): 28 (WebCore::GraphicsContext::clipConvexPolygon): 29 (WebCore::GraphicsContext::fillPath): 30 (WebCore::GraphicsContext::strokePath): 31 (WebCore::GraphicsContext::fillRect): 32 (WebCore::GraphicsContext::clip): 33 (WebCore::GraphicsContext::clipPath): 34 (WebCore::GraphicsContext::clipBounds): 35 (WebCore::GraphicsContext::drawLinesForText): 36 (WebCore::GraphicsContext::roundToDevicePixels): 37 (WebCore::GraphicsContext::translate): 38 (WebCore::GraphicsContext::setPlatformStrokeThickness): 39 (WebCore::GraphicsContext::setPlatformStrokeStyle): 40 (WebCore::GraphicsContext::concatCTM): 41 (WebCore::GraphicsContext::setCTM): 42 (WebCore::GraphicsContext::beginPlatformTransparencyLayer): 43 (WebCore::GraphicsContext::endPlatformTransparencyLayer): 44 (WebCore::GraphicsContext::clearRect): 45 (WebCore::GraphicsContext::strokeRect): 46 (WebCore::GraphicsContext::setLineCap): 47 (WebCore::GraphicsContext::setLineDash): 48 (WebCore::GraphicsContext::setLineJoin): 49 (WebCore::GraphicsContext::clipOut): 50 (WebCore::GraphicsContext::rotate): 51 (WebCore::GraphicsContext::scale): 52 (WebCore::GraphicsContext::platformFillRoundedRect): 53 (WebCore::GraphicsContext::fillRectWithRoundedHole): 54 (WebCore::GraphicsContext::drawPattern): 55 (WebCore::GraphicsContext::setPlatformShouldAntialias): 56 (WebCore::GraphicsContext::setPlatformImageInterpolationQuality): 57 (WebCore::GraphicsContext::isAcceleratedContext): 58 * platform/graphics/cg/GraphicsContextCG.cpp: 59 (WebCore::GraphicsContext::savePlatformState): 60 (WebCore::GraphicsContext::restorePlatformState): 61 (WebCore::GraphicsContext::drawNativeImage): 62 (WebCore::GraphicsContext::drawPattern): 63 (WebCore::GraphicsContext::drawRect): 64 (WebCore::GraphicsContext::drawLine): 65 (WebCore::GraphicsContext::drawEllipse): 66 (WebCore::GraphicsContext::drawConvexPolygon): 67 (WebCore::GraphicsContext::clipConvexPolygon): 68 (WebCore::GraphicsContext::applyStrokePattern): 69 (WebCore::GraphicsContext::applyFillPattern): 70 (WebCore::GraphicsContext::drawPath): 71 (WebCore::GraphicsContext::fillPath): 72 (WebCore::GraphicsContext::strokePath): 73 (WebCore::GraphicsContext::fillRect): 74 (WebCore::GraphicsContext::platformFillRoundedRect): 75 (WebCore::GraphicsContext::fillRectWithRoundedHole): 76 (WebCore::GraphicsContext::clip): 77 (WebCore::GraphicsContext::clipOut): 78 (WebCore::GraphicsContext::clipPath): 79 (WebCore::GraphicsContext::clipBounds): 80 (WebCore::GraphicsContext::beginPlatformTransparencyLayer): 81 (WebCore::GraphicsContext::endPlatformTransparencyLayer): 82 (WebCore::GraphicsContext::setPlatformShadow): 83 (WebCore::GraphicsContext::setMiterLimit): 84 (WebCore::GraphicsContext::clearRect): 85 (WebCore::GraphicsContext::strokeRect): 86 (WebCore::GraphicsContext::setLineCap): 87 (WebCore::GraphicsContext::setLineDash): 88 (WebCore::GraphicsContext::setLineJoin): 89 (WebCore::GraphicsContext::scale): 90 (WebCore::GraphicsContext::rotate): 91 (WebCore::GraphicsContext::translate): 92 (WebCore::GraphicsContext::concatCTM): 93 (WebCore::GraphicsContext::setCTM): 94 (WebCore::GraphicsContext::getCTM): 95 (WebCore::GraphicsContext::roundToDevicePixels): 96 (WebCore::GraphicsContext::drawLinesForText): 97 (WebCore::GraphicsContext::setURLForRect): 98 (WebCore::GraphicsContext::setIsCALayerContext): 99 (WebCore::GraphicsContext::isCALayerContext): 100 (WebCore::GraphicsContext::setIsAcceleratedContext): 101 (WebCore::GraphicsContext::isAcceleratedContext): 102 (WebCore::GraphicsContext::setPlatformTextDrawingMode): 103 (WebCore::GraphicsContext::setPlatformStrokeColor): 104 (WebCore::GraphicsContext::setPlatformStrokeThickness): 105 (WebCore::GraphicsContext::setPlatformFillColor): 106 (WebCore::GraphicsContext::setPlatformShouldAntialias): 107 (WebCore::GraphicsContext::setPlatformShouldSmoothFonts): 108 (WebCore::GraphicsContext::setPlatformAlpha): 109 (WebCore::GraphicsContext::setPlatformCompositeOperation): 110 (WebCore::GraphicsContext::platformApplyDeviceScaleFactor): 111 (WebCore::GraphicsContext::platformFillEllipse): 112 (WebCore::GraphicsContext::platformStrokeEllipse): 113 1 114 2016-01-08 Simon Fraser <simon.fraser@apple.com> 2 115 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r194814 r194816 683 683 return 0; 684 684 685 if (isRecording()) { 686 // FIXME: Text drawing with display lists TBD. 687 return 0; 688 } 689 685 690 return font.drawText(*this, run, point, from, to); 686 691 } -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r194798 r194816 38 38 #include "AffineTransform.h" 39 39 #include "CairoUtilities.h" 40 #include "DisplayListRecorder.h" 40 41 #include "DrawErrorUnderline.h" 41 42 #include "FloatConversion.h" … … 202 203 return AffineTransform(); 203 204 205 if (isRecording()) { 206 WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts."); 207 return AffineTransform(); 208 } 209 204 210 cairo_t* cr = platformContext()->cr(); 205 211 cairo_matrix_t m; … … 215 221 void GraphicsContext::savePlatformState() 216 222 { 223 ASSERT(!isRecording()); 217 224 platformContext()->save(); 218 225 m_data->save(); … … 221 228 void GraphicsContext::restorePlatformState() 222 229 { 230 ASSERT(!isRecording()); 223 231 platformContext()->restore(); 224 232 m_data->restore(); … … 231 239 232 240 // Draws a filled rectangle with a stroked border. 233 void GraphicsContext::drawRect(const FloatRect& rect, float) 234 { 235 if (paintingDisabled()) 236 return; 241 void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness) 242 { 243 if (paintingDisabled()) 244 return; 245 246 if (isRecording()) { 247 m_displayListRecorder->drawRect(rect, borderThickness); 248 return; 249 } 237 250 238 251 ASSERT(!rect.isEmpty()); … … 248 261 r.inflate(-.5f); 249 262 cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height()); 250 cairo_set_line_width(cr, 1.0); 263 cairo_set_line_width(cr, 1.0); // borderThickness? 251 264 cairo_stroke(cr); 252 265 } … … 257 270 void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation) 258 271 { 259 UNUSED_PARAM(imageSize); 272 if (paintingDisabled()) 273 return; 274 275 if (isRecording()) { 276 m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation); 277 return; 278 } 260 279 261 280 NativeImagePtr image = imagePtr; … … 295 314 if (strokeStyle() == NoStroke) 296 315 return; 316 317 if (isRecording()) { 318 m_displayListRecorder->drawLine(point1, point2); 319 return; 320 } 297 321 298 322 const Color& strokeColor = this->strokeColor(); … … 385 409 return; 386 410 411 if (isRecording()) { 412 m_displayListRecorder->drawEllipse(rect); 413 return; 414 } 415 387 416 cairo_t* cr = platformContext()->cr(); 388 417 cairo_save(cr); … … 415 444 return; 416 445 446 if (isRecording()) { 447 m_displayListRecorder->drawConvexPolygon(npoints, points, shouldAntialias); 448 return; 449 } 450 417 451 cairo_t* cr = platformContext()->cr(); 418 452 … … 445 479 return; 446 480 481 if (isRecording()) { 482 m_displayListRecorder->clipConvexPolygon(numPoints, points, antialiased); 483 return; 484 } 485 447 486 cairo_t* cr = platformContext()->cr(); 448 487 … … 465 504 return; 466 505 506 if (isRecording()) { 507 m_displayListRecorder->fillPath(path); 508 return; 509 } 510 467 511 cairo_t* cr = platformContext()->cr(); 468 512 setPathOnCairoContext(cr, path.platformPath()->context()); … … 475 519 return; 476 520 521 if (isRecording()) { 522 m_displayListRecorder->strokePath(path); 523 return; 524 } 525 477 526 cairo_t* cr = platformContext()->cr(); 478 527 setPathOnCairoContext(cr, path.platformPath()->context()); … … 485 534 return; 486 535 536 if (isRecording()) { 537 m_displayListRecorder->fillRect(rect); 538 return; 539 } 540 487 541 cairo_t* cr = platformContext()->cr(); 488 542 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); … … 495 549 return; 496 550 551 if (isRecording()) { 552 m_displayListRecorder->fillRect(rect, color); 553 return; 554 } 555 497 556 if (hasShadow()) 498 557 platformContext()->shadowBlur().drawRectShadow(*this, FloatRoundedRect(rect)); … … 505 564 if (paintingDisabled()) 506 565 return; 566 567 if (isRecording()) { 568 m_displayListRecorder->clip(rect); 569 return; 570 } 507 571 508 572 cairo_t* cr = platformContext()->cr(); … … 528 592 return; 529 593 594 if (isRecording()) { 595 m_displayListRecorder->clipPath(path, clipRule); 596 return; 597 } 598 530 599 cairo_t* cr = platformContext()->cr(); 531 600 if (!path.isNull()) … … 553 622 IntRect GraphicsContext::clipBounds() const 554 623 { 624 if (paintingDisabled()) 625 return IntRect(); 626 627 if (isRecording()) { 628 WTFLogAlways("Getting the clip bounds not yet supported with display lists"); 629 return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists. 630 } 631 555 632 double x1, x2, y1, y2; 556 633 cairo_clip_extents(platformContext()->cr(), &x1, &y1, &x2, &y2); … … 664 741 return; 665 742 743 if (isRecording()) { 744 m_displayListRecorder->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness()); 745 return; 746 } 747 666 748 Color localStrokeColor(strokeColor()); 667 749 … … 721 803 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode) 722 804 { 805 if (paintingDisabled()) 806 return frect; 807 808 if (!isRecording()) { 809 WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts."); 810 return frect; 811 } 812 723 813 FloatRect result; 724 814 double x = frect.x(); … … 761 851 return; 762 852 853 if (isRecording()) { 854 m_displayListRecorder->translate(x, y); 855 return; 856 } 857 763 858 cairo_t* cr = platformContext()->cr(); 764 859 cairo_translate(cr, x, y); … … 783 878 return; 784 879 880 ASSERT(!isRecording()); 881 785 882 cairo_set_line_width(platformContext()->cr(), strokeThickness); 786 883 } … … 793 890 if (paintingDisabled()) 794 891 return; 892 893 ASSERT(!isRecording()); 795 894 796 895 switch (strokeStyle) { … … 823 922 return; 824 923 924 if (isRecording()) { 925 m_displayListRecorder->concatCTM(transform); 926 return; 927 } 928 825 929 cairo_t* cr = platformContext()->cr(); 826 930 const cairo_matrix_t matrix = cairo_matrix_t(transform); … … 833 937 if (paintingDisabled()) 834 938 return; 939 940 if (isRecording()) { 941 WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts."); 942 return; 943 } 835 944 836 945 cairo_t* cr = platformContext()->cr(); … … 871 980 return; 872 981 982 ASSERT(!isRecording()); 983 873 984 cairo_t* cr = platformContext()->cr(); 874 985 cairo_push_group(cr); … … 880 991 if (paintingDisabled()) 881 992 return; 993 994 ASSERT(!isRecording()); 882 995 883 996 cairo_t* cr = platformContext()->cr(); … … 897 1010 if (paintingDisabled()) 898 1011 return; 1012 1013 if (isRecording()) { 1014 m_displayListRecorder->clearRect(rect); 1015 return; 1016 } 899 1017 900 1018 cairo_t* cr = platformContext()->cr(); … … 912 1030 return; 913 1031 1032 if (isRecording()) { 1033 m_displayListRecorder->strokeRect(rect, width); 1034 return; 1035 } 1036 914 1037 cairo_t* cr = platformContext()->cr(); 915 1038 cairo_save(cr); … … 924 1047 if (paintingDisabled()) 925 1048 return; 1049 1050 if (isRecording()) { 1051 m_displayListRecorder->setLineCap(lineCap); 1052 return; 1053 } 926 1054 927 1055 cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT; … … 951 1079 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) 952 1080 { 1081 if (paintingDisabled()) 1082 return; 1083 1084 if (isRecording()) { 1085 m_displayListRecorder->setLineDash(dashes, dashOffset); 1086 return; 1087 } 1088 953 1089 if (isDashArrayAllZero(dashes)) 954 1090 cairo_set_dash(platformContext()->cr(), 0, 0, 0); … … 961 1097 if (paintingDisabled()) 962 1098 return; 1099 1100 if (isRecording()) { 1101 m_displayListRecorder->setLineJoin(lineJoin); 1102 return; 1103 } 963 1104 964 1105 cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER; … … 1014 1155 return; 1015 1156 1157 if (isRecording()) { 1158 m_displayListRecorder->clipOut(path); 1159 return; 1160 } 1161 1016 1162 cairo_t* cr = platformContext()->cr(); 1017 1163 double x1, y1, x2, y2; … … 1031 1177 return; 1032 1178 1179 if (isRecording()) { 1180 m_displayListRecorder->rotate(radians); 1181 return; 1182 } 1183 1033 1184 cairo_rotate(platformContext()->cr(), radians); 1034 1185 m_data->rotate(radians); … … 1040 1191 return; 1041 1192 1193 if (isRecording()) { 1194 m_displayListRecorder->scale(size); 1195 return; 1196 } 1197 1042 1198 cairo_scale(platformContext()->cr(), size.width(), size.height()); 1043 1199 m_data->scale(size); … … 1048 1204 if (paintingDisabled()) 1049 1205 return; 1206 1207 if (isRecording()) { 1208 m_displayListRecorder->clipOut(r); 1209 return; 1210 } 1050 1211 1051 1212 cairo_t* cr = platformContext()->cr(); … … 1065 1226 return; 1066 1227 1228 ASSERT(!isRecording()); 1229 1067 1230 if (hasShadow()) 1068 1231 platformContext()->shadowBlur().drawRectShadow(*this, rect); … … 1083 1246 return; 1084 1247 1248 if (isRecording()) { 1249 m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color); 1250 return; 1251 } 1252 1085 1253 if (this->mustUseShadowBlur()) 1086 1254 platformContext()->shadowBlur().drawInsetShadow(*this, rect, roundedHoleRect); … … 1100 1268 } 1101 1269 1102 void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, CompositeOperator op, const FloatRect& destRect, BlendMode) 1103 { 1270 void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode) 1271 { 1272 if (paintingDisabled()) 1273 return; 1274 1275 if (isRecording()) { 1276 m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode); 1277 return; 1278 } 1279 1104 1280 RefPtr<cairo_surface_t> surface = image.nativeImageForCurrentFrame(); 1105 1281 if (!surface) // If it's too early we won't have an image yet. … … 1114 1290 if (paintingDisabled()) 1115 1291 return; 1292 1293 ASSERT(!isRecording()); 1116 1294 1117 1295 // When true, use the default Cairo backend antialias mode (usually this … … 1123 1301 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality) 1124 1302 { 1303 ASSERT(!isRecording()); 1304 1125 1305 platformContext()->setImageInterpolationQuality(quality); 1126 1306 } … … 1128 1308 bool GraphicsContext::isAcceleratedContext() const 1129 1309 { 1310 if (isRecording()) 1311 return false; 1312 1130 1313 return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL; 1131 1314 } -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r194798 r194816 30 30 #include "AffineTransform.h" 31 31 #include "CoreGraphicsSPI.h" 32 #include "DisplayListRecorder.h" 32 33 #include "FloatConversion.h" 33 34 #include "GraphicsContextPlatformPrivateCG.h" … … 142 143 { 143 144 ASSERT(!paintingDisabled()); 145 ASSERT(!isRecording()); 146 144 147 // Note: Do not use this function within this class implementation, since we want to avoid the extra 145 148 // save of the secondary context (in GraphicsContextPlatformPrivateCG.h). … … 151 154 { 152 155 ASSERT(!paintingDisabled()); 156 ASSERT(!isRecording()); 157 153 158 // Note: Do not use this function within this class implementation, since we want to avoid the extra 154 159 // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h). … … 162 167 if (paintingDisabled()) 163 168 return; 169 170 if (isRecording()) { 171 m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation); 172 return; 173 } 164 174 165 175 RetainPtr<CGImageRef> image(imagePtr); … … 279 289 if (paintingDisabled() || !patternTransform.isInvertible()) 280 290 return; 291 292 if (isRecording()) { 293 m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode); 294 return; 295 } 281 296 282 297 CGContextRef context = platformContext(); … … 380 395 return; 381 396 397 if (isRecording()) { 398 m_displayListRecorder->drawRect(rect, borderThickness); 399 return; 400 } 401 382 402 // FIXME: this function does not handle patterns and gradients like drawPath does, it probably should. 383 403 ASSERT(!rect.isEmpty()); … … 412 432 if (strokeStyle() == NoStroke) 413 433 return; 434 435 if (isRecording()) { 436 m_displayListRecorder->drawLine(point1, point2); 437 return; 438 } 414 439 415 440 float thickness = strokeThickness(); … … 498 523 return; 499 524 525 if (isRecording()) { 526 m_displayListRecorder->drawEllipse(rect); 527 return; 528 } 529 500 530 Path path; 501 531 path.addEllipse(rect); … … 521 551 return; 522 552 553 if (isRecording()) { 554 m_displayListRecorder->drawConvexPolygon(numberOfPoints, points, antialiased); 555 return; 556 } 557 523 558 CGContextRef context = platformContext(); 524 559 … … 542 577 return; 543 578 579 if (isRecording()) { 580 m_displayListRecorder->clipConvexPolygon(numberOfPoints, points, antialias); 581 return; 582 } 583 544 584 CGContextRef context = platformContext(); 545 585 … … 560 600 return; 561 601 602 if (isRecording()) { 603 m_displayListRecorder->applyStrokePattern(); 604 return; 605 } 606 562 607 CGContextRef cgContext = platformContext(); 563 608 AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext)); … … 578 623 if (paintingDisabled()) 579 624 return; 625 626 if (isRecording()) { 627 m_displayListRecorder->applyFillPattern(); 628 return; 629 } 580 630 581 631 CGContextRef cgContext = platformContext(); … … 625 675 return; 626 676 677 if (isRecording()) { 678 m_displayListRecorder->drawPath(path); 679 return; 680 } 681 627 682 CGContextRef context = platformContext(); 628 683 const GraphicsContextState& state = m_state; … … 661 716 if (paintingDisabled() || path.isEmpty()) 662 717 return; 718 719 if (isRecording()) { 720 m_displayListRecorder->fillPath(path); 721 return; 722 } 663 723 664 724 CGContextRef context = platformContext(); … … 715 775 if (paintingDisabled() || path.isEmpty()) 716 776 return; 777 778 if (isRecording()) { 779 m_displayListRecorder->strokePath(path); 780 return; 781 } 717 782 718 783 CGContextRef context = platformContext(); … … 773 838 return; 774 839 840 if (isRecording()) { 841 m_displayListRecorder->fillRect(rect); 842 return; 843 } 844 775 845 CGContextRef context = platformContext(); 776 846 … … 821 891 return; 822 892 893 if (isRecording()) { 894 m_displayListRecorder->fillRect(rect, color); 895 return; 896 } 897 823 898 CGContextRef context = platformContext(); 824 899 Color oldFillColor = fillColor(); … … 850 925 if (paintingDisabled()) 851 926 return; 927 928 ASSERT(!isRecording()); 852 929 853 930 CGContextRef context = platformContext(); … … 892 969 return; 893 970 971 if (isRecording()) { 972 m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color); 973 return; 974 } 975 894 976 CGContextRef context = platformContext(); 895 977 … … 933 1015 return; 934 1016 1017 if (isRecording()) { 1018 m_displayListRecorder->clip(rect); 1019 return; 1020 } 1021 935 1022 CGContextClipToRect(platformContext(), rect); 936 1023 m_data->clip(rect); … … 941 1028 if (paintingDisabled()) 942 1029 return; 1030 1031 if (isRecording()) { 1032 m_displayListRecorder->clipOut(rect); 1033 return; 1034 } 943 1035 944 1036 // FIXME: Using CGRectInfinite is much faster than getting the clip bounding box. However, due … … 954 1046 } 955 1047 1048 void GraphicsContext::clipOut(const Path& path) 1049 { 1050 if (paintingDisabled()) 1051 return; 1052 1053 if (isRecording()) { 1054 m_displayListRecorder->clipOut(path); 1055 return; 1056 } 1057 1058 CGContextBeginPath(platformContext()); 1059 CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext())); 1060 if (!path.isEmpty()) 1061 CGContextAddPath(platformContext(), path.platformPath()); 1062 CGContextEOClip(platformContext()); 1063 } 1064 956 1065 void GraphicsContext::clipPath(const Path& path, WindRule clipRule) 957 1066 { 958 1067 if (paintingDisabled()) 959 1068 return; 1069 1070 if (isRecording()) { 1071 m_displayListRecorder->clipPath(path, clipRule); 1072 return; 1073 } 960 1074 961 1075 CGContextRef context = platformContext(); … … 980 1094 return IntRect(); 981 1095 1096 if (isRecording()) { 1097 WTFLogAlways("Getting the clip bounds not yet supported with display lists"); 1098 return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists. 1099 } 1100 1101 982 1102 return enclosingIntRect(CGContextGetClipBoundingBox(platformContext())); 983 1103 } … … 987 1107 if (paintingDisabled()) 988 1108 return; 1109 1110 ASSERT(!isRecording()); 989 1111 990 1112 save(); … … 1000 1122 if (paintingDisabled()) 1001 1123 return; 1124 1125 ASSERT(!isRecording()); 1126 1002 1127 CGContextRef context = platformContext(); 1003 1128 CGContextEndTransparencyLayer(context); … … 1043 1168 if (paintingDisabled()) 1044 1169 return; 1170 1171 ASSERT(!isRecording()); 1045 1172 1046 1173 // FIXME: we could avoid the shadow setup cost when we know we'll render the shadow ourselves. … … 1093 1220 if (paintingDisabled()) 1094 1221 return; 1222 1223 if (isRecording()) { 1224 // Maybe this should be part of the state. 1225 m_displayListRecorder->setMiterLimit(limit); 1226 return; 1227 } 1228 1095 1229 CGContextSetMiterLimit(platformContext(), limit); 1096 1230 } … … 1100 1234 if (paintingDisabled()) 1101 1235 return; 1236 1237 if (isRecording()) { 1238 m_displayListRecorder->clearRect(r); 1239 return; 1240 } 1241 1102 1242 CGContextClearRect(platformContext(), r); 1103 1243 } … … 1107 1247 if (paintingDisabled()) 1108 1248 return; 1249 1250 if (isRecording()) { 1251 m_displayListRecorder->strokeRect(rect, lineWidth); 1252 return; 1253 } 1109 1254 1110 1255 CGContextRef context = platformContext(); … … 1172 1317 if (paintingDisabled()) 1173 1318 return; 1319 1320 if (isRecording()) { 1321 m_displayListRecorder->setLineCap(cap); 1322 return; 1323 } 1324 1174 1325 switch (cap) { 1175 1326 case ButtCap: … … 1190 1341 return; 1191 1342 1343 if (isRecording()) { 1344 m_displayListRecorder->setLineDash(dashes, dashOffset); 1345 return; 1346 } 1347 1192 1348 if (dashOffset < 0) { 1193 1349 float length = 0; … … 1204 1360 if (paintingDisabled()) 1205 1361 return; 1362 1363 if (isRecording()) { 1364 m_displayListRecorder->setLineJoin(join); 1365 return; 1366 } 1367 1206 1368 switch (join) { 1207 1369 case MiterJoin: … … 1222 1384 } 1223 1385 1224 void GraphicsContext::clipOut(const Path& path)1225 {1226 if (paintingDisabled())1227 return;1228 1229 CGContextBeginPath(platformContext());1230 CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));1231 if (!path.isEmpty())1232 CGContextAddPath(platformContext(), path.platformPath());1233 CGContextEOClip(platformContext());1234 }1235 1236 1386 void GraphicsContext::scale(const FloatSize& size) 1237 1387 { 1238 1388 if (paintingDisabled()) 1239 1389 return; 1390 1391 if (isRecording()) { 1392 m_displayListRecorder->scale(size); 1393 return; 1394 } 1395 1240 1396 CGContextScaleCTM(platformContext(), size.width(), size.height()); 1241 1397 m_data->scale(size); … … 1247 1403 if (paintingDisabled()) 1248 1404 return; 1405 1406 if (isRecording()) { 1407 m_displayListRecorder->rotate(angle); 1408 return; 1409 } 1410 1249 1411 CGContextRotateCTM(platformContext(), angle); 1250 1412 m_data->rotate(angle); … … 1256 1418 if (paintingDisabled()) 1257 1419 return; 1420 1421 if (isRecording()) { 1422 m_displayListRecorder->translate(x, y); 1423 return; 1424 } 1425 1258 1426 CGContextTranslateCTM(platformContext(), x, y); 1259 1427 m_data->translate(x, y); … … 1265 1433 if (paintingDisabled()) 1266 1434 return; 1435 1436 if (isRecording()) { 1437 m_displayListRecorder->concatCTM(transform); 1438 return; 1439 } 1440 1267 1441 CGContextConcatCTM(platformContext(), transform); 1268 1442 m_data->concatCTM(transform); … … 1274 1448 if (paintingDisabled()) 1275 1449 return; 1450 1451 if (isRecording()) { 1452 WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts."); 1453 return; 1454 } 1455 1276 1456 CGContextSetCTM(platformContext(), transform); 1277 1457 m_data->setCTM(transform); … … 1283 1463 if (paintingDisabled()) 1284 1464 return AffineTransform(); 1465 1466 if (isRecording()) { 1467 WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts."); 1468 return AffineTransform(); 1469 } 1285 1470 1286 1471 // The CTM usually includes the deviceScaleFactor except in WebKit 1 when the … … 1297 1482 if (paintingDisabled()) 1298 1483 return rect; 1484 1485 if (!isRecording()) { 1486 WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts."); 1487 return rect; 1488 } 1299 1489 1300 1490 // It is not enough just to round to pixels in device space. The rotation part of the … … 1356 1546 return; 1357 1547 1548 if (isRecording()) { 1549 m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeThickness()); 1550 return; 1551 } 1552 1358 1553 Color localStrokeColor(strokeColor()); 1359 1554 … … 1387 1582 if (paintingDisabled()) 1388 1583 return; 1584 1585 if (isRecording()) { 1586 WTFLogAlways("GraphicsContext::setURLForRect() is not yet compatible with recording contexts."); 1587 return; // FIXME for display lists. 1588 } 1389 1589 1390 1590 RetainPtr<CFURLRef> urlRef = link.createCFURL(); … … 1439 1639 return; 1440 1640 1641 // FIXME 1642 if (isRecording()) 1643 return; 1644 1441 1645 if (isLayerContext) 1442 1646 m_data->m_contextFlags |= IsLayerCGContext; … … 1450 1654 return false; 1451 1655 1656 // FIXME 1657 if (isRecording()) 1658 return false; 1659 1452 1660 return m_data->m_contextFlags & IsLayerCGContext; 1453 1661 } … … 1456 1664 { 1457 1665 if (paintingDisabled()) 1666 return; 1667 1668 // FIXME 1669 if (isRecording()) 1458 1670 return; 1459 1671 … … 1469 1681 return false; 1470 1682 1683 // FIXME 1684 if (isRecording()) 1685 return false; 1686 1471 1687 return m_data->m_contextFlags & IsAcceleratedCGContext; 1472 1688 } … … 1476 1692 if (paintingDisabled()) 1477 1693 return; 1694 1695 ASSERT(!isRecording()); 1478 1696 1479 1697 CGContextRef context = platformContext(); … … 1497 1715 if (paintingDisabled()) 1498 1716 return; 1717 1718 ASSERT(!isRecording()); 1719 1499 1720 setCGStrokeColor(platformContext(), color); 1500 1721 } … … 1504 1725 if (paintingDisabled()) 1505 1726 return; 1727 1728 ASSERT(!isRecording()); 1729 1506 1730 CGContextSetLineWidth(platformContext(), std::max(thickness, 0.f)); 1507 1731 } … … 1511 1735 if (paintingDisabled()) 1512 1736 return; 1737 1738 ASSERT(!isRecording()); 1739 1513 1740 setCGFillColor(platformContext(), color); 1514 1741 } … … 1518 1745 if (paintingDisabled()) 1519 1746 return; 1747 1748 ASSERT(!isRecording()); 1749 1520 1750 CGContextSetShouldAntialias(platformContext(), enable); 1521 1751 } … … 1525 1755 if (paintingDisabled()) 1526 1756 return; 1757 1758 ASSERT(!isRecording()); 1759 1527 1760 CGContextSetShouldSmoothFonts(platformContext(), enable); 1528 1761 } … … 1532 1765 if (paintingDisabled()) 1533 1766 return; 1767 1768 ASSERT(!isRecording()); 1769 1534 1770 CGContextSetAlpha(platformContext(), alpha); 1535 1771 } … … 1539 1775 if (paintingDisabled()) 1540 1776 return; 1777 1778 ASSERT(!isRecording()); 1541 1779 1542 1780 CGBlendMode target = kCGBlendModeNormal; … … 1651 1889 return; 1652 1890 1891 ASSERT(!isRecording()); 1892 1653 1893 // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it. 1654 1894 // Failing to change the base level CTM will cause certain CG features, such as focus rings, … … 1662 1902 return; 1663 1903 1904 ASSERT(!isRecording()); 1905 1664 1906 // CGContextFillEllipseInRect only supports solid colors. 1665 1907 if (m_state.fillGradient || m_state.fillPattern) { … … 1677 1919 return; 1678 1920 1921 ASSERT(!isRecording()); 1922 1679 1923 // CGContextStrokeEllipseInRect only supports solid colors. 1680 1924 if (m_state.strokeGradient || m_state.strokePattern) {
Note:
See TracChangeset
for help on using the changeset viewer.