this->getMapXYProc()(*this, x, y, result);
}
+ SkPoint mapXY(SkScalar x, SkScalar y) const {
+ SkPoint result;
+ this->getMapXYProc()(*this, x, y, &result);
+ return result;
+ }
+
/** Apply this matrix to the array of vectors specified by src, and write
the transformed vectors into the array of vectors specified by dst.
This is similar to mapPoints, but ignores any translation in the matrix.
this->mapVectors(vecs, vecs, count);
}
+ void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
+ SkVector vec = { dx, dy };
+ this->mapVectors(result, &vec, 1);
+ }
+
+ SkVector mapVector(SkScalar dx, SkScalar dy) const {
+ SkVector vec = { dx, dy };
+ this->mapVectors(&vec, &vec, 1);
+ return vec;
+ }
+
/** Apply this matrix to the src rectangle, and write the transformed
rectangle into dst. This is accomplished by transforming the 4 corners
of src, and then setting dst to the bounds of those points.
/**
* Return a new IRect, built as an offset of this rect.
*/
- SkIRect makeOffset(int dx, int dy) const {
+ SkIRect makeOffset(int32_t dx, int32_t dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
}
/**
* Return a new IRect, built as an inset of this rect.
*/
- SkIRect makeInset(int dx, int dy) const {
+ SkIRect makeInset(int32_t dx, int32_t dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
}
+ /**
+ * Return a new Rect, built as an outset of this rect.
+ */
+ SkIRect makeOutset(int32_t dx, int32_t dy) const {
+ return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
SkRect makeOffset(SkScalar dx, SkScalar dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
}
-
+
/**
* Return a new Rect, built as an inset of this rect.
*/
return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
}
+ /**
+ * Return a new Rect, built as an outset of this rect.
+ */
+ SkRect makeOutset(SkScalar dx, SkScalar dy) const {
+ return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
SkASSERT(texture);
SkMatrix mat;
- mat.setIDiv(texture->width(), texture->height());
+ (void)mat.setIDiv(texture->width(), texture->height());
return mat;
}
}
// init our bounds from the path
- {
- SkRect pathBounds = devPath.getBounds();
- pathBounds.inset(-SK_ScalarHalf, -SK_ScalarHalf);
- pathBounds.roundOut(bounds);
- }
+ *bounds = devPath.getBounds().makeOutset(SK_ScalarHalf, SK_ScalarHalf).roundOut();
SkIPoint margin = SkIPoint::Make(0, 0);
if (filter) {
// (possibly) trim the bounds to reflect the clip
// (plus whatever slop the filter needs)
if (clipBounds) {
- SkIRect tmp = *clipBounds;
// Ugh. Guard against gigantic margins from wacky filters. Without this
// check we can request arbitrary amounts of slop beyond our visible
// clip, and bring down the renderer (at least on finite RAM machines
// quality of large filters like blurs, and the corresponding memory
// requests.
static const int MAX_MARGIN = 128;
- tmp.inset(-SkMin32(margin.fX, MAX_MARGIN),
- -SkMin32(margin.fY, MAX_MARGIN));
- if (!bounds->intersect(tmp)) {
+ if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MARGIN),
+ SkMin32(margin.fY, MAX_MARGIN)))) {
return false;
}
}
///////////////////////////////////////////////////////////////////////////////
void SkRRect::inset(SkScalar dx, SkScalar dy, SkRRect* dst) const {
- SkRect r = fRect;
+ const SkRect r = fRect.makeInset(dx, dy);
- r.inset(dx, dy);
if (r.isEmpty()) {
dst->setEmpty();
return;
if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
return false;
}
- storage = *clipBounds;
- storage.inset(-margin.fX, -margin.fY);
+ storage = clipBounds->makeOutset(margin.fX, margin.fY);
clipBounds = &storage;
}
since the 1/2 pixel boundary is important to the antihair blitter,
we don't want to risk numerical fate by chopping on that edge.
*/
- clipBounds.inset(-SK_Scalar1, -SK_Scalar1);
+ clipBounds.outset(SK_Scalar1, SK_Scalar1);
if (!SkLineClipper::IntersectLine(pts, clipBounds, pts)) {
return;
const SkRegion* clip = NULL;
{
- SkIRect ibounds;
- path.getBounds().roundOut(&ibounds);
- ibounds.inset(-1, -1);
+ const SkIRect ibounds = path.getBounds().roundOut().makeOutset(1, 1);
if (rclip.quickReject(ibounds)) {
return;
SkRect r;
r.set(p0.fX, p0.fY, p1.fX, p1.fY);
r.sort();
- r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
+ r.outset(SK_ScalarHalf, SK_ScalarHalf);
SkAAClipBlitterWrapper wrap;
if (!clip.quickContains(r.roundOut())) {
} else {
const SkRegion* clipRgn = NULL;
SkRect r;
- SkIRect ir;
r.set(p0.fX, p0.fY, p1.fX, p1.fY);
r.sort();
- r.roundOut(&ir);
- ir.inset(-1, -1);
SkAAClipBlitterWrapper wrap;
- if (!clip.quickContains(ir)) {
+ if (!clip.quickContains(r.roundOut().makeOutset(1, 1))) {
wrap.init(clip, blitter);
blitter = wrap.getBlitter();
clipRgn = &wrap.getRgn();
SkScalar baseFrequencyX, SkScalar baseFrequencyY,
const SkMatrix& matrix)
{
- SkVector wavelength = SkVector::Make(SkScalarInvert(baseFrequencyX),
- SkScalarInvert(baseFrequencyY));
- matrix.mapVectors(&wavelength, 1);
- fBaseFrequency.fX = SkScalarInvert(wavelength.fX);
- fBaseFrequency.fY = SkScalarInvert(wavelength.fY);
- SkVector sizeVec = SkVector::Make(SkIntToScalar(tileSize.fWidth),
- SkIntToScalar(tileSize.fHeight));
- matrix.mapVectors(&sizeVec, 1);
- fTileSize.fWidth = SkScalarRoundToInt(sizeVec.fX);
- fTileSize.fHeight = SkScalarRoundToInt(sizeVec.fY);
+ SkVector vec[2] = {
+ { SkScalarInvert(baseFrequencyX), SkScalarInvert(baseFrequencyY) },
+ { SkIntToScalar(tileSize.fWidth), SkIntToScalar(tileSize.fHeight) },
+ };
+ matrix.mapVectors(vec, 2);
+
+ fBaseFrequency.set(SkScalarInvert(vec[0].fX), SkScalarInvert(vec[0].fY));
+ fTileSize.set(SkScalarRoundToInt(vec[1].fX), SkScalarRoundToInt(vec[1].fY));
this->init(seed);
if (!fTileSize.isEmpty()) {
this->stitch();
void generateAdvance(SkGlyph* glyph) SK_OVERRIDE {
fFace->getAdvance(glyph);
- SkVector advance;
- fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX),
- SkFixedToScalar(glyph->fAdvanceY), &advance);
+ const SkVector advance = fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX),
+ SkFixedToScalar(glyph->fAdvanceY));
glyph->fAdvanceX = SkScalarToFixed(advance.fX);
glyph->fAdvanceY = SkScalarToFixed(advance.fY);
}
void generateMetrics(SkGlyph* glyph) SK_OVERRIDE {
fFace->getMetrics(glyph);
- SkVector advance;
- fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX),
- SkFixedToScalar(glyph->fAdvanceY), &advance);
+ const SkVector advance = fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX),
+ SkFixedToScalar(glyph->fAdvanceY));
glyph->fAdvanceX = SkScalarToFixed(advance.fX);
glyph->fAdvanceY = SkScalarToFixed(advance.fY);