|
|
Created:
6 years, 4 months ago by bungeman-skia Modified:
6 years, 4 months ago Reviewers:
caryclark CC:
reviews_skia.org Base URL:
https://skia.googlesource.com/skia.git@master Project:
skia Visibility:
Public. |
DescriptionXPS to use PathOps for inverse winding paths.
Committed: https://skia.googlesource.com/skia/+/76db31a2ca11da4dd45016e964b2e49f39f3dd49
Patch Set 1 #Patch Set 2 : Add a comment about fall-through. #Patch Set 3 : Rebase #Messages
Total messages: 9 (0 generated)
lgtm. Neat that you get to delete all of that code!
The CQ bit was checked by bungeman@google.com
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/bungeman@google.com/484343003/20001
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for src/device/xps/SkXPSDevice.cpp: While running git apply --index -p1; error: patch failed: src/device/xps/SkXPSDevice.cpp:30 error: src/device/xps/SkXPSDevice.cpp: patch does not apply Patch: src/device/xps/SkXPSDevice.cpp Index: src/device/xps/SkXPSDevice.cpp diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp index bdc612fae6d1608e0203d9134da7bef5934d20a0..0b87968acf4b104f541a572fadea9c8a851c5cd1 100644 --- a/src/device/xps/SkXPSDevice.cpp +++ b/src/device/xps/SkXPSDevice.cpp @@ -30,6 +30,7 @@ #include "SkIStream.h" #include "SkMaskFilter.h" #include "SkPaint.h" +#include "SkPathOps.h" #include "SkPoint.h" #include "SkRasterizer.h" #include "SkSFNTHeader.h" @@ -1387,162 +1388,6 @@ HRESULT SkXPSDevice::addXpsPathGeometry( return S_OK; } -HRESULT SkXPSDevice::drawInverseWindingPath(const SkDraw& d, - const SkPath& devicePath, - IXpsOMPath* shadedPath) { - const SkRect universeRect = SkRect::MakeLTRB(0, 0, - this->fCurrentCanvasSize.fWidth, this->fCurrentCanvasSize.fHeight); - - const XPS_RECT universeRectXps = { - 0.0f, 0.0f, - SkScalarToFLOAT(this->fCurrentCanvasSize.fWidth), - SkScalarToFLOAT(this->fCurrentCanvasSize.fHeight), - }; - - //Get the geometry. - SkTScopedComPtr<IXpsOMGeometry> shadedGeometry; - HRM(shadedPath->GetGeometry(&shadedGeometry), - "Could not get shaded geometry for inverse path."); - - //Get the figures from the geometry. - SkTScopedComPtr<IXpsOMGeometryFigureCollection> shadedFigures; - HRM(shadedGeometry->GetFigures(&shadedFigures), - "Could not get shaded figures for inverse path."); - - HRM(shadedGeometry->SetFillRule(XPS_FILL_RULE_NONZERO), - "Could not set shaded fill rule for inverse path."); - - //Take everything drawn so far, and make a shared resource out of it. - //Replace everything drawn so far with - //inverse canvas - // old canvas of everything so far - // world shaded figure, clipped to current clip - // top canvas of everything so far, clipped to path - //Note: this is not quite right when there is nothing solid in the - //canvas of everything so far, as the bit on top will allow - //the world paint to show through. - - //Create new canvas. - SkTScopedComPtr<IXpsOMCanvas> newCanvas; - HRM(this->fXpsFactory->CreateCanvas(&newCanvas), - "Could not create inverse canvas."); - - //Save the old canvas to a dictionary on the new canvas. - SkTScopedComPtr<IXpsOMDictionary> newDictionary; - HRM(this->fXpsFactory->CreateDictionary(&newDictionary), - "Could not create inverse dictionary."); - HRM(newCanvas->SetDictionaryLocal(newDictionary.get()), - "Could not set inverse dictionary."); - - const size_t size = SK_ARRAY_COUNT(L"ID" L_GUID_ID); - wchar_t buffer[size]; - wchar_t id[GUID_ID_LEN]; - HR(create_id(id, GUID_ID_LEN, '_')); - swprintf_s(buffer, size, L"ID%s", id); - HRM(newDictionary->Append(buffer, this->fCurrentXpsCanvas.get()), - "Could not add canvas to inverse dictionary."); - - //Start drawing - SkTScopedComPtr<IXpsOMVisualCollection> newVisuals; - HRM(newCanvas->GetVisuals(&newVisuals), - "Could not get inverse canvas visuals."); - - //Draw old canvas from dictionary onto new canvas. - SkTScopedComPtr<IXpsOMGeometry> oldGeometry; - HRM(this->fXpsFactory->CreateGeometry(&oldGeometry), - "Could not create old inverse geometry."); - - SkTScopedComPtr<IXpsOMGeometryFigureCollection> oldFigures; - HRM(oldGeometry->GetFigures(&oldFigures), - "Could not get old inverse figures."); - - SkTScopedComPtr<IXpsOMGeometryFigure> oldFigure; - HR(this->createXpsRect(universeRect, FALSE, TRUE, &oldFigure)); - HRM(oldFigures->Append(oldFigure.get()), - "Could not add old inverse figure."); - - SkTScopedComPtr<IXpsOMVisualBrush> oldBrush; - HRM(this->fXpsFactory->CreateVisualBrush(&universeRectXps, - &universeRectXps, - &oldBrush), - "Could not create old inverse brush."); - - SkTScopedComPtr<IXpsOMPath> oldPath; - HRM(this->fXpsFactory->CreatePath(&oldPath), - "Could not create old inverse path."); - HRM(oldPath->SetGeometryLocal(oldGeometry.get()), - "Could not set old inverse geometry."); - HRM(oldPath->SetFillBrushLocal(oldBrush.get()), - "Could not set old inverse fill brush."); - //the brush must be parented before setting the lookup. - HRM(newVisuals->Append(oldPath.get()), - "Could not add old inverse path to new canvas visuals."); - HRM(oldBrush->SetVisualLookup(buffer), - "Could not set old inverse brush visual lookup."); - - //Draw the clip filling shader. - SkTScopedComPtr<IXpsOMGeometryFigure> shadedFigure; - HR(this->createXpsRect(universeRect, FALSE, TRUE, &shadedFigure)); - HRM(shadedFigures->Append(shadedFigure.get()), - "Could not add inverse shaded figure."); - //the geometry is already set - HR(this->clip(shadedPath, d)); - HRM(newVisuals->Append(shadedPath), - "Could not add inverse shaded path to canvas visuals."); - - //Draw the old canvas on top, clipped to the original path. - SkTScopedComPtr<IXpsOMCanvas> topCanvas; - HRM(this->fXpsFactory->CreateCanvas(&topCanvas), - "Could not create top inverse canvas."); - //Clip the canvas to prevent alpha spill. - //This is the entire reason this canvas exists. - HR(this->clip(topCanvas.get(), d)); - - SkTScopedComPtr<IXpsOMGeometry> topGeometry; - HRM(this->fXpsFactory->CreateGeometry(&topGeometry), - "Could not create top inverse geometry."); - - SkTScopedComPtr<IXpsOMGeometryFigureCollection> topFigures; - HRM(topGeometry->GetFigures(&topFigures), - "Could not get top inverse figures."); - - SkTScopedComPtr<IXpsOMGeometryFigure> topFigure; - HR(this->createXpsRect(universeRect, FALSE, TRUE, &topFigure)); - HRM(topFigures->Append(topFigure.get()), - "Could not add old inverse figure."); - - SkTScopedComPtr<IXpsOMVisualBrush> topBrush; - HRM(this->fXpsFactory->CreateVisualBrush(&universeRectXps, - &universeRectXps, - &topBrush), - "Could not create top inverse brush."); - - SkTScopedComPtr<IXpsOMPath> topPath; - HRM(this->fXpsFactory->CreatePath(&topPath), - "Could not create top inverse path."); - HRM(topPath->SetGeometryLocal(topGeometry.get()), - "Could not set top inverse geometry."); - HRM(topPath->SetFillBrushLocal(topBrush.get()), - "Could not set top inverse fill brush."); - //the brush must be parented before setting the lookup. - HRM(newVisuals->Append(topCanvas.get()), - "Could not add top canvas to inverse canvas visuals."); - SkTScopedComPtr<IXpsOMVisualCollection> topVisuals; - HRM(topCanvas->GetVisuals(&topVisuals), - "Could not get top inverse canvas visuals."); - HRM(topVisuals->Append(topPath.get()), - "Could not add top inverse path to top canvas visuals."); - HRM(topBrush->SetVisualLookup(buffer), - "Could not set top inverse brush visual lookup."); - - HR(this->clipToPath(topPath.get(), devicePath, XPS_FILL_RULE_NONZERO)); - - //swap current canvas to new canvas - this->fCurrentXpsCanvas.swap(newCanvas); - - return S_OK; -} - void SkXPSDevice::convertToPpm(const SkMaskFilter* filter, SkMatrix* matrix, SkVector* ppuScale, @@ -1846,8 +1691,9 @@ void SkXPSDevice::drawPath(const SkDraw& d, bool xpsTransformsPath = true; //Set the fill rule. + SkPath* xpsCompatiblePath = fillablePath; XPS_FILL_RULE xpsFillRule; - switch (platonicPath.getFillType()) { + switch (fillablePath->getFillType()) { case SkPath::kWinding_FillType: xpsFillRule = XPS_FILL_RULE_NONZERO; break; @@ -1855,15 +1701,17 @@ void SkXPSDevice::drawPath(const SkDraw& d, xpsFillRule = XPS_FILL_RULE_EVENODD; break; case SkPath::kInverseWinding_FillType: { - //[Fillable-path -> Device-path] - SkPath* devicePath = pathIsMutable ? fillablePath : &modifiedPath; - fillablePath->transform(matrix, devicePath); - - HRV(this->drawInverseWindingPath(d, - *devicePath, - shadedPath.get())); - return; + //[Fillable-path (inverse winding) -> XPS-path (inverse even odd)] + if (!pathIsMutable) { + xpsCompatiblePath = &modifiedPath; + pathIsMutable = true; + } + if (!Simplify(*fillablePath, xpsCompatiblePath)) { + SkDEBUGF(("Could not simplify inverse winding path.")); + return; + } } + // The xpsCompatiblePath is noW inverse even odd, so fall through. case SkPath::kInverseEvenOdd_FillType: { const SkRect universe = SkRect::MakeLTRB( 0, 0, @@ -1896,11 +1744,11 @@ void SkXPSDevice::drawPath(const SkDraw& d, } } - SkPath* devicePath = fillablePath; + SkPath* devicePath = xpsCompatiblePath; if (!xpsTransformsPath) { //[Fillable-path -> Device-path] - devicePath = pathIsMutable ? fillablePath : &modifiedPath; - fillablePath->transform(matrix, devicePath); + devicePath = pathIsMutable ? xpsCompatiblePath : &modifiedPath; + xpsCompatiblePath->transform(matrix, devicePath); } HRV(this->addXpsPathGeometry(shadedFigures.get(), stroke, fill, *devicePath));
The CQ bit was checked by bungeman@google.com
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/bungeman@google.com/484343003/40001
Message was sent while issue was closed.
Committed patchset #3 (40001) as 76db31a2ca11da4dd45016e964b2e49f39f3dd49 |