Remove SkBitmapProcStateAutoMapper's overflow check
(follow-up to https://codereview.chromium.org/1642273002) Add an optional SkPoint outparam, and relocate the overflow check to the only client which needs it. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1650403002 Review URL: https://codereview.chromium.org/1650403002
This commit is contained in:
parent
395eabeb0e
commit
8a8eb5242b
@ -586,29 +586,28 @@ static void DoNothing_shaderproc(const void*, int x, int y,
|
||||
}
|
||||
|
||||
bool SkBitmapProcState::setupForTranslate() {
|
||||
#ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
|
||||
SkPoint pt;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
|
||||
fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt);
|
||||
|
||||
const SkScalar too_big = SkIntToScalar(1 << 30);
|
||||
if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fFilterOneX = SkScalarFloorToInt(pt.fX);
|
||||
fFilterOneY = SkScalarFloorToInt(pt.fY);
|
||||
#else
|
||||
SkBitmapProcStateAutoMapper mapper(*this, 0, 0);
|
||||
const SkBitmapProcStateAutoMapper mapper(*this, 0, 0, &pt);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* if the translate is larger than our ints, we can get random results, or
|
||||
* worse, we might get 0x80000000, which wreaks havoc on us, since we can't
|
||||
* negate it.
|
||||
*/
|
||||
if (mapper.isOverflow()) {
|
||||
const SkScalar too_big = SkIntToScalar(1 << 30);
|
||||
if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
|
||||
fFilterOneX = SkScalarFloorToInt(pt.fX);
|
||||
fFilterOneY = SkScalarFloorToInt(pt.fY);
|
||||
#else
|
||||
// Since we know we're not filtered, we re-purpose these fields allow
|
||||
// us to go from device -> src coordinates w/ just an integer add,
|
||||
// rather than running through the inverse-matrix
|
||||
|
@ -192,7 +192,8 @@ void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
|
||||
// TODO: filtered version which applies a fFilterOne{X,Y}/2 bias instead of epsilon?
|
||||
class SkBitmapProcStateAutoMapper {
|
||||
public:
|
||||
SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y) {
|
||||
SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y,
|
||||
SkPoint* scalarPoint = nullptr) {
|
||||
SkPoint pt;
|
||||
s.fInvProc(s.fInvMatrix,
|
||||
SkIntToScalar(x) + SK_ScalarHalf,
|
||||
@ -207,26 +208,17 @@ public:
|
||||
fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX);
|
||||
fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY);
|
||||
|
||||
/*
|
||||
* (see SkBitmapProcState::setupForTranslate, which is the only user of this flag)
|
||||
*
|
||||
* if the translate is larger than our ints, we can get random results, or
|
||||
* worse, we might get 0x80000000, which wreaks havoc on us, since we can't
|
||||
* negate it.
|
||||
*/
|
||||
const SkScalar too_big = SkIntToScalar(1 << 30);
|
||||
fOverflow = SkScalarAbs(pt.x() - SkFixedToScalar(biasX)) > too_big
|
||||
|| SkScalarAbs(pt.y() - SkFixedToScalar(biasY)) > too_big;
|
||||
if (scalarPoint) {
|
||||
scalarPoint->set(pt.x() - SkFixedToScalar(biasX),
|
||||
pt.y() - SkFixedToScalar(biasY));
|
||||
}
|
||||
}
|
||||
|
||||
SkFractionalInt x() const { return fX; }
|
||||
SkFractionalInt y() const { return fY; }
|
||||
|
||||
bool isOverflow() const { return fOverflow; }
|
||||
|
||||
private:
|
||||
SkFractionalInt fX, fY;
|
||||
bool fOverflow;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user