| 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 #include "SkLinearBitmapPipeline.h" | 8 #include "SkLinearBitmapPipeline.h" |
| 9 #include "SkPM4f.h" | 9 #include "SkPM4f.h" |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // point lists for processing. | 126 // point lists for processing. |
| 127 template<typename Strategy, typename Next> | 127 template<typename Strategy, typename Next> |
| 128 class PointProcessor final : public SkLinearBitmapPipeline::PointProcessorInterf
ace { | 128 class PointProcessor final : public SkLinearBitmapPipeline::PointProcessorInterf
ace { |
| 129 public: | 129 public: |
| 130 template <typename... Args> | 130 template <typename... Args> |
| 131 PointProcessor(Next* next, Args&&... args) | 131 PointProcessor(Next* next, Args&&... args) |
| 132 : fNext{next} | 132 : fNext{next} |
| 133 , fStrategy{std::forward<Args>(args)...}{ } | 133 , fStrategy{std::forward<Args>(args)...}{ } |
| 134 | 134 |
| 135 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { | 135 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { |
| 136 Sk4f newXs = xs; | 136 fStrategy.processPoints(&xs, &ys); |
| 137 Sk4f newYs = ys; | 137 fNext->pointListFew(n, xs, ys); |
| 138 fStrategy.processPoints(&newXs, &newYs); | |
| 139 fNext->pointListFew(n, newXs, newYs); | |
| 140 } | 138 } |
| 141 | 139 |
| 142 void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override { | 140 void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override { |
| 143 Sk4f newXs = xs; | 141 fStrategy.processPoints(&xs, &ys); |
| 144 Sk4f newYs = ys; | 142 fNext->pointList4(xs, ys); |
| 145 fStrategy.processPoints(&newXs, &newYs); | |
| 146 fNext->pointList4(newXs, newYs); | |
| 147 } | 143 } |
| 148 | 144 |
| 149 void pointSpan(SkPoint start, SkScalar length, int count) override { | 145 void pointSpan(SkPoint start, SkScalar length, int count) override { |
| 150 if (!fStrategy.maybeProcessSpan(start, length, count, fNext)) { | 146 if (!fStrategy.maybeProcessSpan(start, length, count, fNext)) { |
| 151 span_fallback(start, length, count, this); | 147 span_fallback(start, length, count, this); |
| 152 } | 148 } |
| 153 } | 149 } |
| 154 | 150 |
| 155 private: | 151 private: |
| 156 Next* const fNext; | 152 Next* const fNext; |
| 157 Strategy fStrategy; | 153 Strategy fStrategy; |
| 158 }; | 154 }; |
| 159 | 155 |
| 160 // See PointProcessor for responsibilities of Strategy. | 156 // See PointProcessor for responsibilities of Strategy. |
| 161 template<typename Strategy, typename Next> | 157 template<typename Strategy, typename Next> |
| 162 class BilerpProcessor final : public SkLinearBitmapPipeline::BilerpProcessorInte
rface { | 158 class BilerpProcessor final : public SkLinearBitmapPipeline::BilerpProcessorInte
rface { |
| 163 public: | 159 public: |
| 164 template <typename... Args> | 160 template <typename... Args> |
| 165 BilerpProcessor(Next* next, Args&&... args) | 161 BilerpProcessor(Next* next, Args&&... args) |
| 166 : fNext{next} | 162 : fNext{next} |
| 167 , fStrategy{std::forward<Args>(args)...}{ } | 163 , fStrategy{std::forward<Args>(args)...}{ } |
| 168 | 164 |
| 169 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { | 165 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { |
| 170 Sk4f newXs = xs; | 166 fStrategy.processPoints(&xs, &ys); |
| 171 Sk4f newYs = ys; | 167 fNext->pointListFew(n, xs, ys); |
| 172 fStrategy.processPoints(&newXs, &newYs); | |
| 173 fNext->pointListFew(n, newXs, newYs); | |
| 174 } | 168 } |
| 175 | 169 |
| 176 void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override { | 170 void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override { |
| 177 Sk4f newXs = xs; | 171 fStrategy.processPoints(&xs, &ys); |
| 178 Sk4f newYs = ys; | 172 fNext->pointList4(xs, ys); |
| 179 fStrategy.processPoints(&newXs, &newYs); | |
| 180 fNext->pointList4(newXs, newYs); | |
| 181 } | 173 } |
| 182 | 174 |
| 183 void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override { | 175 void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override { |
| 184 Sk4f newXs = xs; | 176 fStrategy.processPoints(&xs, &ys); |
| 185 Sk4f newYs = ys; | 177 fNext->bilerpList(xs, ys); |
| 186 fStrategy.processPoints(&newXs, &newYs); | |
| 187 fNext->bilerpList(newXs, newYs); | |
| 188 } | 178 } |
| 189 | 179 |
| 190 void pointSpan(SkPoint start, SkScalar length, int count) override { | 180 void pointSpan(SkPoint start, SkScalar length, int count) override { |
| 191 if (!fStrategy.maybeProcessSpan(start, length, count, fNext)) { | 181 if (!fStrategy.maybeProcessSpan(start, length, count, fNext)) { |
| 192 span_fallback(start, length, count, this); | 182 span_fallback(start, length, count, this); |
| 193 } | 183 } |
| 194 } | 184 } |
| 195 | 185 |
| 196 private: | 186 private: |
| 197 Next* const fNext; | 187 Next* const fNext; |
| 198 Strategy fStrategy; | 188 Strategy fStrategy; |
| 199 }; | 189 }; |
| 200 | 190 |
| 201 class SkippedStage final : public SkLinearBitmapPipeline::BilerpProcessorInterfa
ce { | 191 class SkippedStage final : public SkLinearBitmapPipeline::BilerpProcessorInterfa
ce { |
| 202 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { | 192 void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override { |
| 203 SkFAIL("Skipped stage."); | 193 SkFAIL("Skipped stage."); |
| 204 } | 194 } |
| 205 void VECTORCALL pointList4(Sk4f Xs, Sk4f Ys) override { | 195 void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override { |
| 206 SkFAIL("Skipped stage."); | 196 SkFAIL("Skipped stage."); |
| 207 } | 197 } |
| 208 void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override { | 198 void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override { |
| 209 SkFAIL("Skipped stage."); | 199 SkFAIL("Skipped stage."); |
| 210 } | 200 } |
| 211 void pointSpan(SkPoint start, SkScalar length, int count) override { | 201 void pointSpan(SkPoint start, SkScalar length, int count) override { |
| 212 SkFAIL("Skipped stage."); | 202 SkFAIL("Skipped stage."); |
| 213 } | 203 } |
| 214 }; | 204 }; |
| 215 | 205 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 if (count == 1) { | 701 if (count == 1) { |
| 712 fFirstStage->pointListFew(1, Sk4f{x + 0.5f}, Sk4f{y + 0.5f}); | 702 fFirstStage->pointListFew(1, Sk4f{x + 0.5f}, Sk4f{y + 0.5f}); |
| 713 } else { | 703 } else { |
| 714 // The count and length arguments start out in a precise relation in ord
er to keep the | 704 // The count and length arguments start out in a precise relation in ord
er to keep the |
| 715 // math correct through the different stages. Count is the number of pix
el to produce. | 705 // math correct through the different stages. Count is the number of pix
el to produce. |
| 716 // Since the code samples at pixel centers, length is the distance from
the center of the | 706 // Since the code samples at pixel centers, length is the distance from
the center of the |
| 717 // first pixel to the center of the last pixel. This implies that length
is count-1. | 707 // first pixel to the center of the last pixel. This implies that length
is count-1. |
| 718 fFirstStage->pointSpan(SkPoint{x + 0.5f, y + 0.5f}, count - 1, count); | 708 fFirstStage->pointSpan(SkPoint{x + 0.5f, y + 0.5f}, count - 1, count); |
| 719 } | 709 } |
| 720 } | 710 } |
| OLD | NEW |