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;
|
const SkPoint pos[], const SkPaint&) SK_OVERRIDE;
|
||||||
|
|
||||||
virtual void drawPosTextH(const void* text, size_t byteLength,
|
virtual void drawPosTextH(const void* text, size_t byteLength,
|
||||||
const SkScalar xpos[], SkScalar constY,
|
const SkScalar xpos[], SkScalar constY,
|
||||||
const SkPaint&) SK_OVERRIDE;
|
const SkPaint&) SK_OVERRIDE;
|
||||||
|
|
||||||
virtual void drawRect(const SkRect& rect, 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)) {
|
if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// quick success check
|
// quick success check
|
||||||
if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) {
|
if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mapRect supports negative scales, so we eliminate those first
|
// mapRect supports negative scales, so we eliminate those first
|
||||||
if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
|
if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkRect dst;
|
SkRect dst;
|
||||||
SkIRect isrc, idst;
|
SkIRect isrc, idst;
|
||||||
|
|
||||||
mat.mapRect(&dst, src);
|
mat.mapRect(&dst, src);
|
||||||
|
|
||||||
{
|
{
|
||||||
SkRect tmp = src;
|
SkRect tmp = src;
|
||||||
tmp.offset(mat.getTranslateX(), mat.getTranslateY());
|
tmp.offset(mat.getTranslateX(), mat.getTranslateY());
|
||||||
tmp.round(&isrc);
|
tmp.round(&isrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subpixelBits) {
|
if (subpixelBits) {
|
||||||
isrc.fLeft <<= subpixelBits;
|
isrc.fLeft <<= subpixelBits;
|
||||||
isrc.fTop <<= subpixelBits;
|
isrc.fTop <<= subpixelBits;
|
||||||
isrc.fRight <<= subpixelBits;
|
isrc.fRight <<= subpixelBits;
|
||||||
isrc.fBottom <<= subpixelBits;
|
isrc.fBottom <<= subpixelBits;
|
||||||
|
|
||||||
const float scale = 1 << subpixelBits;
|
const float scale = 1 << subpixelBits;
|
||||||
dst.fLeft *= scale;
|
dst.fLeft *= scale;
|
||||||
dst.fTop *= scale;
|
dst.fTop *= scale;
|
||||||
dst.fRight *= scale;
|
dst.fRight *= scale;
|
||||||
dst.fBottom *= scale;
|
dst.fBottom *= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.round(&idst);
|
dst.round(&idst);
|
||||||
return isrc == idst;
|
return isrc == idst;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,6 @@
|
|||||||
* of subpixel-bits to simulate filtering.
|
* of subpixel-bits to simulate filtering.
|
||||||
*/
|
*/
|
||||||
bool SkTreatAsSprite(const SkMatrix&, const SkRect& src, unsigned subpixelBits);
|
bool SkTreatAsSprite(const SkMatrix&, const SkRect& src, unsigned subpixelBits);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +50,7 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
|
|||||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, 0));
|
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assert: rotate/perspect is never treated as sprite
|
// assert: rotate/perspect is never treated as sprite
|
||||||
for (int i = 0; i < 1000; ++i) {
|
for (int i = 0; i < 1000; ++i) {
|
||||||
rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask);
|
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));
|
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits));
|
||||||
mat.setTranslate(0, tinySubPixel);
|
mat.setTranslate(0, tinySubPixel);
|
||||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits));
|
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits));
|
||||||
|
|
||||||
const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
|
const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
|
||||||
const SkScalar bigScale = SkScalarDiv(r.width() + twoThirds, r.width());
|
const SkScalar bigScale = SkScalarDiv(r.width() + twoThirds, r.width());
|
||||||
mat.setScale(bigScale, bigScale);
|
mat.setScale(bigScale, bigScale);
|
||||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, false));
|
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, false));
|
||||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
||||||
|
|
||||||
const SkScalar oneThird = SK_Scalar1 / 3;
|
const SkScalar oneThird = SK_Scalar1 / 3;
|
||||||
const SkScalar smallScale = SkScalarDiv(r.width() + oneThird, r.width());
|
const SkScalar smallScale = SkScalarDiv(r.width() + oneThird, r.width());
|
||||||
mat.setScale(smallScale, smallScale);
|
mat.setScale(smallScale, smallScale);
|
||||||
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, false));
|
REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, false));
|
||||||
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits));
|
||||||
|
|
||||||
const SkScalar oneFortyth = SK_Scalar1 / 40;
|
const SkScalar oneFortyth = SK_Scalar1 / 40;
|
||||||
const SkScalar tinyScale = SkScalarDiv(r.width() + oneFortyth, r.width());
|
const SkScalar tinyScale = SkScalarDiv(r.width() + oneFortyth, r.width());
|
||||||
mat.setScale(tinyScale, tinyScale);
|
mat.setScale(tinyScale, tinyScale);
|
||||||
|
Loading…
Reference in New Issue
Block a user