Bug 1498701 - Backport some upstream Skia patches. r=lsalzman

Backport of:
https://skia.googlesource.com/skia/+/c3d8a48f1b27370049aa512019cd726c59354743
https://skia.googlesource.com/skia/+/8051d38358293df1e5b8a1a513f8114147ec9fa3

--HG--
extra : rebase_source : 60c6d31c9971de5bbedcf45dbee326f9a90dc26c
extra : source : 767d62fe72c8ecc86aa75e0b25ca1af15466bd29
This commit is contained in:
Ryan VanderMeulen 2018-10-15 14:01:24 -04:00
parent 3e8c7866a9
commit a7be122853

View File

@ -17,6 +17,7 @@
#include "SkPointPriv.h"
#include "SkRRect.h"
#include "SkSafeMath.h"
#include "SkTLazy.h"
static float poly_eval(float A, float B, float C, float t) {
return (A * t + B) * t + C;
@ -1555,10 +1556,17 @@ void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy, AddPathMode m
this->addPath(path, matrix, mode);
}
void SkPath::addPath(const SkPath& path, const SkMatrix& matrix, AddPathMode mode) {
SkPathRef::Editor(&fPathRef, path.countVerbs(), path.countPoints());
void SkPath::addPath(const SkPath& srcPath, const SkMatrix& matrix, AddPathMode mode) {
// Detect if we're trying to add ourself
const SkPath* src = &srcPath;
SkTLazy<SkPath> tmp;
if (this == src) {
src = tmp.set(srcPath);
}
RawIter iter(path);
SkPathRef::Editor(&fPathRef, src->countVerbs(), src->countPoints());
RawIter iter(*src);
SkPoint pts[4];
Verb verb;
@ -1658,14 +1666,21 @@ void SkPath::reversePathTo(const SkPath& path) {
}
}
void SkPath::reverseAddPath(const SkPath& src) {
SkPathRef::Editor ed(&fPathRef, src.fPathRef->countPoints(), src.fPathRef->countVerbs());
void SkPath::reverseAddPath(const SkPath& srcPath) {
// Detect if we're trying to add ourself
const SkPath* src = &srcPath;
SkTLazy<SkPath> tmp;
if (this == src) {
src = tmp.set(srcPath);
}
const SkPoint* pts = src.fPathRef->pointsEnd();
SkPathRef::Editor ed(&fPathRef, src->fPathRef->countPoints(), src->fPathRef->countVerbs());
const SkPoint* pts = src->fPathRef->pointsEnd();
// we will iterator through src's verbs backwards
const uint8_t* verbs = src.fPathRef->verbsMemBegin(); // points at the last verb
const uint8_t* verbsEnd = src.fPathRef->verbs(); // points just past the first verb
const SkScalar* conicWeights = src.fPathRef->conicWeightsEnd();
const uint8_t* verbs = src->fPathRef->verbsMemBegin(); // points at the last verb
const uint8_t* verbsEnd = src->fPathRef->verbs(); // points just past the first verb
const SkScalar* conicWeights = src->fPathRef->conicWeightsEnd();
bool needMove = true;
bool needClose = false;