OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 // mark the bounds as non-opaque. | 565 // mark the bounds as non-opaque. |
566 SkPaint paint; | 566 SkPaint paint; |
567 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 567 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
568 m_trackedRegion.didDrawBounded(this, displayList->bounds(), paint); | 568 m_trackedRegion.didDrawBounded(this, displayList->bounds(), paint); |
569 } | 569 } |
570 | 570 |
571 if (performClip || performTransform) | 571 if (performClip || performTransform) |
572 restore(); | 572 restore(); |
573 } | 573 } |
574 | 574 |
575 void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin
ts, bool shouldAntialias) | 575 void GraphicsContext::fillPolygon(size_t numPoints, const FloatPoint* points, co
nst Color& color, |
| 576 bool shouldAntialias) |
576 { | 577 { |
577 if (contextDisabled()) | 578 if (contextDisabled()) |
578 return; | 579 return; |
579 | 580 |
580 if (numPoints <= 1) | 581 ASSERT(numPoints > 2); |
581 return; | |
582 | 582 |
583 SkPath path; | 583 SkPath path; |
584 setPathFromConvexPoints(&path, numPoints, points); | 584 setPathFromPoints(&path, numPoints, points); |
585 | 585 |
586 SkPaint paint(immutableState()->fillPaint()); | 586 SkPaint paint(immutableState()->fillPaint()); |
587 paint.setAntiAlias(shouldAntialias); | 587 paint.setAntiAlias(shouldAntialias); |
| 588 paint.setColor(color.rgb()); |
| 589 |
588 drawPath(path, paint); | 590 drawPath(path, paint); |
589 | |
590 if (strokeStyle() != NoStroke) | |
591 drawPath(path, immutableState()->strokePaint()); | |
592 } | 591 } |
593 | 592 |
594 float GraphicsContext::prepareFocusRingPaint(SkPaint& paint, const Color& color,
int width) const | 593 float GraphicsContext::prepareFocusRingPaint(SkPaint& paint, const Color& color,
int width) const |
595 { | 594 { |
596 paint.setAntiAlias(true); | 595 paint.setAntiAlias(true); |
597 paint.setStyle(SkPaint::kStroke_Style); | 596 paint.setStyle(SkPaint::kStroke_Style); |
598 paint.setColor(color.rgb()); | 597 paint.setColor(color.rgb()); |
599 paint.setStrokeWidth(focusRingWidth(width)); | 598 paint.setStrokeWidth(focusRingWidth(width)); |
600 | 599 |
601 #if OS(MACOSX) | 600 #if OS(MACOSX) |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 SkPath& path = const_cast<SkPath&>(pathToClip.skPath()); | 1524 SkPath& path = const_cast<SkPath&>(pathToClip.skPath()); |
1526 SkPath::FillType previousFillType = path.getFillType(); | 1525 SkPath::FillType previousFillType = path.getFillType(); |
1527 | 1526 |
1528 SkPath::FillType temporaryFillType = WebCoreWindRuleToSkFillType(clipRule); | 1527 SkPath::FillType temporaryFillType = WebCoreWindRuleToSkFillType(clipRule); |
1529 path.setFillType(temporaryFillType); | 1528 path.setFillType(temporaryFillType); |
1530 clipPath(path, AntiAliased); | 1529 clipPath(path, AntiAliased); |
1531 | 1530 |
1532 path.setFillType(previousFillType); | 1531 path.setFillType(previousFillType); |
1533 } | 1532 } |
1534 | 1533 |
1535 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
ts, bool antialiased) | 1534 void GraphicsContext::clipPolygon(size_t numPoints, const FloatPoint* points, bo
ol antialiased) |
1536 { | 1535 { |
1537 if (contextDisabled()) | 1536 if (contextDisabled()) |
1538 return; | 1537 return; |
1539 | 1538 |
1540 if (numPoints <= 1) | 1539 ASSERT(numPoints > 2); |
1541 return; | |
1542 | 1540 |
1543 SkPath path; | 1541 SkPath path; |
1544 setPathFromConvexPoints(&path, numPoints, points); | 1542 setPathFromPoints(&path, numPoints, points); |
1545 clipPath(path, antialiased ? AntiAliased : NotAntiAliased); | 1543 clipPath(path, antialiased ? AntiAliased : NotAntiAliased); |
1546 } | 1544 } |
1547 | 1545 |
1548 void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect) | 1546 void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect) |
1549 { | 1547 { |
1550 if (contextDisabled()) | 1548 if (contextDisabled()) |
1551 return; | 1549 return; |
1552 | 1550 |
1553 clipRoundedRect(rect, SkRegion::kDifference_Op); | 1551 clipRoundedRect(rect, SkRegion::kDifference_Op); |
1554 } | 1552 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 if (!surface->isValid()) | 1789 if (!surface->isValid()) |
1792 return nullptr; | 1790 return nullptr; |
1793 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); | 1791 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); |
1794 | 1792 |
1795 buffer->context()->scale(static_cast<float>(scaledSize.width()) / size.width
(), | 1793 buffer->context()->scale(static_cast<float>(scaledSize.width()) / size.width
(), |
1796 static_cast<float>(scaledSize.height()) / size.height()); | 1794 static_cast<float>(scaledSize.height()) / size.height()); |
1797 | 1795 |
1798 return buffer.release(); | 1796 return buffer.release(); |
1799 } | 1797 } |
1800 | 1798 |
1801 void GraphicsContext::setPathFromConvexPoints(SkPath* path, size_t numPoints, co
nst FloatPoint* points) | 1799 void GraphicsContext::setPathFromPoints(SkPath* path, size_t numPoints, const Fl
oatPoint* points) |
1802 { | 1800 { |
1803 path->incReserve(numPoints); | 1801 path->incReserve(numPoints); |
1804 path->moveTo(WebCoreFloatToSkScalar(points[0].x()), | 1802 path->moveTo(WebCoreFloatToSkScalar(points[0].x()), |
1805 WebCoreFloatToSkScalar(points[0].y())); | 1803 WebCoreFloatToSkScalar(points[0].y())); |
1806 for (size_t i = 1; i < numPoints; ++i) { | 1804 for (size_t i = 1; i < numPoints; ++i) { |
1807 path->lineTo(WebCoreFloatToSkScalar(points[i].x()), | 1805 path->lineTo(WebCoreFloatToSkScalar(points[i].x()), |
1808 WebCoreFloatToSkScalar(points[i].y())); | 1806 WebCoreFloatToSkScalar(points[i].y())); |
1809 } | 1807 } |
1810 | |
1811 /* The code used to just blindly call this | |
1812 path->setIsConvex(true); | |
1813 But webkit can sometimes send us non-convex 4-point values, so we mark t
he path's | |
1814 convexity as unknown, so it will get computed by skia at draw time. | |
1815 See crbug.com 108605 | |
1816 */ | |
1817 SkPath::Convexity convexity = SkPath::kConvex_Convexity; | |
1818 if (numPoints == 4) | |
1819 convexity = SkPath::kUnknown_Convexity; | |
1820 path->setConvexity(convexity); | |
1821 } | 1808 } |
1822 | 1809 |
1823 void GraphicsContext::setRadii(SkVector* radii, IntSize topLeft, IntSize topRigh
t, IntSize bottomRight, IntSize bottomLeft) | 1810 void GraphicsContext::setRadii(SkVector* radii, IntSize topLeft, IntSize topRigh
t, IntSize bottomRight, IntSize bottomLeft) |
1824 { | 1811 { |
1825 radii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(topLeft.width()), | 1812 radii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(topLeft.width()), |
1826 SkIntToScalar(topLeft.height())); | 1813 SkIntToScalar(topLeft.height())); |
1827 radii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(topRight.width()), | 1814 radii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(topRight.width()), |
1828 SkIntToScalar(topRight.height())); | 1815 SkIntToScalar(topRight.height())); |
1829 radii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(bottomRight.width()), | 1816 radii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(bottomRight.width()), |
1830 SkIntToScalar(bottomRight.height())); | 1817 SkIntToScalar(bottomRight.height())); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag | 1977 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag |
1991 // being set to true). We need to decide if we respect InterpolationNone | 1978 // being set to true). We need to decide if we respect InterpolationNone |
1992 // being returned from computeInterpolationQuality. | 1979 // being returned from computeInterpolationQuality. |
1993 resampling = InterpolationLow; | 1980 resampling = InterpolationLow; |
1994 } | 1981 } |
1995 resampling = limitInterpolationQuality(this, resampling); | 1982 resampling = limitInterpolationQuality(this, resampling); |
1996 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); | 1983 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); |
1997 } | 1984 } |
1998 | 1985 |
1999 } // namespace blink | 1986 } // namespace blink |
OLD | NEW |