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

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

Issue 2134893002: Redo Tiling (Closed) Base URL: https://skia.googlesource.com/skia.git@reduce-LBP-sample
Patch Set: Document bug. Created 4 years, 5 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 | « src/core/SkLinearBitmapPipeline.cpp ('k') | src/core/SkLinearBitmapPipeline_sample.h » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 SkLinearBitmapPipeline_core_DEFINED 8 #ifndef SkLinearBitmapPipeline_core_DEFINED
9 #define SkLinearBitmapPipeline_core_DEFINED 9 #define SkLinearBitmapPipeline_core_DEFINED
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 while (count >= 4) { 172 while (count >= 4) {
173 stage->pointList4(xs, ys); 173 stage->pointList4(xs, ys);
174 xs = xs + fourDx; 174 xs = xs + fourDx;
175 count -= 4; 175 count -= 4;
176 } 176 }
177 if (count > 0) { 177 if (count > 0) {
178 stage->pointListFew(count, xs, ys); 178 stage->pointListFew(count, xs, ys);
179 } 179 }
180 } 180 }
181
182 inline Sk4f SK_VECTORCALL check_pixel(const Sk4f& pixel) {
183 SkASSERTF(0.0f <= pixel[0] && pixel[0] <= 1.0f, "pixel[0]: %f", pixel[0]);
184 SkASSERTF(0.0f <= pixel[1] && pixel[1] <= 1.0f, "pixel[1]: %f", pixel[1]);
185 SkASSERTF(0.0f <= pixel[2] && pixel[2] <= 1.0f, "pixel[2]: %f", pixel[2]);
186 SkASSERTF(0.0f <= pixel[3] && pixel[3] <= 1.0f, "pixel[3]: %f", pixel[3]);
187 return pixel;
188 }
189
181 } // namespace 190 } // namespace
182 191
183 class SkLinearBitmapPipeline::PointProcessorInterface { 192 class SkLinearBitmapPipeline::PointProcessorInterface {
184 public: 193 public:
185 virtual ~PointProcessorInterface() { } 194 virtual ~PointProcessorInterface() { }
186 // Take the first n (where 0 < n && n < 4) items from xs and ys and sample t hose points. For 195 // Take the first n (where 0 < n && n < 4) items from xs and ys and sample t hose points. For
187 // nearest neighbor, that means just taking the floor xs and ys. For bilerp, this means 196 // nearest neighbor, that means just taking the floor xs and ys. For bilerp, this means
188 // to expand the bilerp filter around the point and sample using that filter . 197 // to expand the bilerp filter around the point and sample using that filter .
189 virtual void SK_VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0; 198 virtual void SK_VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0;
190 // Same as pointListFew, but n = 4. 199 // Same as pointListFew, but n = 4.
191 virtual void SK_VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0; 200 virtual void SK_VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0;
192 // A span is a compact form of sample points that are obtained by mapping po ints from 201 // A span is a compact form of sample points that are obtained by mapping po ints from
193 // destination space to source space. This is used for horizontal lines only , and is mainly 202 // destination space to source space. This is used for horizontal lines only , and is mainly
194 // used to take advantage of memory coherence for horizontal spans. 203 // used to take advantage of memory coherence for horizontal spans.
195 virtual void pointSpan(Span span) = 0; 204 virtual void pointSpan(Span span) = 0;
196 }; 205 };
197 206
198 class SkLinearBitmapPipeline::SampleProcessorInterface 207 class SkLinearBitmapPipeline::SampleProcessorInterface
199 : public SkLinearBitmapPipeline::PointProcessorInterface { 208 : public SkLinearBitmapPipeline::PointProcessorInterface {
200 public: 209 public:
201 // Used for nearest neighbor when scale factor is 1.0. The span can just be repeated with no 210 // Used for nearest neighbor when scale factor is 1.0. The span can just be repeated with no
202 // edge pixel alignment problems. This is for handling a very common case. 211 // edge pixel alignment problems. This is for handling a very common case.
203 virtual void repeatSpan(Span span, int32_t repeatCount) = 0; 212 virtual void repeatSpan(Span span, int32_t repeatCount) = 0;
204
205 // The x's and y's are setup in the following order:
206 // +--------+--------+
207 // | | |
208 // | px00 | px10 |
209 // | 0 | 1 |
210 // +--------+--------+
211 // | | |
212 // | px01 | px11 |
213 // | 2 | 3 |
214 // +--------+--------+
215 // These pixels coordinates are arranged in the following order in xs and ys :
216 // px00 px10 px01 px11
217 virtual void SK_VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) = 0;
218
219 // A span represents sample points that have been mapped from destination sp ace to source
220 // space. Each sample point is then expanded to the four bilerp points by ad d +/- 0.5. The
221 // resulting Y values my be off the tile. When y +/- 0.5 are more than 1 apa rt because of
222 // tiling, the second Y is used to denote the retiled Y value.
223 virtual void bilerpSpan(Span span, SkScalar y) = 0;
224 }; 213 };
225 214
226 class SkLinearBitmapPipeline::DestinationInterface { 215 class SkLinearBitmapPipeline::DestinationInterface {
227 public: 216 public:
228 virtual ~DestinationInterface() { } 217 virtual ~DestinationInterface() { }
229 // Count is normally not needed, but in these early stages of development it is useful to 218 // Count is normally not needed, but in these early stages of development it is useful to
230 // check bounds. 219 // check bounds.
231 // TODO(herb): 4/6/2016 - remove count when code is stable. 220 // TODO(herb): 4/6/2016 - remove count when code is stable.
232 virtual void setDestination(void* dst, int count) = 0; 221 virtual void setDestination(void* dst, int count) = 0;
233 }; 222 };
234 223
235 class SkLinearBitmapPipeline::BlendProcessorInterface 224 class SkLinearBitmapPipeline::BlendProcessorInterface
236 : public SkLinearBitmapPipeline::DestinationInterface { 225 : public SkLinearBitmapPipeline::DestinationInterface {
237 public: 226 public:
238 virtual void SK_VECTORCALL blendPixel(Sk4f pixel0) = 0; 227 virtual void SK_VECTORCALL blendPixel(Sk4f pixel0) = 0;
239 virtual void SK_VECTORCALL blend4Pixels(Sk4f p0, Sk4f p1, Sk4f p2, Sk4f p3) = 0; 228 virtual void SK_VECTORCALL blend4Pixels(Sk4f p0, Sk4f p1, Sk4f p2, Sk4f p3) = 0;
240 }; 229 };
241 230
242 class SkLinearBitmapPipeline::PixelAccessorInterface { 231 class SkLinearBitmapPipeline::PixelAccessorInterface {
243 public: 232 public:
244 virtual ~PixelAccessorInterface() { } 233 virtual ~PixelAccessorInterface() { }
245 virtual void SK_VECTORCALL getFewPixels( 234 virtual void SK_VECTORCALL getFewPixels(
246 int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) const = 0; 235 int n, Sk4i xs, Sk4i ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) const = 0;
247 236
248 virtual void SK_VECTORCALL get4Pixels( 237 virtual void SK_VECTORCALL get4Pixels(
249 Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const = 0; 238 Sk4i xs, Sk4i ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const = 0;
250 239
251 virtual void get4Pixels( 240 virtual void get4Pixels(
252 const void* src, int index, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const = 0; 241 const void* src, int index, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const = 0;
253 242
254 virtual Sk4f getPixelFromRow(const void* row, int index) const = 0; 243 virtual Sk4f getPixelFromRow(const void* row, int index) const = 0;
255 244
256 virtual Sk4f getPixelAt(int index) const = 0; 245 virtual Sk4f getPixelAt(int index) const = 0;
257 246
258 virtual const void* row(int y) const = 0; 247 virtual const void* row(int y) const = 0;
259 }; 248 };
260 249
261 #endif // SkLinearBitmapPipeline_core_DEFINED 250 #endif // SkLinearBitmapPipeline_core_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline.cpp ('k') | src/core/SkLinearBitmapPipeline_sample.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698