SkPathRef.cpp revision 2028d7ff744c36855ed36d602e3e050e9f18ec9f
1ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com/* 2ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com * Copyright 2013 Google Inc. 3ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com * 4ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com * Use of this source code is governed by a BSD-style license that can be 5ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com * found in the LICENSE file. 6ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com */ 7ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 8ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com#include "SkBuffer.h" 96c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein#include "SkOncePtr.h" 10ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com#include "SkPath.h" 11ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com#include "SkPathRef.h" 12ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 133e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com////////////////////////////////////////////////////////////////////////////// 143e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.comSkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, 153e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int incReserveVerbs, 163e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int incReservePoints) 173e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com{ 183e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if ((*pathRef)->unique()) { 193e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->incReserve(incReserveVerbs, incReservePoints); 203e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } else { 21385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary SkPathRef* copy = new SkPathRef; 223e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com copy->copy(**pathRef, incReserveVerbs, incReservePoints); 233e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pathRef->reset(copy); 243e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 253e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fPathRef = *pathRef; 2684cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco fPathRef->callGenIDChangeListeners(); 273e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fPathRef->fGenerationID = 0; 283e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);) 29ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com} 30ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 313e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com////////////////////////////////////////////////////////////////////////////// 32709ca75f032d7c60eb53c5840524a875a3a6cdb1commit-bot@chromium.org 3384cd621670a357484e1674e06d3d8d6f929a4ab2senorblancoSkPathRef::~SkPathRef() { 3484cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco this->callGenIDChangeListeners(); 3584cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(this->validate();) 3684cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco sk_free(fPoints); 3784cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco 3896fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkDEBUGCODE(fPoints = nullptr;) 3996fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkDEBUGCODE(fVerbs = nullptr;) 4084cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(fVerbCnt = 0x9999999;) 4184cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(fPointCnt = 0xAAAAAAA;) 4284cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(fPointCnt = 0xBBBBBBB;) 4384cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;) 4484cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco SkDEBUGCODE(fEditorsAttached = 0x7777777;) 4584cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco} 4684cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco 476c59d80858f453a426df9b07fdf3a8cc01e0b906mtkleinSK_DECLARE_STATIC_ONCE_PTR(SkPathRef, empty); 481f81fd6546c111e21bc665657e976b9d842192dfcommit-bot@chromium.orgSkPathRef* SkPathRef::CreateEmpty() { 496c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein return SkRef(empty.get([]{ 506c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein SkPathRef* pr = new SkPathRef; 516c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein pr->computeBounds(); // Avoids races later to be the first to do this. 526c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein return pr; 536c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein })); 541f81fd6546c111e21bc665657e976b9d842192dfcommit-bot@chromium.org} 551f81fd6546c111e21bc665657e976b9d842192dfcommit-bot@chromium.org 563e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.comvoid SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, 573e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com const SkPathRef& src, 583e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com const SkMatrix& matrix) { 5903087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(src.validate();) 603e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (matrix.isIdentity()) { 613e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (*dst != &src) { 623e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com src.ref(); 633e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com dst->reset(const_cast<SkPathRef*>(&src)); 6403087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE((*dst)->validate();) 653e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 663e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return; 67ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com } 683e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 69b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com if (!(*dst)->unique()) { 70385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary dst->reset(new SkPathRef); 71b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com } 72b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com 73b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com if (*dst != &src) { 743e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count()); 75cc881dafcbd00e8a811c47c14b472acdba5dd6c6mtklein sk_careful_memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), 76cc881dafcbd00e8a811c47c14b472acdba5dd6c6mtklein src.fVerbCnt * sizeof(uint8_t)); 773e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*dst)->fConicWeights = src.fConicWeights; 783e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 793e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 80b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com SkASSERT((*dst)->countPoints() == src.countPoints()); 81b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com SkASSERT((*dst)->countVerbs() == src.countVerbs()); 82b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); 83b06e88dc6505412cc2b1a5f0bfb0f669465e1f8erobertphillips@google.com 843e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com // Need to check this here in case (&src == dst) 853e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.countPoints() > 1; 863e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 873e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com matrix.mapPoints((*dst)->fPoints, src.points(), src.fPointCnt); 883e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 893e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com /* 903e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * Here we optimize the bounds computation, by noting if the bounds are 913e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * already known, and if so, we just transform those as well and mark 923e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * them as "known", rather than force the transformed path to have to 933e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * recompute them. 943e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * 953e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * Special gotchas if the path is effectively empty (<= 1 point) or 963e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * if it is non-finite. In those cases bounds need to stay empty, 973e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com * regardless of the matrix. 983e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com */ 993e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (canXformBounds) { 1003e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*dst)->fBoundsIsDirty = false; 1013e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (src.fIsFinite) { 1025c9c9be1f540e1895e65fbd244caae9135972143mtklein matrix.mapRect(&(*dst)->fBounds, src.fBounds); 1035c9c9be1f540e1895e65fbd244caae9135972143mtklein if (!((*dst)->fIsFinite = (*dst)->fBounds.isFinite())) { 1045c9c9be1f540e1895e65fbd244caae9135972143mtklein (*dst)->fBounds.setEmpty(); 1053e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 1063e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } else { 1073e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*dst)->fIsFinite = false; 1085c9c9be1f540e1895e65fbd244caae9135972143mtklein (*dst)->fBounds.setEmpty(); 1093e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 1103e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } else { 1113e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*dst)->fBoundsIsDirty = true; 1123e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 1133e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 1146b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com (*dst)->fSegmentMask = src.fSegmentMask; 1156b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 116466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com // It's an oval only if it stays a rect. 117da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark bool rectStaysRect = matrix.rectStaysRect(); 118da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark (*dst)->fIsOval = src.fIsOval && rectStaysRect; 119da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark (*dst)->fIsRRect = src.fIsRRect && rectStaysRect; 120466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com 12103087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE((*dst)->validate();) 122ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com} 123ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 124fed2ab648341ec153ad2af746a31d368963171e4commit-bot@chromium.orgSkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) { 125385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary SkPathRef* ref = new SkPathRef; 126466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com 127466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com int32_t packed; 128466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com if (!buffer->readS32(&packed)) { 129385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary delete ref; 13096fcdcc219d2a0d3579719b84b28bede76efba64halcanary return nullptr; 131466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com } 132466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com 133466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1; 134da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark uint8_t segmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF; 135da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark bool isOval = (packed >> kIsOval_SerializationShift) & 1; 136da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark bool isRRect = (packed >> kIsRRect_SerializationShift) & 1; 137ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 1388f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org int32_t verbCount, pointCount, conicCount; 1398f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org if (!buffer->readU32(&(ref->fGenerationID)) || 1408f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->readS32(&verbCount) || 1418f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->readS32(&pointCount) || 1428f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->readS32(&conicCount)) { 143385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary delete ref; 14496fcdcc219d2a0d3579719b84b28bede76efba64halcanary return nullptr; 1458f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org } 146ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 1478f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org ref->resetToSize(verbCount, pointCount, conicCount); 148ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com SkASSERT(verbCount == ref->countVerbs()); 149ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com SkASSERT(pointCount == ref->countPoints()); 150ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com SkASSERT(conicCount == ref->fConicWeights.count()); 1518f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org 1528f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) || 1538f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) || 1548f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) || 1558f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org !buffer->read(&ref->fBounds, sizeof(SkRect))) { 156385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary delete ref; 15796fcdcc219d2a0d3579719b84b28bede76efba64halcanary return nullptr; 1588f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org } 159ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com ref->fBoundsIsDirty = false; 1606b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 1616b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // resetToSize clears fSegmentMask and fIsOval 1626b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com ref->fSegmentMask = segmentMask; 163466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com ref->fIsOval = isOval; 164da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark ref->fIsRRect = isRRect; 165ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com return ref; 166ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com} 167ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 1683e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.comvoid SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { 1693e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if ((*pathRef)->unique()) { 17003087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE((*pathRef)->validate();) 17184cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco (*pathRef)->callGenIDChangeListeners(); 1723e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite 1733e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fVerbCnt = 0; 1743e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fPointCnt = 0; 1753e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fFreeSpace = (*pathRef)->currSize(); 1763e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fGenerationID = 0; 1773e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->fConicWeights.rewind(); 1786b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com (*pathRef)->fSegmentMask = 0; 179466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com (*pathRef)->fIsOval = false; 180da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark (*pathRef)->fIsRRect = false; 18103087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE((*pathRef)->validate();) 1823e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } else { 1833e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int oldVCnt = (*pathRef)->countVerbs(); 1843e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int oldPCnt = (*pathRef)->countPoints(); 185385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary pathRef->reset(new SkPathRef); 1863e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com (*pathRef)->resetToSize(0, 0, 0, oldVCnt, oldPCnt); 1873e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 1883e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 1893e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 1903e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.combool SkPathRef::operator== (const SkPathRef& ref) const { 19103087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 19203087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(ref.validate();) 1936b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 1946b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // We explicitly check fSegmentMask as a quick-reject. We could skip it, 1956b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // since it is only a cache of info in the fVerbs, but its a fast way to 1966b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // notice a difference 1976b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com if (fSegmentMask != ref.fSegmentMask) { 1986b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com return false; 1996b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 2006b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 2013e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com bool genIDMatch = fGenerationID && fGenerationID == ref.fGenerationID; 2023e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com#ifdef SK_RELEASE 2033e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (genIDMatch) { 2043e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return true; 2053e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 2063e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com#endif 2073e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (fPointCnt != ref.fPointCnt || 2083e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fVerbCnt != ref.fVerbCnt) { 2093e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(!genIDMatch); 2103e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return false; 2113e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 212d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein if (0 == ref.fVerbCnt) { 213d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein SkASSERT(0 == ref.fPointCnt); 214d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein return true; 215d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein } 216d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein SkASSERT(this->verbsMemBegin() && ref.verbsMemBegin()); 2173e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (0 != memcmp(this->verbsMemBegin(), 2183e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com ref.verbsMemBegin(), 2193e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com ref.fVerbCnt * sizeof(uint8_t))) { 2203e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(!genIDMatch); 2213e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return false; 2223e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 223d4897591fddf8f2a4860066449fb7dd8b0cc7b77mtklein SkASSERT(this->points() && ref.points()); 2243e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (0 != memcmp(this->points(), 2253e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com ref.points(), 2263e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com ref.fPointCnt * sizeof(SkPoint))) { 2273e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(!genIDMatch); 2283e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return false; 2293e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 2303e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (fConicWeights != ref.fConicWeights) { 2313e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(!genIDMatch); 2323e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return false; 2333e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 2343e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return true; 2353e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 2363e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 2376b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.comvoid SkPathRef::writeToBuffer(SkWBuffer* buffer) const { 23803087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 239ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com SkDEBUGCODE(size_t beforePos = buffer->pos();) 240ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 241ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com // Call getBounds() to ensure (as a side-effect) that fBounds 242ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com // and fIsFinite are computed. 243ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com const SkRect& bounds = this->getBounds(); 244ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 245466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com int32_t packed = ((fIsFinite & 1) << kIsFinite_SerializationShift) | 2466b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com ((fIsOval & 1) << kIsOval_SerializationShift) | 247da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark ((fIsRRect & 1) << kIsRRect_SerializationShift) | 2486b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com (fSegmentMask << kSegmentMask_SerializationShift); 249ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write32(packed); 250ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 251ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com // TODO: write gen ID here. Problem: We don't know if we're cross process or not from 252ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com // SkWBuffer. Until this is fixed we write 0. 253ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write32(0); 254ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write32(fVerbCnt); 255ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write32(fPointCnt); 256ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write32(fConicWeights.count()); 257ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write(verbsMemBegin(), fVerbCnt * sizeof(uint8_t)); 258ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write(fPoints, fPointCnt * sizeof(SkPoint)); 259ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write(fConicWeights.begin(), fConicWeights.bytes()); 260ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com buffer->write(&bounds, sizeof(bounds)); 261ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com 262ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com SkASSERT(buffer->pos() - beforePos == (size_t) this->writeSize()); 263ca0c8389e2fd1c7f528869beb77a6c8587d59f29robertphillips@google.com} 2643e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 2656b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.comuint32_t SkPathRef::writeSize() const { 2663e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return uint32_t(5 * sizeof(uint32_t) + 2673e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fVerbCnt * sizeof(uint8_t) + 2683e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fPointCnt * sizeof(SkPoint) + 2693e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fConicWeights.bytes() + 2703e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com sizeof(SkRect)); 2713e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 2723e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 27350df4d013f840749f70d1759c23c4217e727fd54skia.committer@gmail.comvoid SkPathRef::copy(const SkPathRef& ref, 27450df4d013f840749f70d1759c23c4217e727fd54skia.committer@gmail.com int additionalReserveVerbs, 2753e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int additionalReservePoints) { 27603087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 2773e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), 2783e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com additionalReserveVerbs, additionalReservePoints); 279cc881dafcbd00e8a811c47c14b472acdba5dd6c6mtklein sk_careful_memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt*sizeof(uint8_t)); 280cc881dafcbd00e8a811c47c14b472acdba5dd6c6mtklein sk_careful_memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint)); 2813e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fConicWeights = ref.fConicWeights; 2823e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fBoundsIsDirty = ref.fBoundsIsDirty; 2833e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (!fBoundsIsDirty) { 2843e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fBounds = ref.fBounds; 2853e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fIsFinite = ref.fIsFinite; 2863e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 2876b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask = ref.fSegmentMask; 288466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com fIsOval = ref.fIsOval; 289da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fIsRRect = ref.fIsRRect; 29003087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 2913e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 2923e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 29396f5fa02e996e39179f2eb88d57e8ed6114b06c5skia.committer@gmail.comSkPoint* SkPathRef::growForRepeatedVerb(int /*SkPath::Verb*/ verb, 29496f5fa02e996e39179f2eb88d57e8ed6114b06c5skia.committer@gmail.com int numVbs, 2956b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkScalar** weights) { 2966b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // This value is just made-up for now. When count is 4, calling memset was much 2976b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // slower than just writing the loop. This seems odd, and hopefully in the 2986b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // future this will appear to have been a fluke... 2996b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com static const unsigned int kMIN_COUNT_FOR_MEMSET_TO_BE_FAST = 16; 3006b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3016b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGCODE(this->validate();) 3026b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com int pCnt; 3036b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com bool dirtyAfterEdit = true; 3046b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com switch (verb) { 3056b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kMove_Verb: 3066b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = numVbs; 3076b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com dirtyAfterEdit = false; 3086b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3096b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kLine_Verb: 3106b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kLine_SegmentMask; 3116b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = numVbs; 3126b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3136b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kQuad_Verb: 3146b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kQuad_SegmentMask; 3156b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 2 * numVbs; 3166b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3176b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kConic_Verb: 3186b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kConic_SegmentMask; 3196b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 2 * numVbs; 3206b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3216b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kCubic_Verb: 3226b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kCubic_SegmentMask; 3236b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 3 * numVbs; 3246b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3256b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kClose_Verb: 3266b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGFAIL("growForRepeatedVerb called for kClose_Verb"); 3276b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 0; 3286b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com dirtyAfterEdit = false; 3296b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3306b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kDone_Verb: 3316b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGFAIL("growForRepeatedVerb called for kDone"); 3326b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // fall through 3336b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com default: 3346b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGFAIL("default should not be reached"); 3356b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 0; 3366b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com dirtyAfterEdit = false; 3376b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 3386b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3396b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com size_t space = numVbs * sizeof(uint8_t) + pCnt * sizeof (SkPoint); 3406b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com this->makeSpace(space); 3416b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3426b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkPoint* ret = fPoints + fPointCnt; 3436b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com uint8_t* vb = fVerbs - fVerbCnt; 3446b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3456b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // cast to unsigned, so if kMIN_COUNT_FOR_MEMSET_TO_BE_FAST is defined to 3466b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com // be 0, the compiler will remove the test/branch entirely. 3476b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com if ((unsigned)numVbs >= kMIN_COUNT_FOR_MEMSET_TO_BE_FAST) { 3486b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com memset(vb - numVbs, verb, numVbs); 3496b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } else { 3506b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com for (int i = 0; i < numVbs; ++i) { 3516b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com vb[~i] = verb; 3526b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 3536b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 3546b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3556b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fVerbCnt += numVbs; 3566b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fPointCnt += pCnt; 3576b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fFreeSpace -= space; 3586b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fBoundsIsDirty = true; // this also invalidates fIsFinite 3596b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com if (dirtyAfterEdit) { 3606b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fIsOval = false; 361da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fIsRRect = false; 3626b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 3636b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3646b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com if (SkPath::kConic_Verb == verb) { 36549f085dddff10473b6ebf832a974288300224e60bsalomon SkASSERT(weights); 3666b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com *weights = fConicWeights.append(numVbs); 3676b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 3686b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3696b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGCODE(this->validate();) 3706b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com return ret; 3716b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com} 3726b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 3736b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.comSkPoint* SkPathRef::growForVerb(int /* SkPath::Verb*/ verb, SkScalar weight) { 37403087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 3753e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com int pCnt; 376466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com bool dirtyAfterEdit = true; 3773e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com switch (verb) { 3783e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kMove_Verb: 3793e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 1; 380466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com dirtyAfterEdit = false; 3813e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com break; 3823e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kLine_Verb: 3836b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kLine_SegmentMask; 3843e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 1; 3853e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com break; 3863e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kQuad_Verb: 3876b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kQuad_SegmentMask; 3886b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com pCnt = 2; 3896b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 3903e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kConic_Verb: 3916b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kConic_SegmentMask; 3923e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 2; 3933e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com break; 3943e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kCubic_Verb: 3956b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com fSegmentMask |= SkPath::kCubic_SegmentMask; 3963e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 3; 3973e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com break; 3983e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kClose_Verb: 3993e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 0; 400466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com dirtyAfterEdit = false; 4013e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com break; 4023e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com case SkPath::kDone_Verb: 4033e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkDEBUGFAIL("growForVerb called for kDone"); 4043e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com // fall through 4053e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com default: 4063e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkDEBUGFAIL("default is not reached"); 407466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com dirtyAfterEdit = false; 4083e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com pCnt = 0; 4093e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 4103e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com size_t space = sizeof(uint8_t) + pCnt * sizeof (SkPoint); 4113e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com this->makeSpace(space); 4123e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com this->fVerbs[~fVerbCnt] = verb; 4133e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkPoint* ret = fPoints + fPointCnt; 4143e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fVerbCnt += 1; 4153e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fPointCnt += pCnt; 4163e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fFreeSpace -= space; 4173e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fBoundsIsDirty = true; // this also invalidates fIsFinite 418466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com if (dirtyAfterEdit) { 419466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com fIsOval = false; 420da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fIsRRect = false; 421466310dbd3073add2ec934e336c30deaaf702eaerobertphillips@google.com } 4226b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 4236b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com if (SkPath::kConic_Verb == verb) { 4246b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com *fConicWeights.append() = weight; 4256b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 4266b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 42703087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com SkDEBUGCODE(this->validate();) 4283e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return ret; 4293e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 4303e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 4311ab9f737f000e530f0c7713c8fad282f39e26efecommit-bot@chromium.orguint32_t SkPathRef::genID() const { 4323e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(!fEditorsAttached); 4331ab9f737f000e530f0c7713c8fad282f39e26efecommit-bot@chromium.org static const uint32_t kMask = (static_cast<int64_t>(1) << SkPath::kPathRefGenIDBitCnt) - 1; 4343e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (!fGenerationID) { 4353e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (0 == fPointCnt && 0 == fVerbCnt) { 4363e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fGenerationID = kEmptyGenID; 4373e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } else { 4383e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com static int32_t gPathRefGenerationID; 4393e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com // do a loop in case our global wraps around, as we never want to return a 0 or the 4403e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com // empty ID 4413e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com do { 4421ab9f737f000e530f0c7713c8fad282f39e26efecommit-bot@chromium.org fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMask; 4433e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } while (fGenerationID <= kEmptyGenID); 4443e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 4453e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 4463e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com return fGenerationID; 4473e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 4483e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 44984cd621670a357484e1674e06d3d8d6f929a4ab2senorblancovoid SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) { 4506c59d80858f453a426df9b07fdf3a8cc01e0b906mtklein if (nullptr == listener || this == (SkPathRef*)empty) { 451385fe4d4b62d7d1dd76116dd570df3290a2f487bhalcanary delete listener; 45284cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco return; 45384cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco } 45484cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco *fGenIDChangeListeners.append() = listener; 45584cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco} 45684cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco 45784cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco// we need to be called *before* the genID gets changed or zerod 45884cd621670a357484e1674e06d3d8d6f929a4ab2senorblancovoid SkPathRef::callGenIDChangeListeners() { 45984cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco for (int i = 0; i < fGenIDChangeListeners.count(); i++) { 46084cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco fGenIDChangeListeners[i]->onChange(); 46184cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco } 46284cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco 46384cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco // Listeners get at most one shot, so whether these triggered or not, blow them away. 46484cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco fGenIDChangeListeners.deleteAll(); 46584cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco} 46684cd621670a357484e1674e06d3d8d6f929a4ab2senorblanco 467da707bf5635c70d4c3c284a0b05d92489b76788ecaryclarkSkRRect SkPathRef::getRRect() const { 468da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark const SkRect& bounds = this->getBounds(); 469da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkVector radii[4] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; 470da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark Iter iter(*this); 471da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkPoint pts[4]; 472da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark uint8_t verb = iter.next(pts); 473da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(SkPath::kMove_Verb == verb); 474da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { 475da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark if (SkPath::kConic_Verb == verb) { 476da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkVector v1_0 = pts[1] - pts[0]; 477da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkVector v2_1 = pts[2] - pts[1]; 478da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkVector dxdy; 479da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark if (v1_0.fX) { 480da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(!v2_1.fX && !v1_0.fY); 481da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark dxdy.set(SkScalarAbs(v1_0.fX), SkScalarAbs(v2_1.fY)); 482da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } else if (!v1_0.fY) { 483da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(!v2_1.fX || !v2_1.fY); 484da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark dxdy.set(SkScalarAbs(v2_1.fX), SkScalarAbs(v2_1.fY)); 485da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } else { 486da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(!v2_1.fY); 487da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark dxdy.set(SkScalarAbs(v2_1.fX), SkScalarAbs(v1_0.fY)); 488da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } 489da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkRRect::Corner corner = 490da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1].fX == bounds.fLeft ? 491da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1].fY == bounds.fTop ? 492da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkRRect::kUpperLeft_Corner : SkRRect::kLowerLeft_Corner : 493da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1].fY == bounds.fTop ? 494da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkRRect::kUpperRight_Corner : SkRRect::kLowerRight_Corner; 495da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(!radii[corner].fX && !radii[corner].fY); 496da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark radii[corner] = dxdy; 497da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } else { 498da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT((verb == SkPath::kLine_Verb 499da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark && (!(pts[1].fX - pts[0].fX) || !(pts[1].fY - pts[0].fY))) 500da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark || verb == SkPath::kClose_Verb); 501da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } 502da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } 503da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkRRect rrect; 504da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark rrect.setRectRadii(bounds, radii); 505da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark return rrect; 506da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark} 507da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 508da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark/////////////////////////////////////////////////////////////////////////////// 509da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 510da707bf5635c70d4c3c284a0b05d92489b76788ecaryclarkSkPathRef::Iter::Iter() { 511da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark#ifdef SK_DEBUG 512da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fPts = nullptr; 513da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fConicWeights = nullptr; 514da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark#endif 515da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark // need to init enough to make next() harmlessly return kDone_Verb 516da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fVerbs = nullptr; 517da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fVerbStop = nullptr; 518da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark} 519da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 520da707bf5635c70d4c3c284a0b05d92489b76788ecaryclarkSkPathRef::Iter::Iter(const SkPathRef& path) { 521da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark this->setPathRef(path); 522da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark} 523da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 524da707bf5635c70d4c3c284a0b05d92489b76788ecaryclarkvoid SkPathRef::Iter::setPathRef(const SkPathRef& path) { 525da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fPts = path.points(); 526da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fVerbs = path.verbs(); 527da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fVerbStop = path.verbsMemBegin(); 528da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fConicWeights = path.conicWeights() - 1; // begin one behind 529da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark} 530da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 531da707bf5635c70d4c3c284a0b05d92489b76788ecaryclarkuint8_t SkPathRef::Iter::next(SkPoint pts[4]) { 532da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(pts); 533da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark if (fVerbs == fVerbStop) { 534da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark return (uint8_t) SkPath::kDone_Verb; 535da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } 536da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 537da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark // fVerbs points one beyond next verb so decrement first. 538da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark unsigned verb = *(--fVerbs); 539da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark const SkPoint* srcPts = fPts; 540da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 541da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark switch (verb) { 542da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kMove_Verb: 543da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[0] = srcPts[0]; 544da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark srcPts += 1; 545da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 546da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kLine_Verb: 547da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[0] = srcPts[-1]; 548da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1] = srcPts[0]; 549da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark srcPts += 1; 550da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 551da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kConic_Verb: 552da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fConicWeights += 1; 553da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark // fall-through 554da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kQuad_Verb: 555da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[0] = srcPts[-1]; 556da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1] = srcPts[0]; 557da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[2] = srcPts[1]; 558da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark srcPts += 2; 559da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 560da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kCubic_Verb: 561da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[0] = srcPts[-1]; 562da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[1] = srcPts[0]; 563da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[2] = srcPts[1]; 564da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark pts[3] = srcPts[2]; 565da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark srcPts += 3; 566da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 567da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kClose_Verb: 568da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 569da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark case SkPath::kDone_Verb: 570da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark SkASSERT(fVerbs == fVerbStop); 571da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark break; 572da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark } 573da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark fPts = srcPts; 574da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark return (uint8_t) verb; 575da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark} 576da707bf5635c70d4c3c284a0b05d92489b76788ecaryclark 5772028d7ff744c36855ed36d602e3e050e9f18ec9fcaryclarkuint8_t SkPathRef::Iter::peek() const { 5782028d7ff744c36855ed36d602e3e050e9f18ec9fcaryclark const uint8_t* next = fVerbs - 1; 5792028d7ff744c36855ed36d602e3e050e9f18ec9fcaryclark return next <= fVerbStop ? (uint8_t) SkPath::kDone_Verb : *next; 5802028d7ff744c36855ed36d602e3e050e9f18ec9fcaryclark} 5812028d7ff744c36855ed36d602e3e050e9f18ec9fcaryclark 58203087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com#ifdef SK_DEBUG 5833e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.comvoid SkPathRef::validate() const { 58403087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com this->INHERITED::validate(); 5853e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); 5863e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints) >= 0); 58796fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkASSERT((nullptr == fPoints) == (nullptr == fVerbs)); 58896fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); 58996fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); 59096fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkASSERT(!(nullptr == fPoints && fPointCnt)); 59196fcdcc219d2a0d3579719b84b28bede76efba64halcanary SkASSERT(!(nullptr == fVerbs && fVerbCnt)); 5923e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(this->currSize() == 5933e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVerbCnt); 5943e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com 5955c9c9be1f540e1895e65fbd244caae9135972143mtklein if (!fBoundsIsDirty && !fBounds.isEmpty()) { 5963e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com bool isFinite = true; 5973e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com for (int i = 0; i < fPointCnt; ++i) { 598f1cdead599715dbae30278bffa4528bd1664f61frobertphillips#ifdef SK_DEBUG 599f1cdead599715dbae30278bffa4528bd1664f61frobertphillips if (fPoints[i].isFinite() && 600f1cdead599715dbae30278bffa4528bd1664f61frobertphillips (fPoints[i].fX < fBounds.fLeft || fPoints[i].fX > fBounds.fRight || 601f1cdead599715dbae30278bffa4528bd1664f61frobertphillips fPoints[i].fY < fBounds.fTop || fPoints[i].fY > fBounds.fBottom)) { 602f1cdead599715dbae30278bffa4528bd1664f61frobertphillips SkDebugf("bounds: %f %f %f %f\n", 603f1cdead599715dbae30278bffa4528bd1664f61frobertphillips fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom); 604f1cdead599715dbae30278bffa4528bd1664f61frobertphillips for (int j = 0; j < fPointCnt; ++j) { 605f1cdead599715dbae30278bffa4528bd1664f61frobertphillips if (i == j) { 606f1cdead599715dbae30278bffa4528bd1664f61frobertphillips SkDebugf("*"); 607f1cdead599715dbae30278bffa4528bd1664f61frobertphillips } 608f1cdead599715dbae30278bffa4528bd1664f61frobertphillips SkDebugf("%f %f\n", fPoints[j].fX, fPoints[j].fY); 609f1cdead599715dbae30278bffa4528bd1664f61frobertphillips } 610f1cdead599715dbae30278bffa4528bd1664f61frobertphillips } 611f1cdead599715dbae30278bffa4528bd1664f61frobertphillips#endif 612f1cdead599715dbae30278bffa4528bd1664f61frobertphillips 6130e912464cecf50cc152c3fb93c2aac31c8a99cacrobertphillips SkASSERT(!fPoints[i].isFinite() || 6140e912464cecf50cc152c3fb93c2aac31c8a99cacrobertphillips (fPoints[i].fX >= fBounds.fLeft && fPoints[i].fX <= fBounds.fRight && 6150e912464cecf50cc152c3fb93c2aac31c8a99cacrobertphillips fPoints[i].fY >= fBounds.fTop && fPoints[i].fY <= fBounds.fBottom)); 6163e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com if (!fPoints[i].isFinite()) { 6173e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com isFinite = false; 6183e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 6193e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 6203e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com SkASSERT(SkToBool(fIsFinite) == isFinite); 6213e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com } 6226b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com 6236b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com#ifdef SK_DEBUG_PATH 6246b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com uint32_t mask = 0; 6256b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com for (int i = 0; i < fVerbCnt; ++i) { 6266b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com switch (fVerbs[~i]) { 6276b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kMove_Verb: 6286b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6296b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kLine_Verb: 6306b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com mask |= SkPath::kLine_SegmentMask; 6316b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6326b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kQuad_Verb: 6336b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com mask |= SkPath::kQuad_SegmentMask; 6346b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6356b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kConic_Verb: 6366b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com mask |= SkPath::kConic_SegmentMask; 6376b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6386b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kCubic_Verb: 6396b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com mask |= SkPath::kCubic_SegmentMask; 6406b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6416b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kClose_Verb: 6426b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6436b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com case SkPath::kDone_Verb: 6446b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGFAIL("Done verb shouldn't be recorded."); 6456b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6466b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com default: 6476b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkDEBUGFAIL("Unknown Verb"); 6486b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com break; 6496b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 6506b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com } 6516b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com SkASSERT(mask == fSegmentMask); 6526b8dbb668f1f069270d35a47cfe98decd059c625robertphillips@google.com#endif // SK_DEBUG_PATH 6533e292aa398dc40f5188bc4f0b36c8916ac552308robertphillips@google.com} 65403087072483378a43f7b3f7a47944614187275ebrobertphillips@google.com#endif 655