| OLD | NEW |
| 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 |
| 11 #include <cmath> | 11 #include <cmath> |
| 12 #include "SkNx.h" | 12 #include "SkNx.h" |
| 13 | 13 |
| 14 // New bilerp strategy: | 14 // New bilerp strategy: |
| 15 // Pass through on bilerpList4 and bilerpListFew (analogs to pointList), introdu
ce bilerpEdge | 15 // Pass through on bilerpList4 and bilerpListFew (analogs to pointList), introdu
ce bilerpEdge |
| 16 // which takes 4 points. If the sample spans an edge, then break it into a biler
pEdge. Bilerp | 16 // which takes 4 points. If the sample spans an edge, then break it into a biler
pEdge. Bilerp |
| 17 // span then becomes a normal span except in special cases where an extra Y is g
iven. The bilerp | 17 // span then becomes a normal span except in special cases where an extra Y is g
iven. The bilerp |
| 18 // need to stay single point calculations until the tile layer. | 18 // need to stay single point calculations until the tile layer. |
| 19 // TODO: | 19 // TODO: |
| 20 // - edge span predicate. | 20 // - edge span predicate. |
| 21 // - introduce new point API | 21 // - introduce new point API |
| 22 // - Add tile for new api. | 22 // - Add tile for new api. |
| 23 | 23 |
| 24 // Tweak ABI of functions that pass Sk4f by value to pass them via registers. | |
| 25 #if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | |
| 26 #define VECTORCALL __vectorcall | |
| 27 #elif defined(SK_CPU_ARM32) && defined(SK_ARM_HAS_NEON) | |
| 28 #define VECTORCALL __attribute__((pcs("aapcs-vfp"))) | |
| 29 #else | |
| 30 #define VECTORCALL | |
| 31 #endif | |
| 32 | |
| 33 namespace { | 24 namespace { |
| 34 struct X { | 25 struct X { |
| 35 explicit X(SkScalar val) : fVal{val} { } | 26 explicit X(SkScalar val) : fVal{val} { } |
| 36 explicit X(SkPoint pt) : fVal{pt.fX} { } | 27 explicit X(SkPoint pt) : fVal{pt.fX} { } |
| 37 explicit X(SkSize s) : fVal{s.fWidth} { } | 28 explicit X(SkSize s) : fVal{s.fWidth} { } |
| 38 explicit X(SkISize s) : fVal((SkScalar)s.fWidth) { } | 29 explicit X(SkISize s) : fVal((SkScalar)s.fWidth) { } |
| 39 operator SkScalar () const {return fVal;} | 30 operator SkScalar () const {return fVal;} |
| 40 private: | 31 private: |
| 41 SkScalar fVal; | 32 SkScalar fVal; |
| 42 }; | 33 }; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 178 } |
| 188 } | 179 } |
| 189 } // namespace | 180 } // namespace |
| 190 | 181 |
| 191 class SkLinearBitmapPipeline::PointProcessorInterface { | 182 class SkLinearBitmapPipeline::PointProcessorInterface { |
| 192 public: | 183 public: |
| 193 virtual ~PointProcessorInterface() { } | 184 virtual ~PointProcessorInterface() { } |
| 194 // Take the first n (where 0 < n && n < 4) items from xs and ys and sample t
hose points. For | 185 // Take the first n (where 0 < n && n < 4) items from xs and ys and sample t
hose points. For |
| 195 // nearest neighbor, that means just taking the floor xs and ys. For bilerp,
this means | 186 // nearest neighbor, that means just taking the floor xs and ys. For bilerp,
this means |
| 196 // to expand the bilerp filter around the point and sample using that filter
. | 187 // to expand the bilerp filter around the point and sample using that filter
. |
| 197 virtual void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0; | 188 virtual void SK_VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0; |
| 198 // Same as pointListFew, but n = 4. | 189 // Same as pointListFew, but n = 4. |
| 199 virtual void VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0; | 190 virtual void SK_VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0; |
| 200 // A span is a compact form of sample points that are obtained by mapping po
ints from | 191 // A span is a compact form of sample points that are obtained by mapping po
ints from |
| 201 // destination space to source space. This is used for horizontal lines only
, and is mainly | 192 // destination space to source space. This is used for horizontal lines only
, and is mainly |
| 202 // used to take advantage of memory coherence for horizontal spans. | 193 // used to take advantage of memory coherence for horizontal spans. |
| 203 virtual void pointSpan(Span span) = 0; | 194 virtual void pointSpan(Span span) = 0; |
| 204 }; | 195 }; |
| 205 | 196 |
| 206 class SkLinearBitmapPipeline::SampleProcessorInterface | 197 class SkLinearBitmapPipeline::SampleProcessorInterface |
| 207 : public SkLinearBitmapPipeline::PointProcessorInterface { | 198 : public SkLinearBitmapPipeline::PointProcessorInterface { |
| 208 public: | 199 public: |
| 209 // Used for nearest neighbor when scale factor is 1.0. The span can just be
repeated with no | 200 // Used for nearest neighbor when scale factor is 1.0. The span can just be
repeated with no |
| 210 // edge pixel alignment problems. This is for handling a very common case. | 201 // edge pixel alignment problems. This is for handling a very common case. |
| 211 virtual void repeatSpan(Span span, int32_t repeatCount) = 0; | 202 virtual void repeatSpan(Span span, int32_t repeatCount) = 0; |
| 212 | 203 |
| 213 // The x's and y's are setup in the following order: | 204 // The x's and y's are setup in the following order: |
| 214 // +--------+--------+ | 205 // +--------+--------+ |
| 215 // | | | | 206 // | | | |
| 216 // | px00 | px10 | | 207 // | px00 | px10 | |
| 217 // | 0 | 1 | | 208 // | 0 | 1 | |
| 218 // +--------+--------+ | 209 // +--------+--------+ |
| 219 // | | | | 210 // | | | |
| 220 // | px01 | px11 | | 211 // | px01 | px11 | |
| 221 // | 2 | 3 | | 212 // | 2 | 3 | |
| 222 // +--------+--------+ | 213 // +--------+--------+ |
| 223 // These pixels coordinates are arranged in the following order in xs and ys
: | 214 // These pixels coordinates are arranged in the following order in xs and ys
: |
| 224 // px00 px10 px01 px11 | 215 // px00 px10 px01 px11 |
| 225 virtual void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) = 0; | 216 virtual void SK_VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) = 0; |
| 226 | 217 |
| 227 // A span represents sample points that have been mapped from destination sp
ace to source | 218 // A span represents sample points that have been mapped from destination sp
ace to source |
| 228 // space. Each sample point is then expanded to the four bilerp points by ad
d +/- 0.5. The | 219 // space. Each sample point is then expanded to the four bilerp points by ad
d +/- 0.5. The |
| 229 // resulting Y values my be off the tile. When y +/- 0.5 are more than 1 apa
rt because of | 220 // resulting Y values my be off the tile. When y +/- 0.5 are more than 1 apa
rt because of |
| 230 // tiling, the second Y is used to denote the retiled Y value. | 221 // tiling, the second Y is used to denote the retiled Y value. |
| 231 virtual void bilerpSpan(Span span, SkScalar y) = 0; | 222 virtual void bilerpSpan(Span span, SkScalar y) = 0; |
| 232 }; | 223 }; |
| 233 | 224 |
| 234 class SkLinearBitmapPipeline::DestinationInterface { | 225 class SkLinearBitmapPipeline::DestinationInterface { |
| 235 public: | 226 public: |
| 236 virtual ~DestinationInterface() { } | 227 virtual ~DestinationInterface() { } |
| 237 // Count is normally not needed, but in these early stages of development it
is useful to | 228 // Count is normally not needed, but in these early stages of development it
is useful to |
| 238 // check bounds. | 229 // check bounds. |
| 239 // TODO(herb): 4/6/2016 - remove count when code is stable. | 230 // TODO(herb): 4/6/2016 - remove count when code is stable. |
| 240 virtual void setDestination(void* dst, int count) = 0; | 231 virtual void setDestination(void* dst, int count) = 0; |
| 241 }; | 232 }; |
| 242 | 233 |
| 243 class SkLinearBitmapPipeline::BlendProcessorInterface | 234 class SkLinearBitmapPipeline::BlendProcessorInterface |
| 244 : public SkLinearBitmapPipeline::DestinationInterface { | 235 : public SkLinearBitmapPipeline::DestinationInterface { |
| 245 public: | 236 public: |
| 246 virtual void VECTORCALL blendPixel(Sk4f pixel0) = 0; | 237 virtual void SK_VECTORCALL blendPixel(Sk4f pixel0) = 0; |
| 247 virtual void VECTORCALL blend4Pixels(Sk4f p0, Sk4f p1, Sk4f p2, Sk4f p3) = 0
; | 238 virtual void SK_VECTORCALL blend4Pixels(Sk4f p0, Sk4f p1, Sk4f p2, Sk4f p3)
= 0; |
| 248 }; | 239 }; |
| 249 | 240 |
| 250 #endif // SkLinearBitmapPipeline_core_DEFINED | 241 #endif // SkLinearBitmapPipeline_core_DEFINED |
| OLD | NEW |