OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "SkGeometry.h" | 28 #include "SkGeometry.h" |
29 #include "SkGlyphCache.h" | 29 #include "SkGlyphCache.h" |
30 #include "SkHRESULT.h" | 30 #include "SkHRESULT.h" |
31 #include "SkImageEncoder.h" | 31 #include "SkImageEncoder.h" |
32 #include "SkIStream.h" | 32 #include "SkIStream.h" |
33 #include "SkMaskFilter.h" | 33 #include "SkMaskFilter.h" |
34 #include "SkPaint.h" | 34 #include "SkPaint.h" |
35 #include "SkPathEffect.h" | 35 #include "SkPathEffect.h" |
36 #include "SkPathOps.h" | 36 #include "SkPathOps.h" |
37 #include "SkPoint.h" | 37 #include "SkPoint.h" |
| 38 #include "SkRasterClip.h" |
38 #include "SkRasterizer.h" | 39 #include "SkRasterizer.h" |
39 #include "SkSFNTHeader.h" | 40 #include "SkSFNTHeader.h" |
40 #include "SkShader.h" | 41 #include "SkShader.h" |
41 #include "SkSize.h" | 42 #include "SkSize.h" |
42 #include "SkStream.h" | 43 #include "SkStream.h" |
43 #include "SkTDArray.h" | 44 #include "SkTDArray.h" |
44 #include "SkTLazy.h" | 45 #include "SkTLazy.h" |
45 #include "SkTScopedComPtr.h" | 46 #include "SkTScopedComPtr.h" |
46 #include "SkTTCFHeader.h" | 47 #include "SkTTCFHeader.h" |
47 #include "SkTypefacePriv.h" | 48 #include "SkTypefacePriv.h" |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 SkPath path; | 1204 SkPath path; |
1204 path.addRRect(rr); | 1205 path.addRRect(rr); |
1205 this->drawPath(d, path, paint, nullptr, true); | 1206 this->drawPath(d, path, paint, nullptr, true); |
1206 } | 1207 } |
1207 | 1208 |
1208 void SkXPSDevice::internalDrawRect(const SkDraw& d, | 1209 void SkXPSDevice::internalDrawRect(const SkDraw& d, |
1209 const SkRect& r, | 1210 const SkRect& r, |
1210 bool transformRect, | 1211 bool transformRect, |
1211 const SkPaint& paint) { | 1212 const SkPaint& paint) { |
1212 //Exit early if there is nothing to draw. | 1213 //Exit early if there is nothing to draw. |
1213 if (d.fClip->isEmpty() || | 1214 if (d.fRC->isEmpty() || |
1214 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { | 1215 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { |
1215 return; | 1216 return; |
1216 } | 1217 } |
1217 | 1218 |
1218 //Path the rect if we can't optimize it. | 1219 //Path the rect if we can't optimize it. |
1219 if (rect_must_be_pathed(paint, *d.fMatrix)) { | 1220 if (rect_must_be_pathed(paint, *d.fMatrix)) { |
1220 SkPath tmp; | 1221 SkPath tmp; |
1221 tmp.addRect(r); | 1222 tmp.addRect(r); |
1222 tmp.setFillType(SkPath::kWinding_FillType); | 1223 tmp.setFillType(SkPath::kWinding_FillType); |
1223 this->drawPath(d, tmp, paint, nullptr, true); | 1224 this->drawPath(d, tmp, paint, nullptr, true); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 } | 1520 } |
1520 | 1521 |
1521 void SkXPSDevice::drawPath(const SkDraw& d, | 1522 void SkXPSDevice::drawPath(const SkDraw& d, |
1522 const SkPath& platonicPath, | 1523 const SkPath& platonicPath, |
1523 const SkPaint& origPaint, | 1524 const SkPaint& origPaint, |
1524 const SkMatrix* prePathMatrix, | 1525 const SkMatrix* prePathMatrix, |
1525 bool pathIsMutable) { | 1526 bool pathIsMutable) { |
1526 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); | 1527 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); |
1527 | 1528 |
1528 // nothing to draw | 1529 // nothing to draw |
1529 if (d.fClip->isEmpty() || | 1530 if (d.fRC->isEmpty() || |
1530 (paint->getAlpha() == 0 && paint->getXfermode() == nullptr)) { | 1531 (paint->getAlpha() == 0 && paint->getXfermode() == nullptr)) { |
1531 return; | 1532 return; |
1532 } | 1533 } |
1533 | 1534 |
1534 SkPath modifiedPath; | 1535 SkPath modifiedPath; |
1535 const bool paintHasPathEffect = paint->getPathEffect() | 1536 const bool paintHasPathEffect = paint->getPathEffect() |
1536 || paint->getStyle() != SkPaint::kFill_Style; | 1537 || paint->getStyle() != SkPaint::kFill_Style; |
1537 | 1538 |
1538 //Apply pre-path matrix [Platonic-path -> Skeletal-path]. | 1539 //Apply pre-path matrix [Platonic-path -> Skeletal-path]. |
1539 SkMatrix matrix = *d.fMatrix; | 1540 SkMatrix matrix = *d.fMatrix; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 &fill, | 1603 &fill, |
1603 &stroke)); | 1604 &stroke)); |
1604 | 1605 |
1605 //Rasterizer | 1606 //Rasterizer |
1606 if (rasterizer) { | 1607 if (rasterizer) { |
1607 SkIRect clipIRect; | 1608 SkIRect clipIRect; |
1608 SkVector ppuScale; | 1609 SkVector ppuScale; |
1609 this->convertToPpm(filter, | 1610 this->convertToPpm(filter, |
1610 &matrix, | 1611 &matrix, |
1611 &ppuScale, | 1612 &ppuScale, |
1612 d.fClip->getBounds(), | 1613 d.fRC->getBounds(), |
1613 &clipIRect); | 1614 &clipIRect); |
1614 | 1615 |
1615 SkMask* mask = nullptr; | 1616 SkMask* mask = nullptr; |
1616 | 1617 |
1617 //[Fillable-path -> Mask] | 1618 //[Fillable-path -> Mask] |
1618 SkMask rasteredMask; | 1619 SkMask rasteredMask; |
1619 if (rasterizer->rasterize( | 1620 if (rasterizer->rasterize( |
1620 *fillablePath, | 1621 *fillablePath, |
1621 matrix, | 1622 matrix, |
1622 &clipIRect, | 1623 &clipIRect, |
(...skipping 17 matching lines...) Expand all Loading... |
1640 return; | 1641 return; |
1641 } | 1642 } |
1642 | 1643 |
1643 //Mask filter | 1644 //Mask filter |
1644 if (filter) { | 1645 if (filter) { |
1645 SkIRect clipIRect; | 1646 SkIRect clipIRect; |
1646 SkVector ppuScale; | 1647 SkVector ppuScale; |
1647 this->convertToPpm(filter, | 1648 this->convertToPpm(filter, |
1648 &matrix, | 1649 &matrix, |
1649 &ppuScale, | 1650 &ppuScale, |
1650 d.fClip->getBounds(), | 1651 d.fRC->getBounds(), |
1651 &clipIRect); | 1652 &clipIRect); |
1652 | 1653 |
1653 //[Fillable-path -> Pixel-path] | 1654 //[Fillable-path -> Pixel-path] |
1654 SkPath* pixelPath = pathIsMutable ? fillablePath : &modifiedPath; | 1655 SkPath* pixelPath = pathIsMutable ? fillablePath : &modifiedPath; |
1655 fillablePath->transform(matrix, pixelPath); | 1656 fillablePath->transform(matrix, pixelPath); |
1656 | 1657 |
1657 SkMask* mask = nullptr; | 1658 SkMask* mask = nullptr; |
1658 | 1659 |
1659 //[Pixel-path -> Mask] | 1660 //[Pixel-path -> Mask] |
1660 SkMask rasteredMask; | 1661 SkMask rasteredMask; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 //Add the path to the active visual collection. | 1759 //Add the path to the active visual collection. |
1759 SkTScopedComPtr<IXpsOMVisualCollection> currentVisuals; | 1760 SkTScopedComPtr<IXpsOMVisualCollection> currentVisuals; |
1760 HRVM(this->fCurrentXpsCanvas->GetVisuals(¤tVisuals), | 1761 HRVM(this->fCurrentXpsCanvas->GetVisuals(¤tVisuals), |
1761 "Could not get current visuals for shaded path."); | 1762 "Could not get current visuals for shaded path."); |
1762 HRVM(currentVisuals->Append(shadedPath.get()), | 1763 HRVM(currentVisuals->Append(shadedPath.get()), |
1763 "Could not add shaded path to current visuals."); | 1764 "Could not add shaded path to current visuals."); |
1764 } | 1765 } |
1765 | 1766 |
1766 HRESULT SkXPSDevice::clip(IXpsOMVisual* xpsVisual, const SkDraw& d) { | 1767 HRESULT SkXPSDevice::clip(IXpsOMVisual* xpsVisual, const SkDraw& d) { |
1767 SkPath clipPath; | 1768 SkPath clipPath; |
1768 SkAssertResult(d.fClip->getBoundaryPath(&clipPath)); | 1769 if (d.fRC->isBW()) { |
| 1770 SkAssertResult(d.fRC->bwRgn().getBoundaryPath(&clipPath)); |
| 1771 } else { |
| 1772 // Don't have a way to turn a AAClip into a path, so we just use the bou
nds. |
| 1773 // TODO: consider using fClipStack instead? |
| 1774 clipPath.addRect(SkRect::Make(d.fRC->getBounds())); |
| 1775 } |
1769 | 1776 |
1770 return this->clipToPath(xpsVisual, clipPath, XPS_FILL_RULE_EVENODD); | 1777 return this->clipToPath(xpsVisual, clipPath, XPS_FILL_RULE_EVENODD); |
1771 } | 1778 } |
1772 HRESULT SkXPSDevice::clipToPath(IXpsOMVisual* xpsVisual, | 1779 HRESULT SkXPSDevice::clipToPath(IXpsOMVisual* xpsVisual, |
1773 const SkPath& clipPath, | 1780 const SkPath& clipPath, |
1774 XPS_FILL_RULE fillRule) { | 1781 XPS_FILL_RULE fillRule) { |
1775 //Create the geometry. | 1782 //Create the geometry. |
1776 SkTScopedComPtr<IXpsOMGeometry> clipGeometry; | 1783 SkTScopedComPtr<IXpsOMGeometry> clipGeometry; |
1777 HRM(this->fXpsFactory->CreateGeometry(&clipGeometry), | 1784 HRM(this->fXpsFactory->CreateGeometry(&clipGeometry), |
1778 "Could not create clip geometry."); | 1785 "Could not create clip geometry."); |
(...skipping 11 matching lines...) Expand all Loading... |
1790 HRM(clipGeometry->SetFillRule(fillRule), | 1797 HRM(clipGeometry->SetFillRule(fillRule), |
1791 "Could not set fill rule."); | 1798 "Could not set fill rule."); |
1792 HRM(xpsVisual->SetClipGeometryLocal(clipGeometry.get()), | 1799 HRM(xpsVisual->SetClipGeometryLocal(clipGeometry.get()), |
1793 "Could not set clip geometry."); | 1800 "Could not set clip geometry."); |
1794 | 1801 |
1795 return S_OK; | 1802 return S_OK; |
1796 } | 1803 } |
1797 | 1804 |
1798 void SkXPSDevice::drawBitmap(const SkDraw& d, const SkBitmap& bitmap, | 1805 void SkXPSDevice::drawBitmap(const SkDraw& d, const SkBitmap& bitmap, |
1799 const SkMatrix& matrix, const SkPaint& paint) { | 1806 const SkMatrix& matrix, const SkPaint& paint) { |
1800 if (d.fClip->isEmpty()) { | 1807 if (d.fRC->isEmpty()) { |
1801 return; | 1808 return; |
1802 } | 1809 } |
1803 | 1810 |
1804 SkIRect srcRect; | 1811 SkIRect srcRect; |
1805 srcRect.set(0, 0, bitmap.width(), bitmap.height()); | 1812 srcRect.set(0, 0, bitmap.width(), bitmap.height()); |
1806 | 1813 |
1807 //Create the new shaded path. | 1814 //Create the new shaded path. |
1808 SkTScopedComPtr<IXpsOMPath> shadedPath; | 1815 SkTScopedComPtr<IXpsOMPath> shadedPath; |
1809 HRVM(this->fXpsFactory->CreatePath(&shadedPath), | 1816 HRVM(this->fXpsFactory->CreatePath(&shadedPath), |
1810 "Could not create path for bitmap."); | 1817 "Could not create path for bitmap."); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 //SkXPSDevice* dev = new SkXPSDevice(this); | 2266 //SkXPSDevice* dev = new SkXPSDevice(this); |
2260 //SkSize s = SkSize::Make(width, height); | 2267 //SkSize s = SkSize::Make(width, height); |
2261 //dev->BeginCanvas(s, s, SkMatrix::I()); | 2268 //dev->BeginCanvas(s, s, SkMatrix::I()); |
2262 //return dev; | 2269 //return dev; |
2263 } | 2270 } |
2264 #endif | 2271 #endif |
2265 return new SkXPSDevice(this->fXpsFactory.get()); | 2272 return new SkXPSDevice(this->fXpsFactory.get()); |
2266 } | 2273 } |
2267 | 2274 |
2268 #endif//defined(SK_BUILD_FOR_WIN32) | 2275 #endif//defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |