move SkClipStack::asPath into PDFUtils
bug: skia:9734 Change-Id: I115c990c1532ab6852fe23956591878a04b3edc6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261282 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
2c316bdbfe
commit
c15afe488b
@ -40,6 +40,8 @@ skia_utils_sources = [
|
||||
"$_src/utils/SkCanvasStateUtils.cpp",
|
||||
"$_src/utils/SkCharToGlyphCache.cpp",
|
||||
"$_src/utils/SkCharToGlyphCache.h",
|
||||
"$_src/utils/SkClipStackUtils.cpp",
|
||||
"$_src/utils/SkClipStackUtils.h",
|
||||
"$_src/utils/SkDashPath.cpp",
|
||||
"$_src/utils/SkDashPathPriv.h",
|
||||
"$_src/utils/SkEventTracer.cpp",
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/pathops/SkPathOps.h"
|
||||
#include "src/core/SkClipOpPriv.h"
|
||||
#include "src/core/SkClipStack.h"
|
||||
#include <atomic>
|
||||
@ -748,35 +747,6 @@ bool SkClipStack::internalQuickContains(const SkRRect& rrect) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkClipStack::asPath(SkPath *path) const {
|
||||
bool isAA = false;
|
||||
|
||||
path->reset();
|
||||
path->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
|
||||
SkClipStack::Iter iter(*this, SkClipStack::Iter::kBottom_IterStart);
|
||||
while (const SkClipStack::Element* element = iter.next()) {
|
||||
SkPath operand;
|
||||
if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
|
||||
element->asDeviceSpacePath(&operand);
|
||||
}
|
||||
|
||||
SkClipOp elementOp = element->getOp();
|
||||
if (elementOp == kReplace_SkClipOp) {
|
||||
*path = operand;
|
||||
} else {
|
||||
Op(*path, operand, (SkPathOp)elementOp, path);
|
||||
}
|
||||
|
||||
// if the prev and curr clips disagree about aa -vs- not, favor the aa request.
|
||||
// perhaps we need an API change to avoid this sort of mixed-signals about
|
||||
// clipping.
|
||||
isAA = (isAA || element->isAA());
|
||||
}
|
||||
|
||||
return isAA;
|
||||
}
|
||||
|
||||
void SkClipStack::pushElement(const Element& element) {
|
||||
// Use reverse iterator instead of back because Rect path may need previous
|
||||
SkDeque::Iter iter(fDeque, SkDeque::Iter::kBack_IterStart);
|
||||
|
@ -337,12 +337,6 @@ public:
|
||||
return this->isWideOpen() || this->internalQuickContains(devRRect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens the clip stack into a single SkPath. Returns true if any of
|
||||
* the clip stack components requires anti-aliasing.
|
||||
*/
|
||||
bool asPath(SkPath* path) const;
|
||||
|
||||
void clipDevRect(const SkIRect& ir, SkClipOp op) {
|
||||
SkRect r;
|
||||
r.set(ir);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "src/pdf/SkPDFShader.h"
|
||||
#include "src/pdf/SkPDFTypes.h"
|
||||
#include "src/pdf/SkPDFUtils.h"
|
||||
#include "src/utils/SkClipStackUtils.h"
|
||||
#include "src/utils/SkUTF.h"
|
||||
|
||||
#include <vector>
|
||||
@ -323,7 +324,7 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v
|
||||
SkPath path = to_path(rect);
|
||||
path.transform(this->localToDevice(), &path);
|
||||
SkPath clip;
|
||||
(void)this->cs().asPath(&clip);
|
||||
SkClipStack_AsPath(this->cs(), &clip);
|
||||
Op(clip, path, kIntersect_SkPathOp, &path);
|
||||
// PDF wants a rectangle only.
|
||||
SkRect transformedRect =
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/pathops/SkPathOps.h"
|
||||
#include "src/pdf/SkPDFUtils.h"
|
||||
#include "src/utils/SkClipStackUtils.h"
|
||||
|
||||
static SkPath to_path(const SkRect& r) {
|
||||
SkPath p;
|
||||
@ -131,7 +132,7 @@ static void append_clip(const SkClipStack& clipStack,
|
||||
|
||||
if (is_complex_clip(clipStack)) {
|
||||
SkPath clipPath;
|
||||
(void)clipStack.asPath(&clipPath);
|
||||
SkClipStack_AsPath(clipStack, &clipPath);
|
||||
if (Op(clipPath, to_path(outsetBounds), kIntersect_SkPathOp, &clipPath)) {
|
||||
append_clip_path(clipPath, wStream);
|
||||
}
|
||||
|
29
src/utils/SkClipStackUtils.cpp
Normal file
29
src/utils/SkClipStackUtils.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/pathops/SkPathOps.h"
|
||||
#include "src/core/SkClipStack.h"
|
||||
|
||||
void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path) {
|
||||
path->reset();
|
||||
path->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
|
||||
SkClipStack::Iter iter(cs, SkClipStack::Iter::kBottom_IterStart);
|
||||
while (const SkClipStack::Element* element = iter.next()) {
|
||||
SkPath operand;
|
||||
if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
|
||||
element->asDeviceSpacePath(&operand);
|
||||
}
|
||||
|
||||
SkClipOp elementOp = element->getOp();
|
||||
if (elementOp == kReplace_SkClipOp) {
|
||||
*path = operand;
|
||||
} else {
|
||||
Op(*path, operand, (SkPathOp)elementOp, path);
|
||||
}
|
||||
}
|
||||
}
|
21
src/utils/SkClipStackUtils.h
Normal file
21
src/utils/SkClipStackUtils.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkClipStackUtils_DEFINED
|
||||
#define SkClipStackUtils_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkClipStack;
|
||||
class SkPath;
|
||||
|
||||
// Return the resolved clipstack as a single path.
|
||||
// Note: uses SkPathOps as part of its implementation.
|
||||
//
|
||||
void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path);
|
||||
|
||||
#endif
|
@ -49,6 +49,7 @@
|
||||
#include "src/sfnt/SkSFNTHeader.h"
|
||||
#include "src/sfnt/SkTTCFHeader.h"
|
||||
#include "src/shaders/SkShaderBase.h"
|
||||
#include "src/utils/SkClipStackUtils.h"
|
||||
#include "src/utils/win/SkHRESULT.h"
|
||||
#include "src/utils/win/SkIStream.h"
|
||||
#include "src/utils/win/SkTScopedComPtr.h"
|
||||
@ -1682,7 +1683,7 @@ HRESULT SkXPSDevice::clip(IXpsOMVisual* xpsVisual) {
|
||||
}
|
||||
SkPath clipPath;
|
||||
// clipPath.addRect(this->cs().bounds(size(*this)));
|
||||
(void)this->cs().asPath(&clipPath);
|
||||
SkClipStack_AsPath(this->cs(), &clipPath);
|
||||
// TODO: handle all the kinds of paths, like drawPath does
|
||||
return this->clipToPath(xpsVisual, clipPath, XPS_FILL_RULE_EVENODD);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user