/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Rect PathSkia::GetBounds(const Matrix& aTransform) const { if (!mPath.isFinite()) { return Rect();
}
Rect bounds = SkRectToRect(mPath.computeTightBounds()); return aTransform.TransformBounds(bounds);
}
Rect PathSkia::GetStrokedBounds(const StrokeOptions& aStrokeOptions, const Matrix& aTransform) const { if (!mPath.isFinite()) { return Rect();
}
SkPath fillPath; if (!GetFillPath(aStrokeOptions, aTransform, fillPath)) { return Rect();
}
Rect bounds = SkRectToRect(fillPath.computeTightBounds()); return aTransform.TransformBounds(bounds);
}
Rect PathSkia::GetFastBounds(const Matrix& aTransform, const StrokeOptions* aStrokeOptions) const { if (!mPath.isFinite()) { return Rect();
}
SkRect bounds = mPath.getBounds(); if (aStrokeOptions) { // If the path is stroked, ensure that the bounds are inflated by any // relevant options such as line width. Avoid using dash path effects // for performance and to ensure computeFastStrokeBounds succeeds.
SkPaint paint; if (!StrokeOptionsToPaint(paint, *aStrokeOptions, false)) { return Rect();
}
SkRect outBounds = SkRect::MakeEmpty();
bounds = paint.computeFastStrokeBounds(bounds, &outBounds);
} return aTransform.TransformBounds(SkRectToRect(bounds));
}
SkPoint points[4];
SkPath::Verb currentVerb; while ((currentVerb = iter.next(points)) != SkPath::kDone_Verb) { switch (currentVerb) { case SkPath::kMove_Verb:
aSink->MoveTo(SkPointToPoint(points[0])); break; case SkPath::kLine_Verb:
aSink->LineTo(SkPointToPoint(points[1])); break; case SkPath::kCubic_Verb:
aSink->BezierTo(SkPointToPoint(points[1]), SkPointToPoint(points[2]),
SkPointToPoint(points[3])); break; case SkPath::kQuad_Verb:
aSink->QuadraticBezierTo(SkPointToPoint(points[1]),
SkPointToPoint(points[2])); break; case SkPath::kConic_Verb: {
std::vector<Point> quads; int numQuads = ConvertConicToQuads(
SkPointToPoint(points[0]), SkPointToPoint(points[1]),
SkPointToPoint(points[2]), iter.conicWeight(), quads); for (int i = 0; i < numQuads; i++) {
aSink->QuadraticBezierTo(quads[2 * i + 1], quads[2 * i + 2]);
} break;
} case SkPath::kClose_Verb:
aSink->Close(); break; default:
MOZ_ASSERT(false); // Unexpected verb found in path!
}
}
}
Maybe<Rect> PathSkia::AsRect() const {
SkRect skiaRect; if (mPath.isRect(&skiaRect)) {
Rect rect = SkRectToRect(skiaRect); // Ensure that the conversion between Skia rect and Moz2D rect is not lossy // due to floating-point precision errors. if (RectToSkRect(rect) == skiaRect) { return Some(rect);
}
} return Nothing();
}
bool PathSkia::IsEmpty() const { // Move/Close/Done segments are not included in the mask so as long as any // flag is set, we know that the path is non-empty. return mPath.getSegmentMasks() == 0;
}
} // namespace mozilla::gfx
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.