зеркало из https://github.com/mozilla/moz-skia.git
Initialize bounds even if the text length is zero.
Review URL: https://codereview.chromium.org/12387092 git-svn-id: http://skia.googlecode.com/svn/trunk@7964 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
d66045ec7d
Коммит
46348e2173
|
@ -1071,6 +1071,9 @@ SkScalar SkPaint::measureText(const void* textData, size_t length,
|
|||
bounds->fBottom = SkScalarMul(bounds->fBottom, scale);
|
||||
}
|
||||
}
|
||||
} else if (bounds) {
|
||||
// ensure that even if we don't measure_text we still update the bounds
|
||||
bounds->setEmpty();
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
|
|
@ -97,12 +97,27 @@ static void regression_cubic(skiatest::Reporter* reporter) {
|
|||
REPORTER_ASSERT(reporter, maxR.contains(strokeR));
|
||||
}
|
||||
|
||||
// found and fixed for android: not initializing rect for string's of length 0
|
||||
static void regression_measureText(skiatest::Reporter* reporter) {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setTextSize(SkFloatToScalar(12.0f));
|
||||
|
||||
SkRect r;
|
||||
r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN);
|
||||
|
||||
// test that the rect was reset
|
||||
paint.measureText("", 0, &r, SkFloatToScalar(1.0f));
|
||||
REPORTER_ASSERT(reporter, r.isEmpty());
|
||||
}
|
||||
|
||||
static void TestPaint(skiatest::Reporter* reporter) {
|
||||
// TODO add general paint tests
|
||||
test_copy(reporter);
|
||||
|
||||
// regression tests
|
||||
regression_cubic(reporter);
|
||||
regression_measureText(reporter);
|
||||
}
|
||||
|
||||
#include "TestClassDef.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче