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

Side by Side Diff: src/core/SkBitmapProcState.h

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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkBitmapProcState_DEFINED 8 #ifndef SkBitmapProcState_DEFINED
9 #define SkBitmapProcState_DEFINED 9 #define SkBitmapProcState_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkBitmapController.h" 12 #include "SkBitmapController.h"
13 #include "SkBitmapFilter.h" 13 #include "SkBitmapFilter.h"
14 #include "SkBitmapProvider.h" 14 #include "SkBitmapProvider.h"
15 #include "SkFloatBits.h" 15 #include "SkFloatBits.h"
16 #include "SkMatrix.h" 16 #include "SkMatrix.h"
17 #include "SkMipMap.h" 17 #include "SkMipMap.h"
18 #include "SkPaint.h" 18 #include "SkPaint.h"
19 #include "SkShader.h" 19 #include "SkShader.h"
20 #include "SkTemplates.h" 20 #include "SkTemplates.h"
21 21
22 typedef SkFixed3232 SkFractionalInt; 22 typedef SkFixed3232 SkFractionalInt;
23 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) 23 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x)
24 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) 24 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x)
25 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) 25 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x)
26 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) 26 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x)
27 27
28 // Applying a fixed point (SkFixed, SkFractionalInt) epsilon bias ensures that t he inverse-mapped
29 // bitmap coordinates are rounded consistently WRT geometry. Note that we only have to do this
30 // when the scale is positive - for negative scales we're already rounding in th e right direction.
31 static inline int bitmap_sampler_inv_bias(SkScalar scale) {
32 #ifndef SK_SUPPORT_LEGACY_BITMAP_SAMPLER_BIAS
33 return -(scale > 0);
34 #else
35 return 0;
36 #endif
37 }
38
39 class SkPaint; 28 class SkPaint;
40 29
41 struct SkBitmapProcState { 30 struct SkBitmapProcState {
42 SkBitmapProcState(const SkBitmapProvider&, SkShader::TileMode tmx, SkShader: :TileMode tmy); 31 SkBitmapProcState(const SkBitmapProvider&, SkShader::TileMode tmx, SkShader: :TileMode tmy);
43 SkBitmapProcState(const SkBitmap&, SkShader::TileMode tmx, SkShader::TileMod e tmy); 32 SkBitmapProcState(const SkBitmap&, SkShader::TileMode tmx, SkShader::TileMod e tmy);
44 ~SkBitmapProcState(); 33 ~SkBitmapProcState();
45 34
46 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, 35 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y,
47 SkPMColor[], int count); 36 SkPMColor[], int count);
48 37
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 FixedTileProc fTileProcY; // chooseProcs 69 FixedTileProc fTileProcY; // chooseProcs
81 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs 70 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs
82 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs 71 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs
83 IntTileProc fIntTileProcY; // chooseProcs 72 IntTileProc fIntTileProcY; // chooseProcs
84 SkFixed fFilterOneX; 73 SkFixed fFilterOneX;
85 SkFixed fFilterOneY; 74 SkFixed fFilterOneY;
86 75
87 SkPMColor fPaintPMColor; // chooseProcs - A8 config 76 SkPMColor fPaintPMColor; // chooseProcs - A8 config
88 SkFixed fInvSx; // chooseProcs 77 SkFixed fInvSx; // chooseProcs
89 SkFixed fInvKy; // chooseProcs 78 SkFixed fInvKy; // chooseProcs
79
80 // Epsilon bias to ensure inverse-mapped bitmap coordinates are rounded cons istently WRT
81 // geometry. These are treated as SkFixed, but we only store the fractional part.
reed1 2015/12/16 16:25:03 We just need 0 or 1 for each, right? why using int
f(malita) 2015/12/16 16:45:55 The current impl also expects an explicit sign. W
82 int16_t fInvBiasX; // chooseProcs
83 int16_t fInvBiasY; // chooseProcs
84
90 uint16_t fAlphaScale; // chooseProcs 85 uint16_t fAlphaScale; // chooseProcs
91 uint8_t fInvType; // chooseProcs 86 uint8_t fInvType; // chooseProcs
92 uint8_t fTileModeX; // CONSTRUCTOR 87 uint8_t fTileModeX; // CONSTRUCTOR
93 uint8_t fTileModeY; // CONSTRUCTOR 88 uint8_t fTileModeY; // CONSTRUCTOR
94 uint8_t fFilterLevel; // chooseProcs 89 uint8_t fFilterLevel; // chooseProcs
95 90
96 /** Platforms implement this, and can optionally overwrite only the 91 /** Platforms implement this, and can optionally overwrite only the
97 following fields: 92 following fields:
98 93
99 fShaderProc32 94 fShaderProc32
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, 201 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s,
207 uint32_t xy[], int count, int x, int y); 202 uint32_t xy[], int count, int x, int y);
208 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, 203 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
209 uint32_t xy[], int count, int x, int y); 204 uint32_t xy[], int count, int x, int y);
210 void S32_D16_filter_DX(const SkBitmapProcState& s, 205 void S32_D16_filter_DX(const SkBitmapProcState& s,
211 const uint32_t* xy, int count, uint16_t* colors); 206 const uint32_t* xy, int count, uint16_t* colors);
212 void S32_D16_filter_DXDY(const SkBitmapProcState& s, 207 void S32_D16_filter_DXDY(const SkBitmapProcState& s,
213 const uint32_t* xy, int count, uint16_t* colors); 208 const uint32_t* xy, int count, uint16_t* colors);
214 209
215 #endif 210 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698