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

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

Issue 1815373002: Document BitmapStateAutoMapper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void ClampX_ClampY_filter_scale(const SkBitmapProcState& s, uint32_t xy[], 193 void ClampX_ClampY_filter_scale(const SkBitmapProcState& s, uint32_t xy[],
194 int count, int x, int y); 194 int count, int x, int y);
195 void ClampX_ClampY_nofilter_scale(const SkBitmapProcState& s, uint32_t xy[], 195 void ClampX_ClampY_nofilter_scale(const SkBitmapProcState& s, uint32_t xy[],
196 int count, int x, int y); 196 int count, int x, int y);
197 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, 197 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s,
198 uint32_t xy[], int count, int x, int y); 198 uint32_t xy[], int count, int x, int y);
199 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, 199 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
200 uint32_t xy[], int count, int x, int y); 200 uint32_t xy[], int count, int x, int y);
201 201
202 // Helper class for mapping the middle of pixel (x, y) into SkFractionalInt bitm ap space. 202 // Helper class for mapping the middle of pixel (x, y) into SkFractionalInt bitm ap space.
203 // Discussion:
204 // Overall, this code takes a point in destination space, and uses the center of the pixel
205 // at (x, y) to determine the sample point in source space. It then adjusts the pixel by different
206 // amounts based in filtering and tiling.
207 // This code can be broken into two main cases based on filtering:
208 // * no filtering (nearest neighbor) - when using nearest neighbor filtering all tile modes reduce
209 // the sampled by one ulp. If a simple point pt lies precisely on XXX.1/2 then i t forced down
210 // when positive making 1/2 + 1/2 = .999999 instead of 1.0.
211 // * filtering - in the filtering case, the code calculates the -1/2 shift for s tarting the
212 // bilerp kernel. There is a twist; there is a big difference between clamp and the other tile
213 // modes. In tile and repeat the matrix has been reduced by an additional 1/widt h and 1/height
214 // factor. This maps from destination space to [0, 1) (instead of source space) to allow easy
215 // modulo arithmetic. This means that the -1/2 needed by bilerp is actually 1/2 * 1/width for x
216 // and 1/2 * 1/height for y. This is what happens when the poorly named fFilterO ne{X|Y} is
217 // divided by two.
203 class SkBitmapProcStateAutoMapper { 218 class SkBitmapProcStateAutoMapper {
204 public: 219 public:
205 SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y, 220 SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y,
206 SkPoint* scalarPoint = nullptr) { 221 SkPoint* scalarPoint = nullptr) {
207 SkPoint pt; 222 SkPoint pt;
208 s.fInvProc(s.fInvMatrix, 223 s.fInvProc(s.fInvMatrix,
209 SkIntToScalar(x) + SK_ScalarHalf, 224 SkIntToScalar(x) + SK_ScalarHalf,
210 SkIntToScalar(y) + SK_ScalarHalf, &pt); 225 SkIntToScalar(y) + SK_ScalarHalf, &pt);
211 226
212 SkFixed biasX, biasY; 227 SkFixed biasX, biasY;
(...skipping 25 matching lines...) Expand all
238 SkFixed fixedY() const { return SkFractionalIntToFixed(fY); } 253 SkFixed fixedY() const { return SkFractionalIntToFixed(fY); }
239 254
240 int intX() const { return SkFractionalIntToInt(fX); } 255 int intX() const { return SkFractionalIntToInt(fX); }
241 int intY() const { return SkFractionalIntToInt(fY); } 256 int intY() const { return SkFractionalIntToInt(fY); }
242 257
243 private: 258 private:
244 SkFractionalInt fX, fY; 259 SkFractionalInt fX, fY;
245 }; 260 };
246 261
247 #endif 262 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698