Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 1529833003: Repeating SkBitmapProcState rounding bias (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 487bd80402609f454b894e5e124eb5d8eb20c9eb..b08db53ffa2f582a89587bea5dc2475e410cd685 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -195,6 +195,15 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
fSampleProc32 = nullptr;
fSampleProc16 = nullptr;
+#ifndef SK_SUPPORT_LEGACY_BITMAP_SAMPLER_BIAS
+ // We only need a bias when the scale is positive: for negative scales
+ // we're rounding in the right direction intrinsically.
+ fInvBiasX = -(fInvMatrix.getScaleX() > 0);
+ fInvBiasY = -(fInvMatrix.getScaleY() > 0);
+#else
+ fInvBiasX = fInvBiasY = 0;
+#endif
+
// recompute the triviality of the matrix here because we may have
// changed it!
@@ -823,12 +832,10 @@ void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
SkPoint pt;
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf,
&pt);
- fx = SkScalarToFractionalInt(pt.fY)
- + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY());
+ fx = SkScalarToFractionalInt(pt.fY) + SkFixedToFractionalInt(s.fInvBiasY);
const unsigned maxY = s.fPixmap.height() - 1;
dstY = SkClampMax(SkFractionalIntToInt(fx), maxY);
- fx = SkScalarToFractionalInt(pt.fX)
- + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX());
+ fx = SkScalarToFractionalInt(pt.fX) + SkFixedToFractionalInt(s.fInvBiasX);
}
const SkPMColor* SK_RESTRICT src = s.fPixmap.addr32(0, dstY);

Powered by Google App Engine
This is Rietveld 408576698