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

Side by Side Diff: tests/SkLinearBitmapPipelineTest.cpp

Issue 1775963002: Bilerp + mirror + perspective (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments. 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 | « src/core/SkLinearBitmapPipeline_tile.h ('k') | 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 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 <algorithm> 8 #include <algorithm>
9 #include <array> 9 #include <array>
10 #include <tuple> 10 #include <tuple>
11 #include <vector> 11 #include <vector>
12 #include "SkLinearBitmapPipeline.h" 12 #include "SkLinearBitmapPipeline.h"
13 #include "SkColor.h" 13 #include "SkColor.h"
14 #include "SkNx.h" 14 #include "SkNx.h"
15 #include "SkPoint.h" 15 #include "SkPoint.h"
16 #include "SkPM4f.h" 16 #include "SkPM4f.h"
17 #include "Test.h" 17 #include "Test.h"
18 #include "SkLinearBitmapPipeline_tile.h" 18 #include "SkLinearBitmapPipeline_tile.h"
19 19
20 20
21 DEF_TEST(LBPBilerpEdge, reporter) {
22
23 }
24
21 static SkString dump(SkScalar cut, Span prefix, Span remainder) { 25 static SkString dump(SkScalar cut, Span prefix, Span remainder) {
22 SkPoint prefixStart; SkScalar prefixLen; int prefixCount; 26 SkPoint prefixStart; SkScalar prefixLen; int prefixCount;
23 std::tie(prefixStart, prefixLen, prefixCount) = prefix; 27 std::tie(prefixStart, prefixLen, prefixCount) = prefix;
24 SkPoint remainderStart; SkScalar remainderLen; int remainderCount; 28 SkPoint remainderStart; SkScalar remainderLen; int remainderCount;
25 std::tie(remainderStart, remainderLen, remainderCount) = remainder; 29 std::tie(remainderStart, remainderLen, remainderCount) = remainder;
26 return SkStringPrintf("cut: %f prefix: (%f, %f), %f, %d - remainder: (%f, %f ), %f, %d", 30 return SkStringPrintf("cut: %f prefix: (%f, %f), %f, %d - remainder: (%f, %f ), %f, %d",
27 cut, 31 cut,
28 prefixStart.fX, prefixStart.fY, prefixLen, prefixCount , 32 prefixStart.fX, prefixStart.fY, prefixLen, prefixCount ,
29 remainderStart.fX, remainderStart.fY, remainderLen, re mainderCount); 33 remainderStart.fX, remainderStart.fY, remainderLen, re mainderCount);
30 } 34 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 check_span_result(reporter, span, dx, 0.0f, start, -5.0f, 6); 97 check_span_result(reporter, span, dx, 0.0f, start, -5.0f, 6);
94 check_span_result(reporter, span, dx, -6.0f, SkPoint::Make(5, 5), -9.0f, 10); 98 check_span_result(reporter, span, dx, -6.0f, SkPoint::Make(5, 5), -9.0f, 10);
95 check_span_result(reporter, span, dx, -5.0f, SkPoint::Make(5, 5), -9.0f, 10); 99 check_span_result(reporter, span, dx, -5.0f, SkPoint::Make(5, 5), -9.0f, 10);
96 check_span_result(reporter, span, dx, -4.0f, SkPoint::Make(5, 5), -9.0f, 10); 100 check_span_result(reporter, span, dx, -4.0f, SkPoint::Make(5, 5), -9.0f, 10);
97 check_span_result(reporter, span, dx, 4.0f, SkPoint::Make(5, 5), -1.0f, 2); 101 check_span_result(reporter, span, dx, 4.0f, SkPoint::Make(5, 5), -1.0f, 2);
98 check_span_result(reporter, span, dx, 5.0f, SkPoint::Make(5, 5), 0.0f, 1); 102 check_span_result(reporter, span, dx, 5.0f, SkPoint::Make(5, 5), 0.0f, 1);
99 check_span_result(reporter, span, dx, 6.0f, SkPoint::Make(0, 0), 0.0f, 0); 103 check_span_result(reporter, span, dx, 6.0f, SkPoint::Make(0, 0), 0.0f, 0);
100 } 104 }
101 } 105 }
102 106
103 template <typename Tiler> 107 DEF_TEST(LBPBilerpSpanOps, reporter) {
104 static bool compare_tiler_case(Tiler& tiler, Span span, skiatest::Reporter* repo rter) { 108
109 }
110
111 template <typename XTiler, typename YTiler>
112 static bool compare_tiler_case(
113 XTiler& xTiler, YTiler& yTiler, Span span, skiatest::Reporter* reporter) {
105 Span originalSpan = span; 114 Span originalSpan = span;
106 std::vector<SkPoint> listPoints; 115 std::vector<SkPoint> listPoints;
107 std::vector<SkPoint> spanPoints; 116 std::vector<SkPoint> spanPoints;
108 struct Sink { 117 struct Sink {
109 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) { 118 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) {
110 SkASSERT(0 < n && n < 4); 119 SkASSERT(0 < n && n < 4);
111 if (n >= 1) storePoint({xs[0], ys[0]}); 120 if (n >= 1) storePoint({xs[0], ys[0]});
112 if (n >= 2) storePoint({xs[1], ys[1]}); 121 if (n >= 2) storePoint({xs[1], ys[1]});
113 if (n >= 3) storePoint({xs[2], ys[2]}); 122 if (n >= 3) storePoint({xs[2], ys[2]});
114 } 123 }
(...skipping 21 matching lines...) Expand all
136 145
137 SkPoint start; SkScalar length; int count; 146 SkPoint start; SkScalar length; int count;
138 std::tie(start, length, count) = span; 147 std::tie(start, length, count) = span;
139 148
140 SkScalar dx = length / (count - 1); 149 SkScalar dx = length / (count - 1);
141 Sk4f xs = Sk4f{X(start)} + Sk4f{0.0f, dx, 2 * dx, 3 * dx}; 150 Sk4f xs = Sk4f{X(start)} + Sk4f{0.0f, dx, 2 * dx, 3 * dx};
142 Sk4f ys = Sk4f{Y(start)}; 151 Sk4f ys = Sk4f{Y(start)};
143 while (count >= 4) { 152 while (count >= 4) {
144 Sk4f txs = xs; 153 Sk4f txs = xs;
145 Sk4f tys = ys; 154 Sk4f tys = ys;
146 tiler.processPoints(&txs, &tys); 155 xTiler.tileXPoints(&txs);
156 yTiler.tileYPoints(&tys);
147 listSink.pointList4(txs, tys); 157 listSink.pointList4(txs, tys);
148 xs = xs + 4.0f * dx; 158 xs = xs + 4.0f * dx;
149 count -= 4; 159 count -= 4;
150 } 160 }
151 if (count > 0) { 161 if (count > 0) {
152 tiler.processPoints(&xs, &ys); 162 xTiler.tileXPoints(&xs);
163 yTiler.tileYPoints(&ys);
153 listSink.pointListFew(count, xs, ys); 164 listSink.pointListFew(count, xs, ys);
154 } 165 }
155 166
156 bool handledSpan = tiler.maybeProcessSpan(span, &spanSink); 167 std::tie(start, length, count) = originalSpan;
168 SkScalar x = X(start);
169 SkScalar y = yTiler.tileY(Y(start));
170 Span yAdjustedSpan{{x, y}, length, count};
171
172 bool handledSpan = xTiler.maybeProcessSpan(yAdjustedSpan, &spanSink);
157 if (handledSpan) { 173 if (handledSpan) {
158 auto firstNotTheSame = std::mismatch( 174 auto firstNotTheSame = std::mismatch(
159 listPoints.begin(), listPoints.end(), spanPoints.begin()); 175 listPoints.begin(), listPoints.end(), spanPoints.begin());
160 if (firstNotTheSame.first != listSink.fPoints->end()) { 176 if (firstNotTheSame.first != listSink.fPoints->end()) {
161 auto element = std::distance(listPoints.begin(), firstNotTheSame.fir st); 177 auto element = std::distance(listPoints.begin(), firstNotTheSame.fir st);
162 SkASSERT(element >= 0); 178 SkASSERT(element >= 0);
163 std::tie(start, length, count) = originalSpan; 179 std::tie(start, length, count) = originalSpan;
164 ERRORF(reporter, "Span: {%f, %f}, %f, %d", start.fX, start.fY, lengt h, count); 180 ERRORF(reporter, "Span: {%f, %f}, %f, %d", start.fX, start.fY, lengt h, count);
165 ERRORF(reporter, "Size points: %d, size span: %d", 181 ERRORF(reporter, "Size points: %d, size span: %d",
166 listPoints.size(), spanPoints.size()); 182 listPoints.size(), spanPoints.size());
(...skipping 10 matching lines...) Expand all
177 "Mismatch at %d - points: %f, %f - span: %f, %f", 193 "Mismatch at %d - points: %f, %f - span: %f, %f",
178 element, listPoints[element].fX, listPoints[element].fY, 194 element, listPoints[element].fX, listPoints[element].fY,
179 spanPoints[element].fX, spanPoints[element].fY); 195 spanPoints[element].fX, spanPoints[element].fY);
180 } 196 }
181 SkFAIL("aha"); 197 SkFAIL("aha");
182 } 198 }
183 } 199 }
184 return true; 200 return true;
185 } 201 }
186 202
187 template <typename Tiler> 203 template <typename XTiler, typename YTiler>
188 static bool compare_tiler_spans(int width, int height, skiatest::Reporter* repor ter) { 204 static bool compare_tiler_spans(int width, int height, skiatest::Reporter* repor ter) {
189 Tiler tiler{SkSize::Make((SkScalar)width, (SkScalar)height)}; 205 XTiler xTiler{width};
206 YTiler yTiler{height};
190 INFOF(reporter, "w: %d, h: %d \n", width, height); 207 INFOF(reporter, "w: %d, h: %d \n", width, height);
191 std::array<int, 8> interestingX {{-5, -1, 0, 1, width - 1, width, width + 1, width + 5}}; 208 std::array<int, 8> interestingX {{-5, -1, 0, 1, width - 1, width, width + 1, width + 5}};
192 std::array<int, 8> interestingY {{-5, -1, 0, 1, height - 1, height, height + 1, height + 5}}; 209 std::array<int, 8> interestingY {{-5, -1, 0, 1, height - 1, height, height + 1, height + 5}};
193 std::array<int, 6> interestingCount {{1, 2, 3, 4, 5, 10}}; 210 std::array<int, 6> interestingCount {{1, 2, 3, 4, 5, 10}};
194 std::array<SkScalar, 7> interestingScale {{0.0f, 1.0f, 0.5f, 2.1f, -2.1f, -1 .0f, -0.5f}}; 211 std::array<SkScalar, 7> interestingScale {{0.0f, 1.0f, 0.5f, 2.1f, -2.1f, -1 .0f, -0.5f}};
195 for (auto scale : interestingScale) { 212 for (auto scale : interestingScale) {
196 for (auto startX : interestingX) { 213 for (auto startX : interestingX) {
197 for (auto count : interestingCount) { 214 for (auto count : interestingCount) {
198 for (auto y : interestingY) { 215 for (auto y : interestingY) {
199 Span span{ 216 Span span{
200 SkPoint::Make((SkScalar)startX, (SkScalar)y), (count-1.0 f) * scale, count}; 217 SkPoint::Make((SkScalar)startX, (SkScalar)y), (count-1.0 f) * scale, count};
201 if (!compare_tiler_case(tiler, span, reporter)) { 218 if (!compare_tiler_case(xTiler, yTiler, span, reporter)) {
202 return false; 219 return false;
203 } 220 }
204 } 221 }
205 } 222 }
206 } 223 }
207 } 224 }
208 return true; 225 return true;
209 } 226 }
210 227
211 template <typename Tiler> 228 template <typename XTiler, typename YTiler>
212 static void test_tiler(skiatest::Reporter* reporter) { 229 static void test_tiler(skiatest::Reporter* reporter) {
213 std::array<int, 6> interestingSize {{1, 2, 3, 4, 5, 10}}; 230 std::array<int, 6> interestingSize {{1, 2, 3, 4, 5, 10}};
214 for (auto width : interestingSize) { 231 for (auto width : interestingSize) {
215 for (auto height : interestingSize) { 232 for (auto height : interestingSize) {
216 if (!compare_tiler_spans<Tiler>(width, height, reporter)) { return; } 233 if (!compare_tiler_spans<XTiler, YTiler>(width, height, reporter)) { return; }
217 } 234 }
218 } 235 }
219 } 236 }
220 237 /*
221 DEF_TEST(LBPStrategyClampTile, reporter) { 238 DEF_TEST(LBPStrategyClampTile, reporter) {
222 #if 0 239 #if 0
223 ClampStrategy tiler{SkSize::Make(1, 1)}; 240 ClampStrategy tiler{SkSize::Make(1, 1)};
224 Span span{SkPoint::Make(0, -5), 1.0f, 2}; 241 Span span{SkPoint::Make(0, -5), 1.0f, 2};
225 compare_tiler_case<ClampStrategy>(tiler, span, reporter); 242 compare_tiler_case<ClampStrategy>(tiler, span, reporter);
226 #else 243 #else
227 test_tiler<ClampStrategy>(reporter); 244 test_tiler<XClampStrategy, YClampStrategy>(reporter);
228 #endif 245 #endif
229 } 246 }
230 247
231 DEF_TEST(LBPStrategyRepeatTile, reporter) { 248 DEF_TEST(LBPStrategyRepeatTile, reporter) {
232 #if 0 249 #if 0
233 RepeatStrategy tiler{SkSize::Make(3, 1)}; 250 RepeatStrategy tiler{SkSize::Make(3, 1)};
234 Span span{SkPoint::Make(-5, -5), 20 * 2.1f, 100}; 251 Span span{SkPoint::Make(-5, -5), 20 * 2.1f, 100};
235 compare_tiler_case<RepeatStrategy>(tiler, span, reporter); 252 compare_tiler_case<RepeatStrategy>(tiler, span, reporter);
236 #else 253 #else
237 test_tiler<RepeatStrategy>(reporter); 254 test_tiler<XRepeatStrategy, YRepeatStrategy>(reporter);
238 #endif 255 #endif
239 } 256 }
240 257 */
241
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline_tile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698