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

Unified Diff: src/core/SkBitmapProcState.h

Issue 1661613002: Use SkBitmapProcStateAutoMapper for filter samplers also (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « no previous file | src/core/SkBitmapProcState_matrix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.h
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 0ae8cf285670bc8a5b187f57012f0d0ccbf0cadc..fca7dc0a3edfa42d512776465eba2dc7e1b34f1d 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -189,7 +189,6 @@ void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
uint32_t xy[], int count, int x, int y);
// Helper class for mapping the middle of pixel (x, y) into SkFractionalInt bitmap space.
-// 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,
@@ -199,12 +198,19 @@ public:
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
- // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are rounded
- // consistently WRT geometry. Note that we only need the bias for positive scales:
- // for negative scales, the rounding is intrinsically correct.
- // We scale it to persist SkFractionalInt -> SkFixed conversions.
- const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0);
- const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0);
+ SkFixed biasX, biasY;
+ if (s.fFilterLevel == kNone_SkFilterQuality) {
+ // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are rounded
+ // consistently WRT geometry. Note that we only need the bias for positive scales:
+ // for negative scales, the rounding is intrinsically correct.
+ // We scale it to persist SkFractionalInt -> SkFixed conversions.
+ biasX = (s.fInvMatrix.getScaleX() > 0);
+ biasY = (s.fInvMatrix.getScaleY() > 0);
+ } else {
+ biasX = s.fFilterOneX >> 1;
+ biasY = s.fFilterOneY >> 1;
+ }
+
fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX);
fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY);
« no previous file with comments | « no previous file | src/core/SkBitmapProcState_matrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698