refresh public includes

Update includes to fix minor edits
and bookmaker bugs.

Also update SkPoint.h for the first
time to see if that sticks.

TBR=reed@google.com
Bug: skia:6898
Change-Id: I7d11dea45482602248e2d15b05699bb4c86ea4c6
Reviewed-on: https://skia-review.googlesource.com/90541
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2018-01-03 10:00:34 -05:00 committed by Skia Commit-Bot
parent 61dfc3a53d
commit 2823f9f06c
7 changed files with 688 additions and 420 deletions

View File

@ -99,14 +99,14 @@ public:
*/
void swap(SkBitmap& other);
/** Returns SkPixmap with SkBitmap pixel address, row bytes, and SkImageInfo, if address
is available. If pixel address is not available, returns default constructed
SkPixmap: nullptr pixels, kUnknown_SkColorType, kUnknown_SkAlphaType, width and
height of zero.
/** Returns a SkPixmap with the SkBitmap pixel address, row bytes, and
SkImageInfo to pixmap, if address is available. If pixel address
is not available, return an empty SkPixmap.
Returned SkPixmap becomes invalid on any future change to SkBitmap
The SkPixmap contents become invalid on any future change to SkBitmap.
@return new SkPixmap describing this SkBitmap.
@return SkPixmap describing SkBitmap, if pixels are readable; otherwise containing zeroes
*/
SkPixmap pixmap() const { return fPixels ? SkPixmap(fInfo, fPixels, fRowBytes) : SkPixmap(); }
@ -116,7 +116,7 @@ public:
*/
const SkImageInfo& info() const { return fInfo; }
/** Returns pixel count in each pixel row. Should be equal or less than:
/** Returns pixel count in each row. Should be equal or less than:
rowBytes() / info().bytesPerPixel().
Maybe be less than pixelRef().width(). Will not exceed pixelRef().width() less
@ -154,7 +154,7 @@ public:
reference count of SkColorSpace is unchanged. The returned SkColorSpace is
immutable.
@return SkColorSpace in SkImageInfo
@return SkColorSpace in SkImageInfo, or nullptr
*/
SkColorSpace* colorSpace() const { return fInfo.colorSpace(); }
@ -404,7 +404,6 @@ public:
Calls reset() and returns false if:
- rowBytes exceeds 31 bits
- imageInfo.width() times imageInfo.bytesPerPixel() exceeds 31 bits
- imageInfo.width() is negative
- imageInfo.height() is negative
- rowBytes is positive and less than imageInfo.width() times imageInfo.bytesPerPixel()
@ -427,8 +426,7 @@ public:
memory. If flags is kZeroPixels_AllocFlag, memory is zeroed.
Returns false and calls reset() if SkImageInfo could not be set, or memory could
not be allocated, or memory size exceeds 31 bits, or memory could not optionally
be zeroed.
not be allocated, or memory could not optionally be zeroed.
On most platforms, allocating pixel memory may succeed even though there is
not sufficient memory to hold pixels; allocation does not take place
@ -449,7 +447,7 @@ public:
memory. If flags is kZeroPixels_AllocFlag, memory is zeroed.
Aborts execution if SkImageInfo could not be set, or memory could
not be allocated, or memory size exceeds 31 bits, or memory could not optionally
not be allocated, or memory could not optionally
be zeroed. Abort steps may be provided by the user at compile time by defining
SK_ABORT.
@ -492,7 +490,7 @@ public:
or equal zero. Pass in zero for rowBytes to compute the minimum valid value.
Aborts execution if SkImageInfo could not be set, or memory could
not be allocated, or memory size exceeds 31 bits. Abort steps may be provided by
not be allocated. Abort steps may be provided by
the user at compile time by defining SK_ABORT.
On most platforms, allocating pixel memory may succeed even though there is
@ -529,7 +527,7 @@ public:
memory.
Aborts execution if SkImageInfo could not be set, or memory could
not be allocated, or memory size exceeds 31 bits. Abort steps may be provided by
not be allocated. Abort steps may be provided by
the user at compile time by defining SK_ABORT.
On most platforms, allocating pixel memory may succeed even though there is
@ -543,7 +541,7 @@ public:
this->allocPixels(info, info.minRowBytes());
}
/** Sets SkImageInfo to width, height, and the native SkColorType; and allocates
/** Sets SkImageInfo to width, height, and native SkColorType; and allocates
pixel memory. If isOpaque is true, sets SkImageInfo to kOpaque_SkAlphaType;
otherwise, sets to kPremul_SkAlphaType.
@ -552,8 +550,8 @@ public:
Returns false if allocation fails.
Use to create SkBitmap that matches native pixel arrangement on the platform,
to draw without converting its pixel format.
Use to create SkBitmap that matches SkPMColor, the native pixel arrangement on
the platform. SkBitmap drawn to output device skips converting its pixel format.
@param width pixel column count; must be zero or greater
@param height pixel row count; must be zero or greater
@ -574,8 +572,8 @@ public:
allocation fails. Abort steps may be provided by the user at compile time by
defining SK_ABORT.
Use to create SkBitmap that matches native pixel arrangement on the platform,
to draw without converting its pixel format.
Use to create SkBitmap that matches SkPMColor, the native pixel arrangement on
the platform. SkBitmap drawn to output device skips converting its pixel format.
@param width pixel column count; must be zero or greater
@param height pixel row count; must be zero or greater
@ -676,8 +674,7 @@ public:
/** Allocates pixel memory with HeapAllocator, and replaces existing SkPixelRef.
The allocation size is determined by SkImageInfo width, height, and SkColorType.
Returns false if info().colorType is kUnknown_SkColorType, or allocation exceeds
31 bits, or allocation fails.
Returns false if info().colorType is kUnknown_SkColorType, or allocation fails.
@return true if the allocation succeeds
*/
@ -688,8 +685,8 @@ public:
/** Allocates pixel memory with HeapAllocator, and replaces existing SkPixelRef.
The allocation size is determined by SkImageInfo width, height, and SkColorType.
Aborts if info().colorType is kUnknown_SkColorType, or allocation exceeds
31 bits, or allocation fails. Abort steps may be provided by the user at compile
Aborts if info().colorType is kUnknown_SkColorType, or allocation fails.
Abort steps may be provided by the user at compile
time by defining SK_ABORT.
*/
void allocPixels() {

View File

@ -71,7 +71,6 @@ class SK_API SkCanvas : SkNoncopyable {
public:
/** Allocates raster SkCanvas that will draw directly into pixels.
To access pixels after drawing, call flush() or peekPixels().
SkCanvas is returned if all parameters are valid.
Valid parameters include:
@ -85,12 +84,15 @@ public:
info width times bytes required for SkColorType.
Pixel buffer size should be info height times computed rowBytes.
Pixels are not initialized.
To access pixels after drawing, call flush() or peekPixels().
@param info width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface;
width, or height, or both, may be zero
@param pixels pointer to destination pixels buffer
@param rowBytes interval from one SkSurface row to the next, or zero
@param props optional surfaceprops
@param props LCD striping orientation and setting for device independent fonts;
may be nullptr
@return SkCanvas if all parameters are valid; otherwise, nullptr
*/
static std::unique_ptr<SkCanvas> MakeRasterDirect(const SkImageInfo& info, void* pixels,
@ -201,7 +203,7 @@ public:
*/
SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
/** Draw saved layer, if any.
/** Draw saved layers, if any.
Free up resources used by SkCanvas.
*/
virtual ~SkCanvas();
@ -231,6 +233,8 @@ public:
/** Triggers the immediate execution of all pending draw operations.
If SkCanvas is associated with GPU surface, resolves all pending GPU operations.
If SkCanvas is associated with raster surface, has no effect; raster draw
operations are never deferred.
*/
void flush();
@ -302,10 +306,10 @@ public:
bool peekPixels(SkPixmap* pixmap);
/** Copies SkRect of pixels from SkCanvas into dstPixels. SkMatrix and clip are
ignored. Source SkRect corners are (srcX, srcY) and
(imageInfo().width(), imageInfo().height()).
ignored.
Destination SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination SkRect corners are (0, 0) and (dstInfo.width(), dstInfo.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to dstInfo.colorType() and dstInfo.alphaType() if required.
@ -339,10 +343,10 @@ public:
int srcX, int srcY);
/** Copies SkRect of pixels from SkCanvas into pixmap. SkMatrix and clip are
ignored. Source SkRect corners are (srcX, srcY) and
(imageInfo().width(), imageInfo().height()).
ignored.
Destination SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination SkRect corners are (0, 0) and (pixmap.width(), pixmap.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to pixmap.colorType() and pixmap.alphaType() if required.
@ -354,7 +358,7 @@ public:
Caller must allocate pixel storage in pixmap if needed.
Pixel values are converted only if SkColorType and SkAlphaType
do not match. Only pixels within both source and destination SkRect
do not match. Only pixels within both source and destination rects
are copied. pixmap pixels contents outside SkRect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down pixmap.
@ -374,9 +378,9 @@ public:
bool readPixels(const SkPixmap& pixmap, int srcX, int srcY);
/** Copies SkRect of pixels from SkCanvas into bitmap. SkMatrix and clip are
ignored. Source SkRect corners are (srcX, srcY) and
(imageInfo().width(), imageInfo().height()).
ignored.
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to bitmap.colorType() and bitmap.alphaType() if required.
@ -668,7 +672,7 @@ public:
clipMatrix uses color alpha channel of image, transformed by clipMatrix, to clip
layer when drawn to SkCanvas.
Implementation is incomplete; has no effect if SkBaseDevice is GPU-backed.
Implementation is not complete; has no effect if SkBaseDevice is GPU-backed.
@param bounds layer dimensions; may be nullptr
@param paint graphics state applied to layer when overlaying prior
@ -1624,7 +1628,7 @@ public:
/** Draw SkBitmap bitmap, with its top-left corner at (left, top),
using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, color alpha, SkImageFilter,
If SkPaint paint is not nullptr, apply SkColorFilter, color alpha, SkImageFilter,
SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
If paint contains SkMaskFilter, generate mask from bitmap bounds.
@ -1761,18 +1765,13 @@ public:
struct Lattice {
/** \enum SkCanvas::Lattice::RectType
Optional setting per rectangular grid entry.
Optional setting per rectangular grid entry to make it transparent,
or to fill the grid entry with a color.
*/
enum RectType : uint8_t {
kDefault = 0,
/** Set to skip lattice rectangle by making it transparent. */
kTransparent,
/** The lattice rectangle is a fixed color. The color value is stored
in fColors.
*/
kFixedColor,
kDefault = 0, //!< Draws SkBitmap into lattice rectangle.
kTransparent, //!< Skips lattice rectangle by making it transparent.
kFixedColor, //!< Draws one of fColors into lattice rectangle.
};
/** Array of x-coordinates that divide the bitmap vertically.
@ -1781,7 +1780,7 @@ public:
Set the first element to fBounds left to collapse the left column of
fixed grid entries.
*/
const int* fXDivs;
const int* fXDivs;
/** Array of y-coordinates that divide the bitmap horizontally.
Array entries must be unique, increasing, greater than or equal to
@ -1789,11 +1788,13 @@ public:
Set the first element to fBounds top to collapse the top row of fixed
grid entries.
*/
const int* fYDivs;
const int* fYDivs;
/** Optional array of rectangle types, one per rectangular grid entry:
/** Optional array of fill types, one per rectangular grid entry:
array length must be (fXCount + 1) * (fYCount + 1).
Each RectType is one of: kDefault, kTransparent, kFixedColor.
Array entries correspond to the rectangular grid entries, ascending
left to right and then top to bottom.
*/
@ -1802,26 +1803,25 @@ public:
/** Number of entries in fXDivs array; one less than the number of
horizontal divisions.
*/
int fXCount;
int fXCount;
/** Number of entries in fYDivs array; one less than the number of vertical
divisions.
*/
int fYCount;
int fYCount;
/** Optional subset SkIRect source to draw from.
If nullptr, source bounds is dimensions of SkBitmap or SkImage.
*/
const SkIRect* fBounds;
const SkIRect* fBounds;
/** Optional array of colors, one per rectangular grid entry:
array length must be (fXCount + 1) * (fYCount + 1).
/** Optional array of colors, one per rectangular grid entry.
Array length must be (fXCount + 1) * (fYCount + 1).
Array entries correspond to the rectangular grid entries, ascending
left to right and then top to bottom.
left to right, then top to bottom.
*/
const SkColor* fColors;
const SkColor* fColors;
};
@ -2090,6 +2090,8 @@ public:
font embedded bitmaps, full hinting spacing, lcd text, linear text,
subpixel text, and SkPaint vertical text.
SkPaint::TextEncoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader, SkColorFilter,
SkImageFilter, and SkDrawLooper; apply to blob.
@ -2108,6 +2110,8 @@ public:
font embedded bitmaps, full hinting spacing, lcd text, linear text,
subpixel text, and SkPaint vertical text.
SkPaint::TextEncoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader, SkColorFilter,
SkImageFilter, and SkDrawLooper; apply to blob.
@ -2120,11 +2124,11 @@ public:
this->drawTextBlob(blob.get(), x, y, paint);
}
/** Draw picture picture, using clip and SkMatrix.
/** Draw SkPicture picture, using clip and SkMatrix.
Clip and SkMatrix are unchanged by picture contents, as if
save() was called before and restore() was called after drawPicture().
Picture records a series of draw commands for later playback.
SkPicture records a series of draw commands for later playback.
@param picture recorded drawing commands to play
*/
@ -2132,11 +2136,11 @@ public:
this->drawPicture(picture, nullptr, nullptr);
}
/** Draw picture picture, using clip and SkMatrix.
/** Draw SkPicture picture, using clip and SkMatrix.
Clip and SkMatrix are unchanged by picture contents, as if
save() was called before and restore() was called after drawPicture().
Picture records a series of draw commands for later playback.
SkPicture records a series of draw commands for later playback.
@param picture recorded drawing commands to play
*/
@ -2144,7 +2148,7 @@ public:
this->drawPicture(picture.get());
}
/** Draw picture picture, using clip and SkMatrix; transforming picture with
/** Draw SkPicture picture, using clip and SkMatrix; transforming picture with
SkMatrix matrix, if provided; and use SkPaint paint color alpha, SkColorFilter,
SkImageFilter, and SkBlendMode, if provided.
@ -2157,7 +2161,7 @@ public:
*/
void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
/** Draw picture picture, using clip and SkMatrix; transforming picture with
/** Draw SkPicture picture, using clip and SkMatrix; transforming picture with
SkMatrix matrix, if provided; and use SkPaint paint color alpha, SkColorFilter,
SkImageFilter, and SkBlendMode, if provided.
@ -2192,12 +2196,12 @@ public:
*/
void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint);
/** Draws a Coons patch: the interpolation of four cubics with shared corners,
/** Draws a Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
The Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
Coons_Patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
color alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
as the Coons patch texture; SkBlendMode mode combines color colors and SkShader if
as Coons_Patch texture; SkBlendMode mode combines color colors and SkShader if
both are provided.
SkPoint array cubics specifies four cubics starting at the top-left corner,
@ -2220,12 +2224,12 @@ public:
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
/** Draws cubic Coons patch: the interpolation of four cubics with shared corners,
/** Draws cubic Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
The Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
Coons_Patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
color alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
as the Coons patch texture; SkBlendMode mode combines color colors and SkShader if
as Coons_Patch texture; SkBlendMode mode combines color colors and SkShader if
both are provided.
SkPoint array cubics specifies four cubics starting at the top-left corner,
@ -2344,7 +2348,7 @@ public:
optional matrix.
If SkCanvas has an asynchronous implementation, as is the case
when it is recording into picture, then drawable will be referenced,
when it is recording into SkPicture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
@ -2356,7 +2360,7 @@ public:
/** Draw SkDrawable drawable using clip and SkMatrix, offset by (x, y).
If SkCanvas has an asynchronous implementation, as is the case
when it is recording into picture, then drawable will be referenced,
when it is recording into SkPicture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
@ -2367,9 +2371,9 @@ public:
void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y);
/** Associate SkRect on SkCanvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as data.
a null-terminated utf8 string, and optional value is stored as SkData.
Only some canvas implementations, such as recording to picture, or drawing to
Only some canvas implementations, such as recording to SkPicture, or drawing to
document pdf, use annotations.
@param rect SkRect extent of canvas to annotate
@ -2379,9 +2383,9 @@ public:
void drawAnnotation(const SkRect& rect, const char key[], SkData* value);
/** Associate SkRect on SkCanvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as data.
a null-terminated utf8 string, and optional value is stored as SkData.
Only some canvas implementations, such as recording to picture, or drawing to
Only some canvas implementations, such as recording to SkPicture, or drawing to
document pdf, use annotations.
@param rect SkRect extent of canvas to annotate
@ -2790,7 +2794,8 @@ public:
}
}
/** Restores SkCanvas to saved state.
/** Restores SkCanvas to saved state. Destructor is called when container goes out of
scope.
*/
~SkAutoCanvasRestore() {
if (fCanvas) {

View File

@ -17,7 +17,7 @@ class SkString;
/** \class SkMatrix
SkMatrix holds a 3x3 matrix for transforming coordinates. This allows mapping
SkPoint and SkVector with translation, scaling, skewing, rotation, and
points and vectors with translation, scaling, skewing, rotation, and
perspective.
SkMatrix elements are in row major order. SkMatrix does not have a constructor,
@ -79,21 +79,22 @@ public:
return m;
}
/** Sets matrix to be:
/** Sets SkMatrix to:
| scaleX skewX transX |
| skewY scaleY transY |
| pers0 pers1 pers2 |
| pers0 pers1 pers2 |
@param scaleX horizontal scale factor to store
@param skewX horizontal skew factor to store
@param transX horizontal translation to store
@param skewY vertical skew factor to store
@param scaleY vertical scale factor to store
@param transY vertical translation to store
@param pers0 input x perspective factor to store
@param pers1 input y perspective factor to store
@param pers2 perspective scale factor to store
@param scaleX horizontal scale factor
@param skewX horizontal skew factor
@param transX horizontal translation
@param skewY vertical skew factor
@param scaleY vertical scale factor
@param transY vertical translation
@param pers0 input x perspective factor
@param pers1 input y perspective factor
@param pers2 perspective scale factor
@return SkMatrix constructed from parameters
*/
static SkMatrix SK_WARN_UNUSED_RESULT MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX,
SkScalar skewY, SkScalar scaleY, SkScalar transY,
@ -240,7 +241,7 @@ public:
Describes that the SkMatrix makes rendering with and without the matrix are
visually alike; a transformed circle remains a circle. Mathematically, this is
referred to as similarity of a Euclidean space, or a similarity transformation.
referred to as similarity of a Euclidean_Space, or a similarity transformation.
Preserves right angles, keeping the arms of the angle equal lengths.
@ -291,6 +292,13 @@ public:
kATransY, //!< vertical translation
};
/** Returns one matrix value. Asserts if index is out of range and SK_DEBUG is
defined.
@param index one of: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY,
kMPersp0, kMPersp1, kMPersp2
@return value corresponding to index
*/
SkScalar operator[](int index) const {
SkASSERT((unsigned)index < 9);
return fMat[index];
@ -309,44 +317,44 @@ public:
}
/** Returns scale factor multiplied by x input, contributing to x output.
With mapPoints(), scales SkPoint along the x-axis.
With mapPoints(), scales points along the x-axis.
@return horizontal scale factor
*/
SkScalar getScaleX() const { return fMat[kMScaleX]; }
/** Returns scale factor multiplied by y input, contributing to y output.
With mapPoints(), scales SkPoint along the y-axis.
With mapPoints(), scales points along the y-axis.
@return vertical scale factor
*/
SkScalar getScaleY() const { return fMat[kMScaleY]; }
/** Returns scale factor multiplied by x input, contributing to y output.
With mapPoints(), skews SkPoint along the y-axis.
Skew x and y together can rotate SkPoint.
With mapPoints(), skews points along the y-axis.
Skew x and y together can rotate points.
@return vertical skew factor
*/
SkScalar getSkewY() const { return fMat[kMSkewY]; }
/** Returns scale factor multiplied by y input, contributing to x output.
With mapPoints(), skews SkPoint along the x-axis.
Skew x and y together can rotate SkPoint.
With mapPoints(), skews points along the x-axis.
Skew x and y together can rotate points.
@return horizontal scale factor
*/
SkScalar getSkewX() const { return fMat[kMSkewX]; }
/** Returns translation contributing to x output.
With mapPoints(), moves SkPoint along the x-axis.
With mapPoints(), moves points along the x-axis.
@return horizontal translation factor
*/
SkScalar getTranslateX() const { return fMat[kMTransX]; }
/** Returns translation contributing to y output.
With mapPoints(), moves SkPoint along the y-axis.
With mapPoints(), moves points along the y-axis.
@return vertical translation factor
*/
@ -502,7 +510,7 @@ public:
*/
void set9(const SkScalar buffer[9]);
/** Sets SkMatrix to identity; which has no effect on mapped SkPoint. Sets SkMatrix to:
/** Sets SkMatrix to identity; which has no effect on mapped points. Sets SkMatrix to:
| 1 0 0 |
| 0 1 0 |
@ -513,7 +521,7 @@ public:
*/
void reset();
/** Sets SkMatrix to identity; which has no effect on mapped SkPoint. Sets SkMatrix to:
/** Sets SkMatrix to identity; which has no effect on mapped points. Sets SkMatrix to:
| 1 0 0 |
| 0 1 0 |
@ -533,7 +541,7 @@ public:
/** Sets SkMatrix to translate by (v.fX, v.fY).
@param v SkVector containing horizontal and vertical translation
@param v vector containing horizontal and vertical translation
*/
void setTranslate(const SkVector& v) { this->setTranslate(v.fX, v.fY); }
@ -575,8 +583,8 @@ public:
/** Sets SkMatrix to rotate by sinValue and cosValue, about a pivot point at (px, py).
The pivot point is unchanged when mapped with SkMatrix.
SkVector (sinValue, cosValue) describes the angle of rotation relative to (0, 1).
SkVector length specifies scale.
Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1).
Vector length specifies scale.
@param sinValue rotation vector x component
@param cosValue rotation vector y component
@ -588,8 +596,8 @@ public:
/** Sets SkMatrix to rotate by sinValue and cosValue, about a pivot point at (0, 0).
SkVector (sinValue, cosValue) describes the angle of rotation relative to (0, 1).
SkVector length specifies scale.
Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1).
Vector length specifies scale.
@param sinValue rotation vector x component
@param cosValue rotation vector y component
@ -598,9 +606,9 @@ public:
/** Sets SkMatrix to rotate, scale, and translate using a compressed matrix form.
SkVector (rsxForm.fSSin, rsxForm.fSCos) describes the angle of rotation relative
to (0, 1). SkVector length specifies scale. Mapped point is rotated and scaled
by SkVector, then translated by (rsxForm.fTx, rsxForm.fTy).
Vector (rsxForm.fSSin, rsxForm.fSCos) describes the angle of rotation relative
to (0, 1). Vector length specifies scale. Mapped point is rotated and scaled
by vector, then translated by (rsxForm.fTx, rsxForm.fTy).
@param rsxForm compressed SkRSXform matrix
@return reference to SkMatrix
@ -1134,13 +1142,13 @@ public:
If count is zero, sets SkMatrix to identity and returns true.
If count is one, sets SkMatrix to translate and returns true.
If count is two or more, sets SkMatrix to map SkPoint if possible; returns false
If count is two or more, sets SkMatrix to map points if possible; returns false
if SkMatrix cannot be constructed. If count is four, SkMatrix may include
perspective.
@param src SkPoint to map from
@param dst SkPoint to map to
@param count number of SkPoint in src and dst
@param src points to map from
@param dst points to map to
@param count number of points in src and dst
@return true if SkMatrix was constructed successfully
*/
bool setPolyToPoly(const SkPoint src[], const SkPoint dst[], int count);
@ -1205,7 +1213,7 @@ public:
void setAffine(const SkScalar affine[6]);
/** Maps src SkPoint array of length count to dst SkPoint array of equal or greater
length. SkPoint are mapped by multiplying each SkPoint by SkMatrix. Given:
length. Points are mapped by multiplying each SkPoint by SkMatrix. Given:
| A B C | | x |
Matrix = | D E F |, pt = | y |
@ -1226,9 +1234,9 @@ public:
src and dst may point to the same storage.
@param dst storage for mapped SkPoint
@param src SkPoint to transform
@param count number of SkPoint to transform
@param dst storage for mapped points
@param src points to transform
@param count number of points to transform
*/
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
SkASSERT((dst && src && count > 0) || 0 == count);
@ -1237,7 +1245,7 @@ public:
this->getMapPtsProc()(*this, dst, src, count);
}
/** Maps pts SkPoint array of length count in place. SkPoint are mapped by multiplying
/** Maps pts SkPoint array of length count in place. Points are mapped by multiplying
each SkPoint by SkMatrix. Given:
| A B C | | x |
@ -1257,15 +1265,15 @@ public:
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
|G H I| |1| Gx+Hy+I Gx+Hy+I
@param pts storage for mapped SkPoint
@param count number of SkPoint to transform
@param pts storage for mapped points
@param count number of points to transform
*/
void mapPoints(SkPoint pts[], int count) const {
this->mapPoints(pts, pts, count);
}
/** Maps count pts, skipping stride bytes to advance from one SkPoint to the next.
SkPoint are mapped by multiplying each SkPoint by SkMatrix. Given:
Points are mapped by multiplying each SkPoint by SkMatrix. Given:
| A B C | | x |
Matrix = | D E F |, pt = | y |
@ -1277,9 +1285,9 @@ public:
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
|G H I| |1| Gx+Hy+I Gx+Hy+I
@param pts storage for mapped SkPoint
@param pts storage for mapped points
@param stride size of record starting with SkPoint, in bytes
@param count number of SkPoint to transform
@param count number of points to transform
*/
void mapPointsWithStride(SkPoint pts[], size_t stride, int count) const {
SkASSERT(stride >= sizeof(SkPoint));
@ -1292,7 +1300,7 @@ public:
/** Maps src SkPoint array of length count to dst SkPoint array, skipping stride bytes
to advance from one SkPoint to the next.
SkPoint are mapped by multiplying each SkPoint by SkMatrix. Given:
Points are mapped by multiplying each SkPoint by SkMatrix. Given:
| A B C | | x |
Matrix = | D E F |, src = | y |
@ -1304,10 +1312,10 @@ public:
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
|G H I| |1| Gx+Hy+I Gx+Hy+I
@param dst storage for mapped SkPoint
@param src SkPoint to transform
@param dst storage for mapped points
@param src points to transform
@param stride size of record starting with SkPoint, in bytes
@param count number of SkPoint to transform
@param count number of points to transform
*/
void mapPointsWithStride(SkPoint dst[], const SkPoint src[], size_t stride, int count) const {
SkASSERT(stride >= sizeof(SkPoint));
@ -1381,8 +1389,8 @@ public:
return result;
}
/** Maps src SkVector array of length count to SkVector SkPoint array of equal or greater
length. SkVector are mapped by multiplying each SkVector by SkMatrix, treating
/** Maps src vector array of length count to vector SkPoint array of equal or greater
length. Vectors are mapped by multiplying each vector by SkMatrix, treating
SkMatrix translation as zero. Given:
| A B 0 | | x |
@ -1396,7 +1404,7 @@ public:
y = src[i].fY
}
each dst SkVector is computed as:
each dst vector is computed as:
|A B 0| |x| Ax+By Dx+Ey
Matrix * src = |D E 0| |y| = |Ax+By Dx+Ey Gx+Hy+I| = ------- , -------
@ -1404,13 +1412,13 @@ public:
src and dst may point to the same storage.
@param dst storage for mapped SkVector
@param src SkVector to transform
@param count number of SkVector to transform
@param dst storage for mapped vectors
@param src vectors to transform
@param count number of vectors to transform
*/
void mapVectors(SkVector dst[], const SkVector src[], int count) const;
/** Maps vecs SkVector array of length count in place, multiplying each SkVector by
/** Maps vecs vector array of length count in place, multiplying each vector by
SkMatrix, treating SkMatrix translation as zero. Given:
| A B 0 | | x |
@ -1424,57 +1432,57 @@ public:
y = vecs[i].fY
}
each result SkVector is computed as:
each result vector is computed as:
|A B 0| |x| Ax+By Dx+Ey
Matrix * vec = |D E 0| |y| = |Ax+By Dx+Ey Gx+Hy+I| = ------- , -------
|G H I| |1| Gx+Hy+I Gx+Hy+I
@param vecs SkVector to transform, and storage for mapped SkVector
@param count number of SkVector to transform
@param vecs vectors to transform, and storage for mapped vectors
@param count number of vectors to transform
*/
void mapVectors(SkVector vecs[], int count) const {
this->mapVectors(vecs, vecs, count);
}
/** Maps SkVector (x, y) to result. SkVector is mapped by multiplying by SkMatrix,
/** Maps vector (x, y) to result. Vector is mapped by multiplying by SkMatrix,
treating SkMatrix translation as zero. Given:
| A B 0 | | dx |
Matrix = | D E 0 |, vec = | dy |
| G H I | | 1 |
each result SkVector is computed as:
each result vector is computed as:
|A B 0| |dx| A*dx+B*dy D*dx+E*dy
Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , -----------
|G H I| | 1| G*dx+H*dy+I G*dx+*dHy+I
@param dx x-coordinate of SkVector to map
@param dy y-coordinate of SkVector to map
@param result storage for mapped SkVector
@param dx x-coordinate of vector to map
@param dy y-coordinate of vector to map
@param result storage for mapped vector
*/
void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
SkVector vec = { dx, dy };
this->mapVectors(result, &vec, 1);
}
/** Returns SkVector (x, y) multiplied by SkMatrix, treating SkMatrix translation as zero.
/** Returns vector (x, y) multiplied by SkMatrix, treating SkMatrix translation as zero.
Given:
| A B 0 | | dx |
Matrix = | D E 0 |, vec = | dy |
| G H I | | 1 |
each result SkVector is computed as:
each result vector is computed as:
|A B 0| |dx| A*dx+B*dy D*dx+E*dy
Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , -----------
|G H I| | 1| G*dx+H*dy+I G*dx+*dHy+I
@param dx x-coordinate of SkVector to map
@param dy y-coordinate of SkVector to map
@return mapped SkVector
@param dx x-coordinate of vector to map
@param dy y-coordinate of vector to map
@return mapped vector
*/
SkVector mapVector(SkScalar dx, SkScalar dy) const {
SkVector vec = { dx, dy };
@ -1487,7 +1495,7 @@ public:
Returned value is the same as calling rectStaysRect().
@param dst storage for bounds of mapped SkPoint
@param dst storage for bounds of mapped points
@param src SkRect to map
@return true if dst is equivalent to mapped src
*/
@ -1505,7 +1513,7 @@ public:
return this->mapRect(rect, *rect);
}
/** Maps four corners of rect to dst. SkPoint are mapped by multiplying each
/** Maps four corners of rect to dst. Points are mapped by multiplying each
rect corner by SkMatrix. rect corner is processed in this order:
(rect.fLeft, rect.fTop), (rect.fRight, rect.fTop), (rect.fRight, rect.fBottom),
(rect.fLeft, rect.fBottom).
@ -1527,7 +1535,7 @@ public:
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
|G H I| |1| Gx+Hy+I Gx+Hy+I
@param dst storage for mapped corner SkPoint
@param dst storage for mapped corner points
@param rect SkRect to map
*/
void mapRectToQuad(SkPoint dst[4], const SkRect& rect) const {
@ -1540,7 +1548,7 @@ public:
elements other than scale or translate: asserts if SK_DEBUG is defined;
otherwise, results are undefined.
@param dst storage for bounds of mapped SkPoint
@param dst storage for bounds of mapped points
@param src SkRect to map
*/
void mapRectScaleTranslate(SkRect* dst, const SkRect& src) const;
@ -1556,7 +1564,7 @@ public:
SkScalar mapRadius(SkScalar radius) const;
/** Returns true if a unit step in x at some y mapped through SkMatrix can be
represented by a constant SkVector. Returns true if getType() returns kIdentity_Mask,
represented by a constant vector. Returns true if getType() returns kIdentity_Mask,
or combinations of: kTranslate_Mask, kScale_Mask, and kAffine_Mask.
May return true if getType() returns kPerspective_Mask, but only when SkMatrix
@ -1566,11 +1574,11 @@ public:
*/
bool isFixedStepInX() const;
/** Returns SkVector representing a unit step in x at y mapped through SkMatrix.
/** Returns vector representing a unit step in x at y mapped through SkMatrix.
If isFixedStepInX() is false, returned value is undefined.
@param y position of line parallel to x-axis
@return SkVector advance of mapped unit step in x
@return vector advance of mapped unit step in x
*/
SkVector fixedStepInX(SkScalar y) const;
@ -1579,7 +1587,7 @@ public:
Returns false when the sign of zero values is the different; when one
matrix has positive zero value and the other has negative zero value.
Returns true even when both SkMatrix contain NaN.
Returns true even when both matrices contain NaN.
NaN never equals any value, including itself. To improve performance, NaN values
are treated as bit patterns that are equal if their bit patterns are equal.

View File

@ -529,7 +529,7 @@ public:
/** Set to stroke geometry.
Applies to SkRect, SkRegion, SkRRect, arcs, circles, ovals, SkPath, and text.
Arcs, lines, and SkPoint, are always drawn as if kStroke_Style is set,
Arcs, lines, and points, are always drawn as if kStroke_Style is set,
and ignore the set Style.
The stroke construction is unaffected by the FillType.
*/
@ -1542,10 +1542,12 @@ public:
bounds describes a pair of lines parallel to the text advance.
The return count is zero or a multiple of two, and is at most twice the number of glyphs in
the string.
Uses SkPaint::TextEncoding to decode text, SkTypeface to get the glyph paths,
Uses SkTypeface to get the glyph paths,
and text size, fake bold, and SkPathEffect to scale and modify the glyph paths.
Uses run array and SkPaint::Align to position intervals.
SkPaint::TextEncoding must be set to SkPaint::kGlyphID_TextEncoding.
Pass nullptr for intervals to determine the size of the interval array.
intervals are cached to improve performance for multiple calls.
@ -1581,7 +1583,7 @@ public:
*/
bool nothingToDraw() const;
/** (to be made private)
/** (to be made private)
Returns true if SkPaint does not include elements requiring extensive computation
to compute SkBaseDevice bounds of drawn geometry. For instance, SkPaint with SkPathEffect
always returns false.
@ -1590,7 +1592,7 @@ public:
*/
bool canComputeFastBounds() const;
/** (to be made private)
/** (to be made private)
Only call this if canComputeFastBounds() returned true. This takes a
raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
effects in the paint (e.g. stroking). If needed, it uses the storage
@ -1601,15 +1603,15 @@ public:
should not rely on storage being set to the result, but should always
use the returned value. It is legal for orig and storage to be the same
SkRect.
e.g.
if (paint.canComputeFastBounds()) {
SkRect r, storage;
path.computeBounds(&r, SkPath::kFast_BoundsType);
const SkRect& fastR = paint.computeFastBounds(r, &storage);
if (canvas->quickReject(fastR, ...)) {
// don't draw the path
}
}
e.g.
if (paint.canComputeFastBounds()) {
SkRect r, storage;
path.computeBounds(&r, SkPath::kFast_BoundsType);
const SkRect& fastR = paint.computeFastBounds(r, &storage);
if (canvas->quickReject(fastR, ...)) {
// don't draw the path
}
}
@param orig geometry modified by SkPaint when drawn
@param storage computed bounds of geometry; may not be nullptr
@ -1633,7 +1635,7 @@ public:
return this->doComputeFastBounds(orig, storage, style);
}
/** (to be made private)
/** (to be made private)
@param orig geometry modified by SkPaint when drawn
@param storage computed bounds of geometry
@ -1644,7 +1646,7 @@ public:
return this->doComputeFastBounds(orig, storage, kStroke_Style);
}
/** (to be made private)
/** (to be made private)
Computes the bounds, overriding the SkPaint SkPaint::Style. This can be used to
account for additional width required by stroking orig, without
altering SkPaint::Style set to fill.

View File

@ -17,11 +17,11 @@ class SkRRect;
class SkWStream;
/** \class SkPath
SkPath contain geometry. SkPath may be empty, or contain one or more SkPath::Verb that
outline a figure. SkPath always starts with a move verb to a Cartesian
coordinate, and may be followed by additional verbs that add lines or curves.
Paths contain geometry. Paths may be empty, or contain one or more verbs that
outline a figure. SkPath always starts with a move verb to a Cartesian_Coordinate,
and may be followed by additional verbs that add lines or curves.
Adding a close verb makes the geometry into a continuous loop, a closed contour.
SkPath may contain any number of contours, each beginning with a move verb.
Paths may contain any number of contours, each beginning with a move verb.
SkPath contours may contain only a move verb, or may also contain lines,
quadratic beziers, conics, and cubic beziers. SkPath contours may be open or
@ -55,7 +55,7 @@ public:
kCCW_Direction, //!< Contour travels in a counterclockwise direction
};
/** By default, SkPath has no SkPath::Verb, no SkPoint, and no weights.
/** By default, SkPath has no verbs, no points, and no weights.
SkPath::FillType is set to kWinding_FillType.
@return empty SkPath
@ -63,11 +63,11 @@ public:
SkPath();
/** Copy constructor makes two paths identical by value. Internally, path and
the returned result share pointer values. The underlying verb array, SkPoint arrays
the returned result share pointer values. The underlying verb array, SkPoint array
and weights are copied when modified.
Creating a SkPath copy is very efficient and never allocates memory.
SkPath are always copied by value from the interface; the underlying shared
Paths are always copied by value from the interface; the underlying shared
pointers are not exposed.
@param path SkPath to copy by value
@ -80,19 +80,19 @@ public:
~SkPath();
/** SkPath assignment makes two paths identical by value. Internally, assignment
shares pointer values. The underlying verb array, SkPoint arrays and weights
shares pointer values. The underlying verb array, SkPoint array and weights
are copied when modified.
Copying SkPath by assignment is very efficient and never allocates memory.
SkPath are always copied by value from the interface; the underlying shared
Copying paths by assignment is very efficient and never allocates memory.
Paths are always copied by value from the interface; the underlying shared
pointers are not exposed.
@param path verb array, SkPoint arrays, weights, and SkPath::FillType to copy
@param path verb array, SkPoint array, weights, and SkPath::FillType to copy
@return SkPath copied by value
*/
SkPath& operator=(const SkPath& path);
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint arrays, and weights
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
are equivalent.
@param a SkPath to compare
@ -101,7 +101,7 @@ public:
*/
friend SK_API bool operator==(const SkPath& a, const SkPath& b);
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint arrays, and weights
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
are not equivalent.
@param a SkPath to compare
@ -112,36 +112,35 @@ public:
return !(a == b);
}
/** Return true if SkPath contain equal SkPath::Verb and equal weights.
If SkPath contain one or more conics, the weights must match.
/** Return true if paths contain equal verbs and equal weights.
If paths contain one or more conics, the weights must match.
conicTo() may add different SkPath::Verb depending on conic weight, so it is not
trivial to interpolate a pair of SkPath containing conics with different
conicTo() may add different verbs depending on conic weight, so it is not
trivial to interpolate a pair of paths containing conics with different
conic weight values.
@param compare SkPath to compare
@return true if SkPath verb array and weights are equivalent
@return true if paths verb array and weights are equivalent
*/
bool isInterpolatable(const SkPath& compare) const;
/** Interpolate between SkPath with equal sized point arrays.
Copy verb array and weights to out,
and set out SkPoint arrays to a weighted average of this SkPoint arrays and ending
SkPoint arrays, using the formula: (this->points * weight) + ending->points * (1 - weight).
/** Interpolate between paths with SkPoint array of equal size.
Copy verb array and weights to out, and set out SkPoint array to a weighted
average of this SkPoint array and ending SkPoint array, using the formula: (this->points * weight) + ending->points * (1 - weight).
weight is most useful when between zero (ending SkPoint arrays) and
weight is most useful when between zero (ending SkPoint array) and
one (this Point_Array); will work with values outside of this
range.
interpolate() returns false and leaves out unchanged if SkPoint arrays is not
the same size as ending SkPoint arrays. Call isInterpolatable() to check SkPath
interpolate() returns false and leaves out unchanged if SkPoint array is not
the same size as ending SkPoint array. Call isInterpolatable() to check SkPath
compatibility prior to calling interpolate().
@param ending SkPoint arrays averaged with this SkPoint arrays
@param weight contribution of ending SkPoint arrays, and
one minus contribution of this SkPoint arrays
@param ending SkPoint array averaged with this SkPoint array
@param weight contribution of this SkPoint array, and
one minus contribution of ending SkPoint array
@param out SkPath replaced by interpolated averages
@return true if SkPath contain same number of SkPoint
@return true if paths contain same number of points
*/
bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const;
@ -163,13 +162,13 @@ public:
kInverseEvenOdd_FillType fills where the number of contour edges is even.
*/
enum FillType {
/** Specifies fill as area is enclosed by a non-zero sum of contour Direction. */
/** Specifies fill as area is enclosed by a non-zero sum of contour directions. */
kWinding_FillType,
/** Specifies fill as area enclosed by an odd number of contours. */
kEvenOdd_FillType,
/** Specifies fill as area is enclosed by a zero sum of contour Direction. */
/** Specifies fill as area is enclosed by a zero sum of contour directions. */
kInverseWinding_FillType,
/** Specifies fill as area enclosed by an even number of contours. */
@ -337,13 +336,13 @@ public:
}
/** Sets SkPath to its initial state.
Removes verb array, SkPoint arrays, and weights, and sets FillType to kWinding_FillType.
Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType.
Internal storage associated with SkPath is released.
*/
void reset();
/** Sets SkPath to its initial state, preserving internal storage.
Removes verb array, SkPoint arrays, and weights, and sets FillType to kWinding_FillType.
Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType.
Internal storage associated with SkPath is retained.
Use rewind() instead of reset() if SkPath storage will be reused and performance
@ -380,7 +379,7 @@ public:
}
/** Returns true if the path is volatile; it will not be altered or discarded
by the caller after it is drawn. SkPath by default have volatile set false, allowing
by the caller after it is drawn. Paths by default have volatile set false, allowing
SkSurface to attach a cache of data which speeds repeated drawing. If true, SkSurface
may not speed repeated drawing.
@ -391,7 +390,7 @@ public:
}
/** Specify whether SkPath is volatile; whether it will be altered or discarded
by the caller after it is drawn. SkPath by default have volatile set false, allowing
by the caller after it is drawn. Paths by default have volatile set false, allowing
SkBaseDevice to attach a cache of data which speeds repeated drawing.
Mark temporary paths, discarded or modified after use, as volatile
@ -470,7 +469,7 @@ public:
*/
int countPoints() const;
/** Returns SkPoint at index in SkPoint arrays. Valid range for index is
/** Returns SkPoint at index in SkPoint array. Valid range for index is
0 to countPoints() - 1.
Returns (0, 0) if index is out of range.
@ -489,7 +488,7 @@ public:
*/
int getPoints(SkPoint points[], int max) const;
/** Returns the number of SkPath::Verb: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb,
/** Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb,
kCubic_Verb, and kClose_Verb; added to SkPath.
@return length of verb array
@ -505,26 +504,26 @@ public:
*/
int getVerbs(uint8_t verbs[], int max) const;
/** Exchanges the verb array, SkPoint arrays, weights, and SkPath::FillType with other.
/** Exchanges the verb array, SkPoint array, weights, and SkPath::FillType with other.
Cached state is also exchanged. swap() internally exchanges pointers, so
it is lightweight and does not allocate memory.
swap() usage has largely been replaced by operator=(const SkPath& path).
SkPath do not copy their content on assignment until they are written to,
Paths do not copy their content on assignment until they are written to,
making assignment as efficient as swap().
@param other SkPath exchanged by value
*/
void swap(SkPath& other);
/** Returns minimum and maximum x and y values of SkPoint arrays.
/** Returns minimum and maximum x and y values of SkPoint array.
Returns (0, 0, 0, 0) if SkPath contains no points. Returned bounds width and height may
be larger or smaller than area affected when SkPath is drawn.
SkRect returned includes all SkPoint added to SkPath, including SkPoint associated with
SkRect returned includes all points added to SkPath, including points associated with
kMove_Verb that define empty contours.
@return bounds of all SkPoint in SkPoint arrays
@return bounds of all points in SkPoint array
*/
const SkRect& getBounds() const {
return fPathRef->getBounds();
@ -548,7 +547,7 @@ public:
Returned bounds width and height may be larger or smaller than area affected
when SkPath is drawn.
Includes SkPoint associated with kMove_Verb that define empty
Includes points associated with kMove_Verb that define empty
contours.
Behaves identically to getBounds() when SkPath contains
@ -573,11 +572,11 @@ public:
*/
bool conservativelyContainsRect(const SkRect& rect) const;
/** grows SkPath verb array and SkPoint arrays to contain extraPtCount additional SkPoint.
/** grows SkPath verb array and SkPoint array to contain extraPtCount additional points.
May improve performance and use less memory by
reducing the number and size of allocations when creating SkPath.
@param extraPtCount number of additional SkPoint to allocate
@param extraPtCount number of additional points to allocate
*/
void incReserve(unsigned extraPtCount);
@ -609,8 +608,8 @@ public:
/** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is
kClose_Verb, last point is set to (0, 0) before adding line.
lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed.
lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint arrays.
lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.
@param x end of added line in x
@param y end of added line in y
@ -620,8 +619,8 @@ public:
/** Adds line from last point to SkPoint p. If SkPath is empty, or last SkPath::Verb is
kClose_Verb, last point is set to (0, 0) before adding line.
lineTo() first appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed.
lineTo() then appends kLine_Verb to verb array and SkPoint p to SkPoint arrays.
lineTo() first appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
lineTo() then appends kLine_Verb to verb array and SkPoint p to SkPoint array.
@param p end SkPoint of added line
*/
@ -629,12 +628,12 @@ public:
this->lineTo(p.fX, p.fY);
}
/** Adds line from last point to SkVector (dx, dy). If SkPath is empty, or last SkPath::Verb is
/** Adds line from last point to vector (dx, dy). If SkPath is empty, or last SkPath::Verb is
kClose_Verb, last point is set to (0, 0) before adding line.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed;
then appends kLine_Verb to verb array and line end to SkPoint arrays.
Line end is last point plus SkVector (dx, dy).
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
then appends kLine_Verb to verb array and line end to SkPoint array.
Line end is last point plus vector (dx, dy).
Function name stands for "relative line to".
@param dx offset from last point x to line end x
@ -646,9 +645,9 @@ public:
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
before adding quad.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed;
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
then appends kQuad_Verb to verb array; and (x1, y1), (x2, y2)
to SkPoint arrays.
to SkPoint array.
@param x1 control SkPoint of quad in x
@param y1 control SkPoint of quad in y
@ -661,9 +660,9 @@ public:
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
before adding quad.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed;
then appends kQuad_Verb to verb array; and SkPoint p1, p2
to SkPoint arrays.
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
then appends kQuad_Verb to verb array; and points p1, p2
to SkPoint array.
@param p1 control SkPoint of added quad
@param p2 end SkPoint of added quad
@ -672,15 +671,15 @@ public:
this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
}
/** Adds quad from last point towards SkVector (dx1, dy1), to SkVector (dx2, dy2).
/** Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).
If SkPath is empty, or last SkPath::Verb
is kClose_Verb, last point is set to (0, 0) before adding quad.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays,
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
if needed; then appends kQuad_Verb to verb array; and appends quad
control and quad end to SkPoint arrays.
Quad control is last point plus SkVector (dx1, dy1).
Quad end is last point plus SkVector (dx2, dy2).
control and quad end to SkPoint array.
Quad control is last point plus vector (dx1, dy1).
Quad end is last point plus vector (dx2, dy2).
Function name stands for "relative quad to".
@param dx1 offset from last point x to quad control x
@ -694,16 +693,16 @@ public:
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
before adding conic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed.
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
If w is finite and not one, appends kConic_Verb to verb array;
and (x1, y1), (x2, y2) to SkPoint arrays; and w to conic weights.
and (x1, y1), (x2, y2) to SkPoint array; and w to conic weights.
If w is one, appends kQuad_Verb to verb array, and
(x1, y1), (x2, y2) to SkPoint arrays.
(x1, y1), (x2, y2) to SkPoint array.
If w is not finite, appends kLine_Verb twice to verb array, and
(x1, y1), (x2, y2) to SkPoint arrays.
(x1, y1), (x2, y2) to SkPoint array.
@param x1 control SkPoint of conic in x
@param y1 control SkPoint of conic in y
@ -718,16 +717,16 @@ public:
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
before adding conic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed.
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
If w is finite and not one, appends kConic_Verb to verb array;
and SkPoint p1, p2 to SkPoint arrays; and w to conic weights.
and points p1, p2 to SkPoint array; and w to conic weights.
If w is one, appends kQuad_Verb to verb array, and SkPoint p1, p2
to SkPoint arrays.
If w is one, appends kQuad_Verb to verb array, and points p1, p2
to SkPoint array.
If w is not finite, appends kLine_Verb twice to verb array, and
SkPoint p1, p2 to SkPoint arrays.
points p1, p2 to SkPoint array.
@param p1 control SkPoint of added conic
@param p2 end SkPoint of added conic
@ -737,11 +736,11 @@ public:
this->conicTo(p1.fX, p1.fY, p2.fX, p2.fY, w);
}
/** Adds conic from last point towards SkVector (dx1, dy1), to SkVector (dx2, dy2),
/** Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2),
weighted by w. If SkPath is empty, or last SkPath::Verb
is kClose_Verb, last point is set to (0, 0) before adding conic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays,
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
if needed.
If w is finite and not one, next appends kConic_Verb to verb array,
@ -749,9 +748,9 @@ public:
kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb
twice to verb array.
In all cases appends SkPoint control and end to SkPoint arrays.
control is last point plus SkVector (dx1, dy1).
end is last point plus SkVector (dx2, dy2).
In all cases appends points control and end to SkPoint array.
control is last point plus vector (dx1, dy1).
end is last point plus vector (dx2, dy2).
Function name stands for "relative conic to".
@ -768,9 +767,9 @@ public:
(x3, y3). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
(0, 0) before adding cubic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed;
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
then appends kCubic_Verb to verb array; and (x1, y1), (x2, y2), (x3, y3)
to SkPoint arrays.
to SkPoint array.
@param x1 first control SkPoint of cubic in x
@param y1 first control SkPoint of cubic in y
@ -786,9 +785,9 @@ public:
SkPoint p3. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
(0, 0) before adding cubic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays, if needed;
then appends kCubic_Verb to verb array; and SkPoint p1, p2, p3
to SkPoint arrays.
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
then appends kCubic_Verb to verb array; and points p1, p2, p3
to SkPoint array.
@param p1 first control SkPoint of cubic
@param p2 second control SkPoint of cubic
@ -798,16 +797,16 @@ public:
this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
}
/** Adds cubic from last point towards SkVector (dx1, dy1), then towards
SkVector (dx2, dy2), to SkVector (dx3, dy3).
/** Adds cubic from last point towards vector (dx1, dy1), then towards
vector (dx2, dy2), to vector (dx3, dy3).
If SkPath is empty, or last SkPath::Verb
is kClose_Verb, last point is set to (0, 0) before adding cubic.
Appends kMove_Verb to verb array and (0, 0) to SkPoint arrays,
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
if needed; then appends kCubic_Verb to verb array; and appends cubic
control and cubic end to SkPoint arrays.
Cubic control is last point plus SkVector (dx1, dy1).
Cubic end is last point plus SkVector (dx2, dy2).
control and cubic end to SkPoint array.
Cubic control is last point plus vector (dx1, dy1).
Cubic end is last point plus vector (dx2, dy2).
Function name stands for "relative cubic to".
@param x1 offset from last point x to first cubic control x
@ -855,7 +854,7 @@ public:
is part of circle sized to radius, positioned so it touches both tangent lines.
If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath.
The length of SkVector from p1 to p2 does not affect arc.
The length of vector from p1 to p2 does not affect arc.
Arc sweep is always less than 180 degrees. If radius is zero, or if
tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.
@ -1220,20 +1219,20 @@ public:
kAppend_AddPathMode,
/** is not empty, add line from last point to added SkPath first SkPoint. Skip added
SkPath initial kMove_Verb, then append remining Verb, SkPoint, and conic weights.
SkPath initial kMove_Verb, then append remining verbs, points, and conic weights.
*/
kExtend_AddPathMode,
};
/** Append src to SkPath, offset by (dx, dy).
If mode is kAppend_AddPathMode, src verb array, SkPoint arrays, and conic weights are
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
added unaltered. If mode is kExtend_AddPathMode, add line before appending
SkPath::Verb, SkPoint, and conic weights.
verbs, points, and conic weights.
@param src SkPath SkPath::Verb, SkPoint, and conic weights to add
@param dx offset added to src SkPoint arrays x coordinates
@param dy offset added to src SkPoint arrays y coordinates
@param src SkPath verbs, points, and conic weights to add
@param dx offset added to src SkPoint array x coordinates
@param dy offset added to src SkPoint array y coordinates
@param mode kAppend_AddPathMode or kExtend_AddPathMode
*/
void addPath(const SkPath& src, SkScalar dx, SkScalar dy,
@ -1241,11 +1240,11 @@ public:
/** Append src to SkPath.
If mode is kAppend_AddPathMode, src verb array, SkPoint arrays, and conic weights are
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
added unaltered. If mode is kExtend_AddPathMode, add line before appending
SkPath::Verb, SkPoint, and conic weights.
verbs, points, and conic weights.
@param src SkPath SkPath::Verb, SkPoint, and conic weights to add
@param src SkPath verbs, points, and conic weights to add
@param mode kAppend_AddPathMode or kExtend_AddPathMode
*/
void addPath(const SkPath& src, AddPathMode mode = kAppend_AddPathMode) {
@ -1255,13 +1254,13 @@ public:
}
/** Append src to SkPath, transformed by matrix. Transformed curves may have different
SkPath::Verb, SkPoint, and conic weights.
verbs, points, and conic weights.
If mode is kAppend_AddPathMode, src verb array, SkPoint arrays, and conic weights are
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
added unaltered. If mode is kExtend_AddPathMode, add line before appending
SkPath::Verb, SkPoint, and conic weights.
verbs, points, and conic weights.
@param src SkPath SkPath::Verb, SkPoint, and conic weights to add
@param src SkPath verbs, points, and conic weights to add
@param matrix transform applied to src
@param mode kAppend_AddPathMode or kExtend_AddPathMode
*/
@ -1270,30 +1269,30 @@ public:
/** Append src to SkPath, from back to front.
Reversed src always appends a new contour to SkPath.
@param src SkPath SkPath::Verb, SkPoint, and conic weights to add
@param src SkPath verbs, points, and conic weights to add
*/
void reverseAddPath(const SkPath& src);
/** Offset SkPoint arrays by (dx, dy). Offset SkPath replaces dst.
/** Offset SkPoint array by (dx, dy). Offset SkPath replaces dst.
If dst is nullptr, SkPath is replaced by offset data.
@param dx offset added to SkPoint arrays x coordinates
@param dy offset added to SkPoint arrays y coordinates
@param dx offset added to SkPoint array x coordinates
@param dy offset added to SkPoint array y coordinates
@param dst overwritten, translated copy of SkPath; may be nullptr
*/
void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
/** Offset SkPoint arrays by (dx, dy). SkPath is replaced by offset data.
/** Offset SkPoint array by (dx, dy). SkPath is replaced by offset data.
@param dx offset added to SkPoint arrays x coordinates
@param dy offset added to SkPoint arrays y coordinates
@param dx offset added to SkPoint array x coordinates
@param dy offset added to SkPoint array y coordinates
*/
void offset(SkScalar dx, SkScalar dy) {
this->offset(dx, dy, this);
}
/** Transform verb array, SkPoint arrays, and weight by matrix.
transform may change SkPath::Verb and increase their number.
/** Transform verb array, SkPoint array, and weight by matrix.
transform may change verbs and increase their number.
Transformed SkPath replaces dst; if dst is nullptr, original data
is replaced.
@ -1302,8 +1301,8 @@ public:
*/
void transform(const SkMatrix& matrix, SkPath* dst) const;
/** Transform verb array, SkPoint arrays, and weight by matrix.
transform may change SkPath::Verb and increase their number.
/** Transform verb array, SkPoint array, and weight by matrix.
transform may change verbs and increase their number.
SkPath is replaced by transformed data.
@param matrix SkMatrix to apply to SkPath
@ -1312,16 +1311,16 @@ public:
this->transform(matrix, this);
}
/** Returns last point on SkPath in lastPt. Returns false if SkPoint arrays is empty,
/** Returns last point on SkPath in lastPt. Returns false if SkPoint array is empty,
storing (0, 0) if lastPt is not nullptr.
@param lastPt storage for final SkPoint in SkPoint arrays; may be nullptr
@return true if SkPoint arrays contains one or more SkPoint
@param lastPt storage for final SkPoint in SkPoint array; may be nullptr
@return true if SkPoint array contains one or more points
*/
bool getLastPt(SkPoint* lastPt) const;
/** Set last point to (x, y). If SkPoint arrays is empty, append kMove_Verb to
verb array and (x, y) to SkPoint arrays.
/** Set last point to (x, y). If SkPoint array is empty, append kMove_Verb to
verb array and (x, y) to SkPoint array.
@param x set x-coordinate of last point
@param y set y-coordinate of last point
@ -1351,7 +1350,7 @@ public:
};
/** Returns a mask, where each set bit corresponds to a SegmentMask constant
if SkPath contains one or more SkPath::Verb of that type.
if SkPath contains one or more verbs of that type.
Returns zero if SkPath contains no lines, or curves: quads, conics, or cubics.
getSegmentMasks() returns a cached result; it is very fast.
@ -1386,9 +1385,9 @@ public:
*/
kConic_Verb,
/** Adds cubic from last point, using two control SkPoint, and end SkPoint.
Cubic is a third-order Bezier section within tangents from last point to
first control SkPoint, and from second control SkPoint to end SkPoint.
/** Adds cubic from last point, using two control points, and end SkPoint.
Cubic is a third-order Bezier_Curve section within tangents from last point
to first control SkPoint, and from second control SkPoint to end SkPoint.
*/
kCubic_Verb,
kClose_Verb, //!< Closes contour, connecting last point to kMove_Verb SkPoint.
@ -1407,7 +1406,7 @@ public:
*/
Iter();
/** Sets iter to return elements of verb array, SkPoint arrays, and conic weight in path.
/** Sets iter to return elements of verb array, SkPoint array, and conic weight in path.
If forceClose is true, iter will add kLine_Verb and kClose_Verb after each
open contour. path is not altered.
@ -1417,7 +1416,7 @@ public:
*/
Iter(const SkPath& path, bool forceClose);
/** Sets iter to return elements of verb array, SkPoint arrays, and conic weight in path.
/** Sets iter to return elements of verb array, SkPoint array, and conic weight in path.
If forceClose is true, iter will add kLine_Verb and kClose_Verb after each
open contour. path is not altered.
@ -1508,7 +1507,7 @@ public:
*/
RawIter() {}
/** Sets RawIter to return elements of verb array, SkPoint arrays, and conic weight in path.
/** Sets RawIter to return elements of verb array, SkPoint array, and conic weight in path.
@param path SkPath to iterate
@return RawIter of path
@ -1517,7 +1516,7 @@ public:
setPath(path);
}
/** Sets iter to return elements of verb array, SkPoint arrays, and conic weight in path.
/** Sets iter to return elements of verb array, SkPoint array, and conic weight in path.
@param path SkPath to iterate
*/
@ -1573,7 +1572,7 @@ public:
/** Writes text representation of SkPath to stream. If stream is nullptr, writes to
standard output. Set forceClose to true to get edges used to fill SkPath.
Set dumpAsHex true to generate exact binary representations
of floating point numbers used in SkPoint arrays and conic weights.
of floating point numbers used in SkPoint array and conic weights.
@param stream writable SkStream receiving SkPath text representation; may be nullptr
@param forceClose true if missing kClose_Verb is output
@ -1600,7 +1599,7 @@ public:
/** Writes SkPath to buffer, returning the number of bytes written.
Pass nullptr to obtain the storage size.
Writes SkPath::FillType, verb array, SkPoint arrays, conic weight, and
Writes SkPath::FillType, verb array, SkPoint array, conic weight, and
additionally writes computed information like SkPath::Convexity and bounds.
Use only be used in concert with readFromMemory();
@ -1611,22 +1610,22 @@ public:
*/
size_t writeToMemory(void* buffer) const;
/** Write SkPath to buffer, returning the buffer written to, wrapped in data.
/** Write SkPath to buffer, returning the buffer written to, wrapped in SkData.
serialize() writes SkPath::FillType, verb array, SkPoint arrays, conic weight, and
serialize() writes SkPath::FillType, verb array, SkPoint array, conic weight, and
additionally writes computed information like SkPath::Convexity and bounds.
serialize() should only be used in concert with readFromMemory().
The format used for SkPath in memory is not guaranteed.
@return SkPath data wrapped in data buffer
@return SkPath data wrapped in SkData buffer
*/
sk_sp<SkData> serialize() const;
/** Initializes SkPath from buffer of size length. Returns zero if the buffer is
data is inconsistent, or the length is too small.
Reads SkPath::FillType, verb array, SkPoint arrays, conic weight, and
Reads SkPath::FillType, verb array, SkPoint array, conic weight, and
additionally reads computed information like SkPath::Convexity and bounds.
Used only in concert with writeToMemory();
@ -1639,7 +1638,7 @@ public:
size_t readFromMemory(const void* buffer, size_t length);
/** Returns a non-zero, globally unique value. A different value is returned
if verb array, SkPoint arrays, or conic weight changes.
if verb array, SkPoint array, or conic weight changes.
Setting SkPath::FillType does not change generation id.

View File

@ -120,7 +120,7 @@ public:
*/
bool SK_WARN_UNUSED_RESULT extractSubset(SkPixmap* subset, const SkIRect& area) const;
/** Returns width, height, SkAlphaType, SkColorType, and SkColorSpace.
/** Returns width, height, alpha type, color type, and SkColorSpace.
@return reference to ImageInfo
*/
@ -157,18 +157,18 @@ public:
*/
int height() const { return fInfo.height(); }
/** Returns SkColorType, one of: kUnknown_SkColorType, kAlpha_8_SkColorType,
/** Returns color type, one of: kUnknown_SkColorType, kAlpha_8_SkColorType,
kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType,
kBGRA_8888_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType.
@return SkColorType in SkImageInfo
@return color type in SkImageInfo
*/
SkColorType colorType() const { return fInfo.colorType(); }
/** Returns SkAlphaType, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType,
/** Returns alpha type, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType,
kPremul_SkAlphaType, kUnpremul_SkAlphaType.
@return SkAlphaType in SkImageInfo
@return alpha type in SkImageInfo
*/
SkAlphaType alphaType() const { return fInfo.alphaType(); }
@ -180,11 +180,11 @@ public:
*/
SkColorSpace* colorSpace() const { return fInfo.colorSpace(); }
/** Returns true if SkAlphaType is kOpaque_SkAlphaType.
Does not check if SkColorType allows alpha, or if any pixel value has
/** Returns true if alpha type is kOpaque_SkAlphaType.
Does not check if color type allows alpha, or if any pixel value has
transparency.
@return true if SkImageInfo has opaque SkAlphaType
@return true if SkImageInfo has opaque alpha type
*/
bool isOpaque() const { return fInfo.isOpaque(); }
@ -218,30 +218,30 @@ public:
*/
size_t computeByteSize() const { return fInfo.computeByteSize(fRowBytes); }
/** Returns true if all pixels are opaque. SkColorType determines how pixels
are encoded, and whether pixel describes alpha. Returns true for SkColorType
without alpha in each pixel; for other SkColorType, returns true if all
/** Returns true if all pixels are opaque. color type determines how pixels
are encoded, and whether pixel describes alpha. Returns true for color types
without alpha in each pixel; for other color types, returns true if all
pixels have alpha values equivalent to 1.0 or greater.
For SkColorType kRGB_565_SkColorType or kGray_8_SkColorType: always
returns true. For SkColorType kAlpha_8_SkColorType, kBGRA_8888_SkColorType,
For color types kRGB_565_SkColorType or kGray_8_SkColorType: always
returns true. For color types kAlpha_8_SkColorType, kBGRA_8888_SkColorType,
kRGBA_8888_SkColorType: returns true if all pixel alpha values are 255.
For SkColorType kARGB_4444_SkColorType: returns true if all pixel alpha values are 15.
For color type kARGB_4444_SkColorType: returns true if all pixel alpha values are 15.
For kRGBA_F16_SkColorType: returns true if all pixel alpha values are 1.0 or
greater.
Returns false for kUnknown_SkColorType.
@return true if all pixels have opaque values or SkColorType is opaque
@return true if all pixels have opaque values or color type is opaque
*/
bool computeIsOpaque() const;
/** Returns pixel at (x, y) as unpremultiplied color.
Returns black with alpha if SkColorType is kAlpha_8_SkColorType.
Returns black with alpha if color type is kAlpha_8_SkColorType.
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined; and returns undefined values or may crash if
SK_RELEASE is defined. Fails if SkColorType is kUnknown_SkColorType or
SK_RELEASE is defined. Fails if color type is kUnknown_SkColorType or
pixel address is nullptr.
SkColorSpace in SkImageInfo is ignored. Some color precision may be lost in the
@ -257,7 +257,7 @@ public:
/** Returns readable pixel address at (x, y). Returns nullptr if SkPixelRef is nullptr.
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined. Returns nullptr if SkColorType is kUnknown_SkColorType.
built with SK_DEBUG defined. Returns nullptr if color type is kUnknown_SkColorType.
Performs a lookup of pixel size; for better performance, call
one of: addr8, addr16, addr32, addr64, or addrF16().
@ -271,7 +271,7 @@ public:
}
/** Returns readable base pixel address. Result is addressable as unsigned 8-bit bytes.
Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or
Will trigger an assert() if color type is not kAlpha_8_SkColorType or
kGray_8_SkColorType, and is built with SK_DEBUG defined.
One byte corresponds to one pixel.
@ -284,7 +284,7 @@ public:
}
/** Returns readable base pixel address. Result is addressable as unsigned 16-bit words.
Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or
Will trigger an assert() if color type is not kRGB_565_SkColorType or
kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
@ -297,7 +297,7 @@ public:
}
/** Returns readable base pixel address. Result is addressable as unsigned 32-bit words.
Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or
Will trigger an assert() if color type is not kRGBA_8888_SkColorType or
kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
@ -310,7 +310,7 @@ public:
}
/** Returns readable base pixel address. Result is addressable as unsigned 64-bit words.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
Will trigger an assert() if color type is not kRGBA_F16_SkColorType and is built
with SK_DEBUG defined.
One word corresponds to one pixel.
@ -323,7 +323,7 @@ public:
}
/** Returns readable base pixel address. Result is addressable as unsigned 16-bit words.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
Will trigger an assert() if color type is not kRGBA_F16_SkColorType and is built
with SK_DEBUG defined.
Each word represents one color component encoded as a half float.
@ -342,7 +342,7 @@ public:
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or
Will trigger an assert() if color type is not kAlpha_8_SkColorType or
kGray_8_SkColorType, and is built with SK_DEBUG defined.
@param x column index, zero or greater, and less than width()
@ -360,7 +360,7 @@ public:
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or
Will trigger an assert() if color type is not kRGB_565_SkColorType or
kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
@param x column index, zero or greater, and less than width()
@ -378,7 +378,7 @@ public:
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or
Will trigger an assert() if color type is not kRGBA_8888_SkColorType or
kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
@param x column index, zero or greater, and less than width()
@ -396,7 +396,7 @@ public:
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
Will trigger an assert() if color type is not kRGBA_F16_SkColorType and is built
with SK_DEBUG defined.
@param x column index, zero or greater, and less than width()
@ -414,7 +414,7 @@ public:
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
Will trigger an assert() if color type is not kRGBA_F16_SkColorType and is built
with SK_DEBUG defined.
Each unsigned 16-bit word represents one color component encoded as a half float.
@ -438,7 +438,7 @@ public:
/** Returns writable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if
built with SK_DEBUG defined. Returns zero if SkColorType is kUnknown_SkColorType.
built with SK_DEBUG defined. Returns zero if color type is kUnknown_SkColorType.
@param x column index, zero or greater, and less than width()
@param y row index, zero or greater, and less than height()
@ -449,7 +449,7 @@ public:
}
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
8-bit bytes. Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType
8-bit bytes. Will trigger an assert() if color type is not kAlpha_8_SkColorType
or kGray_8_SkColorType, and is built with SK_DEBUG defined.
One byte corresponds to one pixel.
@ -463,7 +463,7 @@ public:
}
/** Returns writable_addr pixel address at (x, y). Result is addressable as unsigned
16-bit words. Will trigger an assert() if SkColorType is not kRGB_565_SkColorType
16-bit words. Will trigger an assert() if color type is not kRGB_565_SkColorType
or kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
@ -477,7 +477,7 @@ public:
}
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
32-bit words. Will trigger an assert() if SkColorType is not
32-bit words. Will trigger an assert() if color type is not
kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG
defined.
@ -492,7 +492,7 @@ public:
}
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
64-bit words. Will trigger an assert() if SkColorType is not
64-bit words. Will trigger an assert() if color type is not
kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
One word corresponds to one pixel.
@ -506,7 +506,7 @@ public:
}
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
16-bit words. Will trigger an assert() if SkColorType is not
16-bit words. Will trigger an assert() if color type is not
kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
Each word represents one color component encoded as a half float.
@ -523,7 +523,7 @@ public:
/** Copies a SkRect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not
exceed (this->width(), this->height()).
dstInfo specifies width, height, SkColorType, SkAlphaType, and
dstInfo specifies width, height, color type, alpha type, and
SkColorSpace of destination. dstRowBytes specifics the gap from one destination
row to the next. Returns true if pixels are copied. Returns false if
dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
@ -544,7 +544,7 @@ public:
If behavior is SkTransferFunctionBehavior::kIgnore: source
pixels are treated as if they are linear, regardless of how they are encoded.
@param dstInfo destination width, height, SkColorType, SkAlphaType, SkColorSpace
@param dstInfo destination width, height, color type, alpha type, SkColorSpace
@param dstPixels destination pixel storage
@param dstRowBytes destination row length
@param srcX column index whose absolute value is less than width()
@ -559,7 +559,7 @@ public:
/** Copies a SkRect of pixels to dstPixels. Copy starts at (0, 0), and does not
exceed (this->width(), this->height()).
dstInfo specifies width, height, SkColorType, SkAlphaType, and
dstInfo specifies width, height, color type, alpha type, and
SkColorSpace of destination. dstRowBytes specifics the gap from one destination
row to the next. Returns true if pixels are copied. Returns false if
dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
@ -573,7 +573,7 @@ public:
Returns false if this->width() or this->height() is zero or negative.
@param dstInfo destination width, height, SkColorType, SkAlphaType, SkColorSpace
@param dstInfo destination width, height, color type, alpha type, SkColorSpace
@param dstPixels destination pixel storage
@param dstRowBytes destination row length
@return true if pixels are copied to dstPixels
@ -585,7 +585,7 @@ public:
/** Copies a SkRect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not
exceed (this->width(), this->height()).
dstInfo specifies width, height, SkColorType, SkAlphaType, and
dstInfo specifies width, height, color type, alpha type, and
SkColorSpace of destination. dstRowBytes specifics the gap from one destination
row to the next. Returns true if pixels are copied. Returns false if
dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
@ -601,7 +601,7 @@ public:
false if this->width() or this->height() is zero or negative. Returns false if:
abs(srcX) >= this->width(), or if abs(srcY) >= this->height().
@param dstInfo destination width, height, SkColorType, SkAlphaType, SkColorSpace
@param dstInfo destination width, height, color type, alpha type, SkColorSpace
@param dstPixels destination pixel storage
@param dstRowBytes destination row length
@param srcX column index whose absolute value is less than width()
@ -615,8 +615,8 @@ public:
}
/** Copies a SkRect of pixels to dst. Copy starts at (srcX, srcY), and does not
exceed (this->width(), this->height()). dst specifies width, height, SkColorType,
SkAlphaType, and SkColorSpace of destination. Returns true if pixels are copied.
exceed (this->width(), this->height()). dst specifies width, height, color type,
alpha type, and SkColorSpace of destination. Returns true if pixels are copied.
Returns false if dst.addr() equals nullptr, or dst.rowBytes() is less than
dst SkImageInfo::minRowBytes.
@ -640,15 +640,15 @@ public:
return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
}
/** Copies pixels inside bounds() to dst. dst specifies width, height, SkColorType,
SkAlphaType, and SkColorSpace of destination. Returns true if pixels are copied.
/** Copies pixels inside bounds() to dst. dst specifies width, height, color type,
alpha type, and SkColorSpace of destination. Returns true if pixels are copied.
Returns false if dst.addr() equals nullptr, or dst.rowBytes() is less than
dst SkImageInfo::minRowBytes.
Pixels are copied only if pixel conversion is possible. If this->colorType() is
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match.
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst color type must match.
If this->colorType() is kGray_8_SkColorType, dst SkColorSpace must match.
If this->alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must
If this->alphaType() is kOpaque_SkAlphaType, dst alpha type must
match. If this->colorSpace() is nullptr, dst SkColorSpace must match. Returns
false if pixel conversion is not possible.
@ -667,9 +667,9 @@ public:
less than dst SkImageInfo::minRowBytes.
Pixels are copied only if pixel conversion is possible. If this->colorType() is
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match.
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst color type must match.
If this->colorType() is kGray_8_SkColorType, dst SkColorSpace must match.
If this->alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must
If this->alphaType() is kOpaque_SkAlphaType, dst alpha type must
match. If this->colorSpace() is nullptr, dst SkColorSpace must match. Returns
false if pixel conversion is not possible.

View File

@ -12,20 +12,41 @@
#include "SkScalar.h"
/** \struct SkIPoint16
SkIPoint holds two 16 bit integer coordinates
*/
struct SkIPoint16 {
int16_t fX;
int16_t fY;
int16_t fX; //!< x-axis value used by SkIPoint16.
int16_t fY; //!< y-axis value used by SkIPoint16.
/** Sets fX to x, fY to y. If SK_DEBUG is defined, asserts
if x or y does not fit in 16 bits.
@param x integer x-axis value of constructed SkIPoint
@param y integer y-axis value of constructed SkIPoint
@return SkIPoint16 (x, y)
*/
static constexpr SkIPoint16 Make(int x, int y) {
return {SkToS16(x), SkToS16(y)};
}
/** Returns x-axis value of SkIPoint16.
@return fX
*/
int16_t x() const { return fX; }
/** Returns y-axis value of SkIPoint.
@return fY
*/
int16_t y() const { return fY; }
/** Sets fX to x and fY to y.
@param x new value for fX
@param y new value for fY
*/
void set(int x, int y) {
fX = SkToS16(x);
fY = SkToS16(y);
@ -36,71 +57,127 @@ struct SkIPoint;
typedef SkIPoint SkIVector;
/** \struct SkIPoint
SkIPoint holds two 32 bit integer coordinates
*/
struct SkIPoint {
int32_t fX;
int32_t fY;
int32_t fX; //!< x-axis value used by SkIPoint.
int32_t fY; //!< y-axis value used by SkIPoint.
/** Sets fX to x, fY to y.
@param x integer x-axis value of constructed SkIPoint
@param y integer y-axis value of constructed SkIPoint
@return SkIPoint (x, y)
*/
static constexpr SkIPoint Make(int32_t x, int32_t y) {
return {x, y};
}
/** Returns x-axis value of SkIPoint.
@return fX
*/
int32_t x() const { return fX; }
/** Returns y-axis value of SkIPoint.
@return fY
*/
int32_t y() const { return fY; }
/**
* Returns true iff fX and fY are both zero.
*/
/** Returns true if fX and fY are both zero.
@return true if fX is zero and fY is zero
*/
bool isZero() const { return (fX | fY) == 0; }
/** Set the x and y values of the point. */
/** Sets fX to x and fY to y.
@param x new value for fX
@param y new value for fY
*/
void set(int32_t x, int32_t y) {
fX = x;
fY = y;
}
/** Return a new point whose X and Y coordinates are the negative of the
original point's
/** Returns SkIPoint changing the signs of fX and fY.
@return SkIPoint as (-fX, -fY)
*/
SkIPoint operator-() const {
return {-fX, -fY};
}
/** Add v's coordinates to this point's */
/** Offsets SkIPoint by ivector v. Sets SkIPoint to (fX + v.fX, fY + v.fY).
@param v ivector to add
*/
void operator+=(const SkIVector& v) {
fX += v.fX;
fY += v.fY;
}
/** Subtract v's coordinates from this point's */
/** Subtracts ivector v from SkIPoint. Sets SkIPoint to: (fX - v.fX, fY - v.fY).
@param v ivector to subtract
*/
void operator-=(const SkIVector& v) {
fX -= v.fX;
fY -= v.fY;
}
/** Returns true if the point's coordinates equal (x,y) */
/** Returns true if SkIPoint is equivalent to SkIPoint constructed from (x, y).
@param x value compared with fX
@param y value compared with fY
@return true if SkIPoint equals (x, y)
*/
bool equals(int32_t x, int32_t y) const {
return fX == x && fY == y;
}
/** Returns true if a is equivalent to b.
@param a SkIPoint to compare
@param b SkIPoint to compare
@return true if a.fX == b.fX and a.fY == b.fY
*/
friend bool operator==(const SkIPoint& a, const SkIPoint& b) {
return a.fX == b.fX && a.fY == b.fY;
}
/** Returns true if a is not equivalent to b.
@param a SkIPoint to compare
@param b SkIPoint to compare
@return true if a.fX != b.fX or a.fY != b.fY
*/
friend bool operator!=(const SkIPoint& a, const SkIPoint& b) {
return a.fX != b.fX || a.fY != b.fY;
}
/** Returns a new point whose coordinates are the difference between
a and b (i.e. a - b)
/** Returns ivector from b to a; computed as (a.fX - b.fX, a.fY - b.fY).
Can also be used to subtract ivector from ivector, returning ivector.
@param a SkIPoint or ivector to subtract from
@param b ivector to subtract
@return ivector from b to a
*/
friend SkIVector operator-(const SkIPoint& a, const SkIPoint& b) {
return {a.fX - b.fX, a.fY - b.fY};
}
/** Returns a new point whose coordinates are the sum of a and b (a + b)
/** Returns SkIPoint resulting from SkIPoint a offset by ivector b, computed as: (a.fX + b.fX, a.fY + b.fY).
Can also be used to offset SkIPoint b by ivector a, returning SkIPoint.
Can also be used to add ivector to ivector, returning ivector.
@param a SkIPoint or ivector to add to
@param b SkIPoint or ivector to add
@return SkIPoint equal to a offset by b
*/
friend SkIPoint operator+(const SkIPoint& a, const SkIVector& b) {
return {a.fX + b.fX, a.fY + b.fY};
@ -110,143 +187,255 @@ struct SkIPoint {
struct SkPoint;
typedef SkPoint SkVector;
/** \struct SkPoint
*/
struct SK_API SkPoint {
SkScalar fX;
SkScalar fY;
/** x-axis value used by both SkPoint and vector. May contain any value, including
infinities and NaN.
*/
SkScalar fX;
/** y-axis value used by both SkPoint and vector. May contain any value, including
infinities and NaN.
*/
SkScalar fY;
/** Sets fX to x, fY to y. Used both to set SkPoint and vector.
@param x SkScalar x-axis value of constructed SkPoint or vector
@param y SkScalar y-axis value of constructed SkPoint or vector
@return SkPoint (x, y)
*/
static constexpr SkPoint Make(SkScalar x, SkScalar y) {
return {x, y};
}
/** Returns x-axis value of SkPoint or vector.
@return fX
*/
SkScalar x() const { return fX; }
/** Returns y-axis value of SkPoint or vector.
@return fY
*/
SkScalar y() const { return fY; }
/**
* Returns true iff fX and fY are both zero.
*/
/** Returns true if fX and fY are both zero.
@return true if fX is zero and fY is zero
*/
bool isZero() const { return (0 == fX) & (0 == fY); }
/** Set the point's X and Y coordinates */
/** Sets fX to x and fY to y.
@param x new value for fX
@param y new value for fY
*/
void set(SkScalar x, SkScalar y) {
fX = x;
fY = y;
}
/** Set the point's X and Y coordinates by automatically promoting (x,y) to
SkScalar values.
/** Sets fX to x and fY to y, promoting integers to SkScalar values.
Assigning a large integer value directly to fX or fY may cause a compiler
error, triggered by narrowing conversion of int to SkScalar. This safely
casts x and y to avoid the error.
@param x new value for fX
@param y new value for fY
*/
void iset(int32_t x, int32_t y) {
fX = SkIntToScalar(x);
fY = SkIntToScalar(y);
}
/** Set the point's X and Y coordinates by automatically promoting p's
coordinates to SkScalar values.
/** Sets fX to p.fX and fY to p.fY, promoting integers to SkScalar values.
Assigning an SkIPoint containing a large integer value directly to fX or fY may
cause a compiler error, triggered by narrowing conversion of int to SkScalar.
This safely casts p.fX and p.fY to avoid the error.
@param p SkIPoint members promoted to SkScalar
*/
void iset(const SkIPoint& p) {
fX = SkIntToScalar(p.fX);
fY = SkIntToScalar(p.fY);
}
/** Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
@param pt members providing magnitude for fX and fY
*/
void setAbs(const SkPoint& pt) {
fX = SkScalarAbs(pt.fX);
fY = SkScalarAbs(pt.fY);
}
/** Adds offset to each SkPoint in points array with count entries.
@param points SkPoint array
@param count entries in array
@param offset vector added to points
*/
static void Offset(SkPoint points[], int count, const SkVector& offset) {
Offset(points, count, offset.fX, offset.fY);
}
/** Adds offset (dx, dy) to each SkPoint in points array of length count.
@param points SkPoint array
@param count entries in array
@param dx added to fX in points
@param dy added to fY in points
*/
static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) {
for (int i = 0; i < count; ++i) {
points[i].offset(dx, dy);
}
}
/** Adds offset (dx, dy) to SkPoint.
@param dx added to fX
@param dy added to fY
*/
void offset(SkScalar dx, SkScalar dy) {
fX += dx;
fY += dy;
}
/** Return the euclidian distance from (0,0) to the point
/** Returns the Euclidean_Distance from origin, computed as:
sqrt(fX * fX + fY * fY)
.
@return straight-line distance to origin
*/
SkScalar length() const { return SkPoint::Length(fX, fY); }
/** Returns the Euclidean_Distance from origin, computed as:
sqrt(fX * fX + fY * fY)
.
@return straight-line distance to origin
*/
SkScalar distanceToOrigin() const { return this->length(); }
/** Set the point (vector) to be unit-length in the same direction as it
already points. If the point has a degenerate length (i.e. nearly 0)
then set it to (0,0) and return false; otherwise return true.
/** Scales (fX, fY) so that length() returns one, while preserving ratio of fX to fY,
if possible. If prior length is nearly zero, sets vector to (0, 0) and returns
false; otherwise returns true.
@return true if former length is not zero or nearly zero
*/
bool normalize();
/** Set the point (vector) to be unit-length in the same direction as the
x,y params. If the vector (x,y) has a degenerate length (i.e. nearly 0)
then set it to (0,0) and return false, otherwise return true.
/** Sets vector to (x, y) scaled so length() returns one, and so that
(fX, fY) is proportional to (x, y). If (x, y) length is nearly zero,
sets vector to (0, 0) and returns false; otherwise returns true.
@param x proportional value for fX
@param y proportional value for fY
@return true if (x, y) length is not zero or nearly zero
*/
bool setNormalize(SkScalar x, SkScalar y);
/** Scale the point (vector) to have the specified length, and return that
length. If the original length is degenerately small (nearly zero),
set it to (0,0) and return false, otherwise return true.
/** Scales vector so that distanceToOrigin() returns length, if possible. If former
length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
true.
@param length straight-line distance to origin
@return true if former length is not zero or nearly zero
*/
bool setLength(SkScalar length);
/** Set the point (vector) to have the specified length in the same
direction as (x,y). If the vector (x,y) has a degenerate length
(i.e. nearly 0) then set it to (0,0) and return false, otherwise return true.
/** Sets vector to (x, y) scaled to length, if possible. If former
length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
true.
@param x proportional value for fX
@param y proportional value for fY
@param length straight-line distance to origin
@return true if (x, y) length is not zero or nearly zero
*/
bool setLength(SkScalar x, SkScalar y, SkScalar length);
/** Scale the point's coordinates by scale, writing the answer into dst.
It is legal for dst == this.
/** Sets dst to SkPoint times scale. dst may be SkPoint to modify SkPoint in place.
@param scale factor to multiply SkPoint by
@param dst storage for scaled SkPoint
*/
void scale(SkScalar scale, SkPoint* dst) const;
/** Scale the point's coordinates by scale, writing the answer back into
the point.
/** Scales SkPoint in place by scale.
@param value factor to multiply SkPoint by
*/
void scale(SkScalar value) { this->scale(value, this); }
/** Negate the point's coordinates
/** Changes the sign of fX and fY.
*/
void negate() {
fX = -fX;
fY = -fY;
}
/** Returns a new point whose coordinates are the negative of the point's
/** Returns SkPoint changing the signs of fX and fY.
@return SkPoint as (-fX, -fY)
*/
SkPoint operator-() const {
return {-fX, -fY};
}
/** Add v's coordinates to the point's
/** Adds vector v to SkPoint. Sets SkPoint to: (fX + v.fX, fY + v.fY).
@param v vector to add
*/
void operator+=(const SkVector& v) {
fX += v.fX;
fY += v.fY;
}
/** Subtract v's coordinates from the point's
/** Subtracts vector v from SkPoint. Sets SkPoint to: (fX - v.fX, fY - v.fY).
@param v vector to subtract
*/
void operator-=(const SkVector& v) {
fX -= v.fX;
fY -= v.fY;
}
/** Returns SkPoint multiplied by scale.
@param scale scalar to multiply by
@return SkPoint as (fX * scale, fY * scale)
*/
SkPoint operator*(SkScalar scale) const {
return {fX * scale, fY * scale};
}
/** Multiplies SkPoint by scale. Sets SkPoint to: (fX * scale, fY * scale)
@param scale scalar to multiply by
@return reference to SkPoint
*/
SkPoint& operator*=(SkScalar scale) {
fX *= scale;
fY *= scale;
return *this;
}
/**
* Returns true if both X and Y are finite (not infinity or NaN)
*/
/** Returns true if both fX and fY are measurable values.
@return true for values other than infinities and NaN
*/
bool isFinite() const {
SkScalar accum = 0;
accum *= fX;
@ -260,71 +449,139 @@ struct SK_API SkPoint {
return !SkScalarIsNaN(accum);
}
/**
* Returns true if the point's coordinates equal (x,y)
*/
/** Returns true if SkPoint is equivalent to SkPoint constructed from (x, y).
@param x value compared with fX
@param y value compared with fY
@return true if SkPoint equals (x, y)
*/
bool equals(SkScalar x, SkScalar y) const {
return fX == x && fY == y;
}
/** Returns true if a is equivalent to b.
@param a SkPoint to compare
@param b SkPoint to compare
@return true if a.fX == b.fX and a.fY == b.fY
*/
friend bool operator==(const SkPoint& a, const SkPoint& b) {
return a.fX == b.fX && a.fY == b.fY;
}
/** Returns true if a is not equivalent to b.
@param a SkPoint to compare
@param b SkPoint to compare
@return true if a.fX != b.fX or a.fY != b.fY
*/
friend bool operator!=(const SkPoint& a, const SkPoint& b) {
return a.fX != b.fX || a.fY != b.fY;
}
/** Returns a new point whose coordinates are the difference between
a's and b's (a - b)
/** Returns vector from b to a, computed as (a.fX - b.fX, a.fY - b.fY).
Can also be used to subtract vector from SkPoint, returning SkPoint.
Can also be used to subtract vector from vector, returning vector.
@param a SkPoint to subtract from
@param b SkPoint to subtract
@return vector from b to a
*/
friend SkVector operator-(const SkPoint& a, const SkPoint& b) {
return {a.fX - b.fX, a.fY - b.fY};
}
/** Returns a new point whose coordinates are the sum of a's and b's (a + b)
/** Returns SkPoint resulting from SkPoint a offset by vector b, computed as: (a.fX + b.fX, a.fY + b.fY).
Can also be used to offset SkPoint b by vector a, returning SkPoint.
Can also be used to add vector to vector, returning vector.
@param a SkPoint or vector to add to
@param b SkPoint or vector to add
@return SkPoint equal to a offset by b
*/
friend SkPoint operator+(const SkPoint& a, const SkVector& b) {
return {a.fX + b.fX, a.fY + b.fY};
}
/** Returns the euclidian distance from (0,0) to (x,y)
/** Returns the Euclidean_Distance from origin, computed as:
sqrt(x * x + y * y)
.
@param x component of length
@param y component of length
@return straight-line distance to origin
*/
static SkScalar Length(SkScalar x, SkScalar y);
/** Normalize pt, returning its previous length. If the prev length is too
small (degenerate), set pt to (0,0) and return 0. This uses the same
tolerance as CanNormalize.
/** Scales (vec->fX, vec->fY) so that length() returns one, while preserving ratio of vec->fX to vec->fY,
if possible. If original length is nearly zero, sets vec to (0, 0) and returns zero;
otherwise, returns length of vec before vec is scaled.
Note that this method may be significantly more expensive than
the non-static normalize(), because it has to return the previous length
of the point. If you don't need the previous length, call the
non-static normalize() method instead.
*/
Returned prior length may be SK_ScalarInfinity if it can not be represented by SkScalar.
Note that normalize() is faster if prior length is not required.
@param vec normalized to unit length
@return original vec length
*/
static SkScalar Normalize(SkVector* vec);
/** Returns the euclidian distance between a and b
/** Returns the Euclidean_Distance between a and b.
@param a line end point
@param b line end point
@return straight-line distance from a to b
*/
static SkScalar Distance(const SkPoint& a, const SkPoint& b) {
return Length(a.fX - b.fX, a.fY - b.fY);
}
/** Returns the dot product of a and b, treating them as 2D vectors
/** Returns the dot product of vector a and vector b.
@param a left side of dot product
@param b right side of dot product
@return product of input magnitudes and cosine of the angle between them
*/
static SkScalar DotProduct(const SkVector& a, const SkVector& b) {
return a.fX * b.fX + a.fY * b.fY;
}
/** Returns the cross product of a and b, treating them as 2D vectors
/** Returns the cross product of vector a and vector b.
a and b form three-dimensional vectors with z equal to zero. The cross product
is a three-dimensional vector with x and y equal to zero. The cross product z
term equals the returned value.
@param a left side of cross product
@param b right side of cross product
@return area spanned by vectors signed by angle direction
*/
static SkScalar CrossProduct(const SkVector& a, const SkVector& b) {
return a.fX * b.fY - a.fY * b.fX;
}
/** Returns the cross product of vector and vec.
Vector and vec form three-dimensional vectors with z equal to zero. The
cross product is a three-dimensional vector with x and y equal to zero.
The cross product z term equals the returned value.
@param vec right side of cross product
@return area spanned by vectors signed by angle direction
*/
SkScalar cross(const SkVector& vec) const {
return CrossProduct(*this, vec);
}
/** Returns the dot product of vector and vector vec.
@param vec right side of dot product
@return product of input magnitudes and cosine of the angle between them
*/
SkScalar dot(const SkVector& vec) const {
return DotProduct(*this, vec);
}