michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #include "SkPathOpsBounds.h" michael@0: #include "SkPathOpsCubic.h" michael@0: #include "SkPathOpsLine.h" michael@0: #include "SkPathOpsQuad.h" michael@0: michael@0: void SkPathOpsBounds::setCubicBounds(const SkPoint a[4]) { michael@0: SkDCubic cubic; michael@0: cubic.set(a); michael@0: SkDRect dRect; michael@0: dRect.setBounds(cubic); michael@0: set(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop), michael@0: SkDoubleToScalar(dRect.fRight), SkDoubleToScalar(dRect.fBottom)); michael@0: } michael@0: michael@0: void SkPathOpsBounds::setLineBounds(const SkPoint a[2]) { michael@0: setPointBounds(a[0]); michael@0: add(a[1]); michael@0: } michael@0: michael@0: void SkPathOpsBounds::setQuadBounds(const SkPoint a[3]) { michael@0: SkDQuad quad; michael@0: quad.set(a); michael@0: SkDRect dRect; michael@0: dRect.setBounds(quad); michael@0: set(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop), michael@0: SkDoubleToScalar(dRect.fRight), SkDoubleToScalar(dRect.fBottom)); michael@0: } michael@0: michael@0: void (SkPathOpsBounds::*SetCurveBounds[])(const SkPoint[]) = { michael@0: NULL, michael@0: &SkPathOpsBounds::setLineBounds, michael@0: &SkPathOpsBounds::setQuadBounds, michael@0: &SkPathOpsBounds::setCubicBounds michael@0: };