107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com/* 207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Copyright 2012 Google Inc. 307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * 407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be 507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * found in the LICENSE file. 607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com */ 71049f1246e7be4ccb68001361efceb8933e6f81ccaryclark#include "SkPathOpsConic.h" 807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPathOpsCubic.h" 907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPathOpsLine.h" 1007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPathOpsQuad.h" 1107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPathOpsRect.h" 1207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 13aec251012542e971100e218bf463adbfb5d21d20caryclarkvoid SkDRect::setBounds(const SkDQuad& curve, const SkDQuad& sub, double startT, double endT) { 14aec251012542e971100e218bf463adbfb5d21d20caryclark set(sub[0]); 15aec251012542e971100e218bf463adbfb5d21d20caryclark add(sub[2]); 1607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com double tValues[2]; 1707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com int roots = 0; 18aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInX()) { 19aec251012542e971100e218bf463adbfb5d21d20caryclark roots = SkDQuad::FindExtrema(&sub[0].fX, tValues); 2007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 21aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInY()) { 22aec251012542e971100e218bf463adbfb5d21d20caryclark roots += SkDQuad::FindExtrema(&sub[0].fY, &tValues[roots]); 2307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 24aec251012542e971100e218bf463adbfb5d21d20caryclark for (int index = 0; index < roots; ++index) { 25aec251012542e971100e218bf463adbfb5d21d20caryclark double t = startT + (endT - startT) * tValues[index]; 26aec251012542e971100e218bf463adbfb5d21d20caryclark add(curve.ptAtT(t)); 2707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 2807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com} 2907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 30aec251012542e971100e218bf463adbfb5d21d20caryclarkvoid SkDRect::setBounds(const SkDConic& curve, const SkDConic& sub, double startT, double endT) { 31aec251012542e971100e218bf463adbfb5d21d20caryclark set(sub[0]); 32aec251012542e971100e218bf463adbfb5d21d20caryclark add(sub[2]); 331049f1246e7be4ccb68001361efceb8933e6f81ccaryclark double tValues[2]; 341049f1246e7be4ccb68001361efceb8933e6f81ccaryclark int roots = 0; 35aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInX()) { 36aec251012542e971100e218bf463adbfb5d21d20caryclark roots = SkDConic::FindExtrema(&sub[0].fX, sub.fWeight, tValues); 371049f1246e7be4ccb68001361efceb8933e6f81ccaryclark } 38aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInY()) { 39aec251012542e971100e218bf463adbfb5d21d20caryclark roots += SkDConic::FindExtrema(&sub[0].fY, sub.fWeight, &tValues[roots]); 401049f1246e7be4ccb68001361efceb8933e6f81ccaryclark } 41aec251012542e971100e218bf463adbfb5d21d20caryclark for (int index = 0; index < roots; ++index) { 42aec251012542e971100e218bf463adbfb5d21d20caryclark double t = startT + (endT - startT) * tValues[index]; 43aec251012542e971100e218bf463adbfb5d21d20caryclark add(curve.ptAtT(t)); 441049f1246e7be4ccb68001361efceb8933e6f81ccaryclark } 451049f1246e7be4ccb68001361efceb8933e6f81ccaryclark} 461049f1246e7be4ccb68001361efceb8933e6f81ccaryclark 47aec251012542e971100e218bf463adbfb5d21d20caryclarkvoid SkDRect::setBounds(const SkDCubic& curve, const SkDCubic& sub, double startT, double endT) { 48aec251012542e971100e218bf463adbfb5d21d20caryclark set(sub[0]); 49aec251012542e971100e218bf463adbfb5d21d20caryclark add(sub[3]); 5007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com double tValues[4]; 5107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com int roots = 0; 52aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInX()) { 53aec251012542e971100e218bf463adbfb5d21d20caryclark roots = SkDCubic::FindExtrema(&sub[0].fX, tValues); 5407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 55aec251012542e971100e218bf463adbfb5d21d20caryclark if (!sub.monotonicInY()) { 56aec251012542e971100e218bf463adbfb5d21d20caryclark roots += SkDCubic::FindExtrema(&sub[0].fY, &tValues[roots]); 5707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 58aec251012542e971100e218bf463adbfb5d21d20caryclark for (int index = 0; index < roots; ++index) { 59aec251012542e971100e218bf463adbfb5d21d20caryclark double t = startT + (endT - startT) * tValues[index]; 60aec251012542e971100e218bf463adbfb5d21d20caryclark add(curve.ptAtT(t)); 6107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 6207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com} 63