Changeset 104861 in webkit
- Timestamp:
- Jan 12, 2012 2:39:25 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r104860 r104861 1 2012-01-12 Dana Jansens <danakj@chromium.org> 2 3 [skia] Track a simple opaque area when painting via PlatformContextSkia and save in LayerTextureUpdater 4 https://bugs.webkit.org/show_bug.cgi?id=74352 5 6 Reviewed by Stephen White. 7 8 New unit tests in PlatformContextSkiaTest.cpp 9 10 * WebCore.gypi: 11 * platform/graphics/skia/GraphicsContextSkia.cpp: 12 (WebCore::GraphicsContext::clearRect): 13 (WebCore::GraphicsContext::drawConvexPolygon): 14 (WebCore::GraphicsContext::drawEllipse): 15 (WebCore::drawOuterPath): 16 (WebCore::drawInnerPath): 17 (WebCore::GraphicsContext::drawFocusRing): 18 (WebCore::GraphicsContext::drawLine): 19 (WebCore::GraphicsContext::drawLineForTextChecking): 20 (WebCore::GraphicsContext::drawLineForText): 21 (WebCore::GraphicsContext::fillPath): 22 (WebCore::GraphicsContext::fillRect): 23 (WebCore::GraphicsContext::fillRoundedRect): 24 (WebCore::GraphicsContext::strokeArc): 25 (WebCore::GraphicsContext::strokePath): 26 (WebCore::GraphicsContext::strokeRect): 27 * platform/graphics/skia/ImageSkia.cpp: 28 (WebCore::paintSkBitmap): 29 * platform/graphics/skia/OpaqueRegionSkia.cpp: Added. 30 (WebCore::OpaqueRegionSkia::OpaqueRegionSkia): 31 (WebCore::OpaqueRegionSkia::~OpaqueRegionSkia): 32 (WebCore::OpaqueRegionSkia::asRect): 33 (WebCore::xfermodeIsOpaque): 34 (WebCore::xfermodePreservesOpaque): 35 (WebCore::paintIsOpaque): 36 (WebCore::OpaqueRegionSkia::didDrawRect): 37 (WebCore::OpaqueRegionSkia::didDrawPath): 38 (WebCore::OpaqueRegionSkia::didDrawPoints): 39 (WebCore::OpaqueRegionSkia::didDrawBounded): 40 (WebCore::OpaqueRegionSkia::didDraw): 41 (WebCore::OpaqueRegionSkia::didDrawUnbounded): 42 (WebCore::OpaqueRegionSkia::markRectAsOpaque): 43 (WebCore::OpaqueRegionSkia::markRectAsNonOpaque): 44 * platform/graphics/skia/OpaqueRegionSkia.h: Added. 45 * platform/graphics/skia/PlatformContextSkia.cpp: 46 (WebCore::PlatformContextSkia::PlatformContextSkia): 47 (WebCore::PlatformContextSkia::clippedToImage): 48 (WebCore::PlatformContextSkia::drawRect): 49 (WebCore::PlatformContextSkia::paintSkPaint): 50 (WebCore::PlatformContextSkia::didDrawRect): 51 (WebCore::PlatformContextSkia::didDrawPath): 52 (WebCore::PlatformContextSkia::didDrawPoints): 53 (WebCore::PlatformContextSkia::didDrawBounded): 54 * platform/graphics/skia/PlatformContextSkia.h: 55 (WebCore::PlatformContextSkia::setTrackOpaqueRegion): 56 (WebCore::PlatformContextSkia::opaqueRegion): 57 1 58 2012-01-12 Beth Dakin <bdakin@apple.com> 2 59 -
trunk/Source/WebCore/WebCore.gypi
r104848 r104861 3929 3929 'platform/graphics/skia/NativeImageSkia.cpp', 3930 3930 'platform/graphics/skia/NativeImageSkia.h', 3931 'platform/graphics/skia/OpaqueRegionSkia.cpp', 3932 'platform/graphics/skia/OpaqueRegionSkia.h', 3931 3933 'platform/graphics/skia/PathSkia.cpp', 3932 3934 'platform/graphics/skia/PatternSkia.cpp', -
trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
r104609 r104861 340 340 paint.setXfermodeMode(SkXfermode::kClear_Mode); 341 341 platformContext()->canvas()->drawRect(r, paint); 342 platformContext()->didDrawRect(r, paint); 342 343 } 343 344 … … 474 475 paint.setAntiAlias(shouldAntialias); 475 476 platformContext()->canvas()->drawPath(path, paint); 477 platformContext()->didDrawPath(path, paint); 476 478 477 479 if (strokeStyle() != NoStroke) { … … 479 481 platformContext()->setupPaintForStroking(&paint, 0, 0); 480 482 platformContext()->canvas()->drawPath(path, paint); 483 platformContext()->didDrawPath(path, paint); 481 484 } 482 485 } … … 514 517 platformContext()->setupPaintForFilling(&paint); 515 518 platformContext()->canvas()->drawOval(rect, paint); 519 platformContext()->didDrawBounded(rect, paint); 516 520 517 521 if (strokeStyle() != NoStroke) { … … 519 523 platformContext()->setupPaintForStroking(&paint, &rect, 0); 520 524 platformContext()->canvas()->drawOval(rect, paint); 525 platformContext()->didDrawBounded(rect, paint); 521 526 } 522 527 } … … 527 532 } 528 533 529 static inline void drawOuterPath( SkCanvas* canvas, const SkPath& path, SkPaint& paint, int width)534 static inline void drawOuterPath(PlatformContextSkia* context, const SkPath& path, SkPaint& paint, int width) 530 535 { 531 536 #if PLATFORM(CHROMIUM) && OS(DARWIN) … … 537 542 paint.setPathEffect(new SkCornerPathEffect(1))->unref(); 538 543 #endif 539 canvas->drawPath(path, paint); 540 } 541 542 static inline void drawInnerPath(SkCanvas* canvas, const SkPath& path, SkPaint& paint, int width) 544 context->canvas()->drawPath(path, paint); 545 context->didDrawPath(path, paint); 546 } 547 548 static inline void drawInnerPath(PlatformContextSkia* context, const SkPath& path, SkPaint& paint, int width) 543 549 { 544 550 #if PLATFORM(CHROMIUM) && OS(DARWIN) 545 551 paint.setAlpha(128); 546 552 paint.setStrokeWidth(width * 0.5f); 547 canvas->drawPath(path, paint); 553 context->canvas()->drawPath(path, paint); 554 context->didDrawPath(path, paint); 548 555 #endif 549 556 } … … 582 589 paint.setColor(color.rgb()); 583 590 focusRingRegion.getBoundaryPath(&path); 584 SkCanvas* canvas = platformContext()->canvas(); 585 drawOuterPath(canvas, path, paint, width); 586 drawInnerPath(canvas, path, paint, width); 591 drawOuterPath(platformContext(), path, paint, width); 592 drawInnerPath(platformContext(), path, paint, width); 587 593 } 588 594 … … 632 638 platformContext()->canvas()->drawRect(r1, fillPaint); 633 639 platformContext()->canvas()->drawRect(r2, fillPaint); 640 platformContext()->didDrawRect(r1, fillPaint); 641 platformContext()->didDrawRect(r2, fillPaint); 634 642 } 635 643 … … 638 646 639 647 platformContext()->canvas()->drawPoints(SkCanvas::kLines_PointMode, 2, pts, paint); 648 platformContext()->didDrawPoints(SkCanvas::kLines_PointMode, 2, pts, paint); 640 649 } 641 650 … … 713 722 originY + SkIntToScalar(misspellBitmap->height())); 714 723 platformContext()->canvas()->drawRect(rect, paint); 724 platformContext()->didDrawRect(rect, paint); 715 725 } 716 726 … … 737 747 paint.setColor(platformContext()->effectiveStrokeColor()); 738 748 platformContext()->canvas()->drawRect(r, paint); 749 platformContext()->didDrawRect(r, paint); 739 750 } 740 751 … … 771 782 772 783 platformContext()->canvas()->drawPath(path, paint); 784 platformContext()->didDrawPath(path, paint); 773 785 } 774 786 … … 789 801 platformContext()->setupPaintForFilling(&paint); 790 802 platformContext()->canvas()->drawRect(r, paint); 803 platformContext()->didDrawRect(r, paint); 791 804 792 805 platformContext()->restore(); … … 817 830 paint.setColor(color.rgb()); 818 831 platformContext()->canvas()->drawRect(r, paint); 832 platformContext()->didDrawRect(r, paint); 819 833 } 820 834 … … 856 870 paint.setColor(color.rgb()); 857 871 platformContext()->canvas()->drawPath(path, paint); 872 platformContext()->didDrawPath(path, paint); 858 873 } 859 874 … … 1140 1155 return; 1141 1156 platformContext()->canvas()->drawPath(path, paint); 1157 platformContext()->didDrawPath(path, paint); 1142 1158 } 1143 1159 … … 1154 1170 platformContext()->setupPaintForStroking(&paint, 0, 0); 1155 1171 platformContext()->canvas()->drawPath(path, paint); 1172 platformContext()->didDrawPath(path, paint); 1156 1173 } 1157 1174 … … 1174 1191 bool validH = r.height() > 0; 1175 1192 SkCanvas* canvas = platformContext()->canvas(); 1176 if (validW && validH) 1193 if (validW && validH) { 1177 1194 canvas->drawRect(r, paint); 1178 else if (validW || validH) { 1195 platformContext()->didDrawRect(r, paint); 1196 } else if (validW || validH) { 1179 1197 // we are expected to respect the lineJoin, so we can't just call 1180 1198 // drawLine -- we have to create a path that doubles back on itself. … … 1184 1202 path.close(); 1185 1203 canvas->drawPath(path, paint); 1204 platformContext()->didDrawPath(path, paint); 1186 1205 } 1187 1206 } -
trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp
r103041 r104861 249 249 canvas->drawBitmapRect(bitmap.bitmap(), &srcRect, destRect, &paint); 250 250 } 251 platformContext->didDrawRect(destRect, paint, &bitmap.bitmap()); 251 252 } 252 253 -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
r103091 r104861 180 180 PlatformContextSkia::PlatformContextSkia(SkCanvas* canvas) 181 181 : m_canvas(canvas) 182 , m_trackOpaqueRegion(false) 182 183 , m_printing(false) 183 184 , m_deferred(false) … … 267 268 } 268 269 270 const SkBitmap& PlatformContextSkia::clippedToImage() const 271 { 272 return m_state->m_imageBufferClip; 273 } 274 269 275 void PlatformContextSkia::restore() 270 276 { … … 288 294 setupPaintForFilling(&paint); 289 295 canvas()->drawRect(rect, paint); 296 didDrawRect(rect, paint); 290 297 } 291 298 … … 300 307 SkRect topBorder = { rect.fLeft, rect.fTop, rect.fRight, rect.fTop + 1 }; 301 308 canvas()->drawRect(topBorder, paint); 309 didDrawRect(topBorder, paint); 302 310 SkRect bottomBorder = { rect.fLeft, rect.fBottom - 1, rect.fRight, rect.fBottom }; 303 311 canvas()->drawRect(bottomBorder, paint); 312 didDrawRect(bottomBorder, paint); 304 313 SkRect leftBorder = { rect.fLeft, rect.fTop + 1, rect.fLeft + 1, rect.fBottom - 1 }; 305 314 canvas()->drawRect(leftBorder, paint); 315 didDrawRect(leftBorder, paint); 306 316 SkRect rightBorder = { rect.fRight - 1, rect.fTop + 1, rect.fRight, rect.fBottom - 1 }; 307 317 canvas()->drawRect(rightBorder, paint); 318 didDrawRect(rightBorder, paint); 308 319 } 309 320 } … … 540 551 { 541 552 m_canvas->drawRect(rect, paint); 553 didDrawRect(rect, paint); 542 554 } 543 555 … … 598 610 } 599 611 612 void PlatformContextSkia::didDrawRect(const SkRect& rect, const SkPaint& paint, const SkBitmap* bitmap) 613 { 614 if (m_trackOpaqueRegion) 615 m_opaqueRegion.didDrawRect(this, rect, paint, bitmap); 616 } 617 618 void PlatformContextSkia::didDrawPath(const SkPath& path, const SkPaint& paint) 619 { 620 if (m_trackOpaqueRegion) 621 m_opaqueRegion.didDrawPath(this, path, paint); 622 } 623 624 void PlatformContextSkia::didDrawPoints(SkCanvas::PointMode mode, int numPoints, const SkPoint points[], const SkPaint& paint) 625 { 626 if (m_trackOpaqueRegion) 627 m_opaqueRegion.didDrawPoints(this, mode, numPoints, points, paint); 628 } 629 630 void PlatformContextSkia::didDrawBounded(const SkRect& rect, const SkPaint& paint) 631 { 632 if (m_trackOpaqueRegion) 633 m_opaqueRegion.didDrawBounded(this, rect, paint); 634 } 635 600 636 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
r103091 r104861 34 34 #include "GraphicsContext.h" 35 35 #include "Noncopyable.h" 36 #include "OpaqueRegionSkia.h" 36 37 37 38 #include "SkCanvas.h" … … 99 100 void beginLayerClippedToImage(const FloatRect&, const ImageBuffer*); 100 101 void clipPathAntiAliased(const SkPath&); 102 // If non-empty, the layer is clipped to the bitmap. 103 const SkBitmap& clippedToImage() const; 101 104 102 105 // Sets up the common flags on a paint for antialiasing, effects, etc. … … 188 191 void setDeferred(bool deferred) { m_deferred = deferred; } 189 192 193 void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; } 194 195 // This will be an empty region unless tracking is enabled. 196 const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; } 197 198 // After drawing in the context's canvas, use these functions to notify the context so it can track the opaque region. 199 void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0); 200 void didDrawPath(const SkPath&, const SkPaint&); 201 void didDrawPoints(SkCanvas::PointMode, int numPoints, const SkPoint[], const SkPaint&); 202 // For drawing operations that do not fill the entire rect. 203 void didDrawBounded(const SkRect&, const SkPaint&); 204 190 205 private: 191 206 // Used when restoring and the state has an image clip. Only shows the pixels in … … 210 225 // mStateStack.back(). 211 226 State* m_state; 227 228 // Tracks the region painted opaque via the GraphicsContext. 229 OpaqueRegionSkia m_opaqueRegion; 230 bool m_trackOpaqueRegion; 212 231 213 232 // Stores image sizes for a hint to compute image resampling modes. -
trunk/Source/WebKit/chromium/ChangeLog
r104844 r104861 1 2012-01-12 Dana Jansens <danakj@chromium.org> 2 3 [skia] Track a simple opaque area when painting via PlatformContextSkia and save in LayerTextureUpdater 4 https://bugs.webkit.org/show_bug.cgi?id=74352 5 6 Reviewed by Stephen White. 7 8 * WebKit.gypi: 9 * tests/PlatformContextSkiaTest.cpp: Added. 10 (WebCore::TEST): 11 1 12 2012-01-12 Nat Duca <nduca@chromium.org> 2 13 -
trunk/Source/WebKit/chromium/WebKit.gypi
r104626 r104861 120 120 'tests/DragImageTest.cpp', 121 121 'tests/ImageLayerChromiumTest.cpp', 122 'tests/PlatformContextSkiaTest.cpp', 122 123 ], 123 124 }],
Note: See TracChangeset
for help on using the changeset viewer.