Sanitizing source files in Skia_Periodic_House_Keeping
git-svn-id: http://skia.googlecode.com/svn/trunk@6982 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7d474f8a84
commit
422188f3c6
@ -165,7 +165,7 @@ public:
|
||||
const SkPoint pos[], const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY,
|
||||
const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
|
||||
|
@ -1812,41 +1812,41 @@ bool SkTreatAsSprite(const SkMatrix& mat, const SkRect& src,
|
||||
if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// quick success check
|
||||
if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// mapRect supports negative scales, so we eliminate those first
|
||||
if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SkRect dst;
|
||||
SkIRect isrc, idst;
|
||||
|
||||
|
||||
mat.mapRect(&dst, src);
|
||||
|
||||
|
||||
{
|
||||
SkRect tmp = src;
|
||||
tmp.offset(mat.getTranslateX(), mat.getTranslateY());
|
||||
tmp.round(&isrc);
|
||||
}
|
||||
|
||||
|
||||
if (subpixelBits) {
|
||||
isrc.fLeft <<= subpixelBits;
|
||||
isrc.fTop <<= subpixelBits;
|
||||
isrc.fRight <<= subpixelBits;
|
||||
isrc.fBottom <<= subpixelBits;
|
||||
|
||||
|
||||
const float scale = 1 << subpixelBits;
|
||||
dst.fLeft *= scale;
|
||||
dst.fTop *= scale;
|
||||
dst.fRight *= scale;
|
||||
dst.fBottom *= scale;
|
||||
}
|
||||
|
||||
|
||||
dst.round(&idst);
|
||||
return isrc == idst;
|
||||
}
|
||||
|
@ -27,6 +27,6 @@
|
||||
* of subpixel-bits to simulate filtering.
|
||||
*/
|
||||
bool SkTreatAsSprite(const SkMatrix&, const SkRect& src, unsigned subpixelBits);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
|
||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// assert: rotate/perspect is never treated as sprite
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask);
|
||||
@ -74,19 +74,19 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
|
||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits));
|
||||
mat.setTranslate(0, tinySubPixel);
|
||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits));
|
||||
|
||||
|
||||
const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
|
||||
const SkScalar bigScale = SkScalarDiv(r.width() + twoThirds, r.width());
|
||||
mat.setScale(bigScale, bigScale);
|
||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, false));
|
||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
||||
|
||||
|
||||
const SkScalar oneThird = SK_Scalar1 / 3;
|
||||
const SkScalar smallScale = SkScalarDiv(r.width() + oneThird, r.width());
|
||||
mat.setScale(smallScale, smallScale);
|
||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, false));
|
||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
||||
|
||||
|
||||
const SkScalar oneFortyth = SK_Scalar1 / 40;
|
||||
const SkScalar tinyScale = SkScalarDiv(r.width() + oneFortyth, r.width());
|
||||
mat.setScale(tinyScale, tinyScale);
|
||||
|
Loading…
Reference in New Issue
Block a user