/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "src/core/SkEdge.h" #include "include/private/base/SkDebug.h" #include "include/private/base/SkTo.h" #include "src/base/SkMathPriv.h" #include "src/core/SkFDot6.h" #include <algorithm> #include <utility> /* In setLine, setQuadratic, setCubic, the first thing we do is to convert the points into FDot6. This is modulated by the shift parameter, which will either be 0, or something like 2 for antialiasing. In the float case, we want to turn the float into .6 by saying pt * 64, or pt * 256 for antialiasing. This is implemented as 1 << (shift + 6). In the fixed case, we want to turn the fixed into .6 by saying pt >> 10, or pt >> 8 for antialiasing. This is implemented as pt >> (10 - shift). */ static inline SkFixed SkFDot6ToFixedDiv2(SkFDot6 value) { … } ///////////////////////////////////////////////////////////////////////// #ifdef SK_DEBUG void SkEdge::dump() const { … } #endif int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip, int shift) { … } // called from a curve subclass int SkEdge::updateLine(SkFixed x0, SkFixed y0, SkFixed x1, SkFixed y1) { … } void SkEdge::chopLineWithClip(const SkIRect& clip) { … } /////////////////////////////////////////////////////////////////////////////// /* We store 1<<shift in a (signed) byte, so its maximum value is 1<<6 == 64. Note that this limits the number of lines we use to approximate a curve. If we need to increase this, we need to store fCurveCount in something larger than int8_t. */ #define MAX_COEFF_SHIFT … static inline SkFDot6 cheap_distance(SkFDot6 dx, SkFDot6 dy) { … } static inline int diff_to_shift(SkFDot6 dx, SkFDot6 dy, int shiftAA = 2) { … } bool SkQuadraticEdge::setQuadraticWithoutUpdate(const SkPoint pts[3], int shift) { … } int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift) { … } int SkQuadraticEdge::updateQuadratic() { … } ///////////////////////////////////////////////////////////////////////// static inline int SkFDot6UpShift(SkFDot6 x, int upShift) { … } /* f(1/3) = (8a + 12b + 6c + d) / 27 f(2/3) = (a + 6b + 12c + 8d) / 27 f(1/3)-b = (8a - 15b + 6c + d) / 27 f(2/3)-c = (a + 6b - 15c + 8d) / 27 use 16/512 to approximate 1/27 */ static SkFDot6 cubic_delta_from_line(SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d) { … } bool SkCubicEdge::setCubicWithoutUpdate(const SkPoint pts[4], int shift, bool sortY) { … } int SkCubicEdge::setCubic(const SkPoint pts[4], int shift) { … } int SkCubicEdge::updateCubic() { … }