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

Side by Side Diff: skia/ext/convolver_unittest.cc

Issue 13293004: enable SSE2 in skia/convolver for linux32 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wrapped convolvevertically Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string.h> 5 #include <string.h>
6 #include <time.h> 6 #include <time.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ASSERT_EQ(6, filter.max_filter()); 204 ASSERT_EQ(6, filter.max_filter());
205 ASSERT_EQ(6, filter.num_values()); 205 ASSERT_EQ(6, filter.num_values());
206 206
207 values = filter.FilterForValue(5, &filter_offset, &filter_length); 207 values = filter.FilterForValue(5, &filter_offset, &filter_length);
208 ASSERT_TRUE(values == NULL); // filter_length == 0 => values is NULL 208 ASSERT_TRUE(values == NULL); // filter_length == 0 => values is NULL
209 ASSERT_EQ(66, filter_offset); // value passed in 209 ASSERT_EQ(66, filter_offset); // value passed in
210 ASSERT_EQ(0, filter_length); 210 ASSERT_EQ(0, filter_length);
211 } 211 }
212 212
213 TEST(Convolver, SIMDVerification) { 213 TEST(Convolver, SIMDVerification) {
214 #if defined(SIMD_SSE2)
215 base::CPU cpu;
216 if (!cpu.has_sse2()) return;
217
218 int source_sizes[][2] = { 214 int source_sizes[][2] = {
219 {1,1}, {1,2}, {1,3}, {1,4}, {1,5}, 215 {1,1}, {1,2}, {1,3}, {1,4}, {1,5},
220 {2,1}, {2,2}, {2,3}, {2,4}, {2,5}, 216 {2,1}, {2,2}, {2,3}, {2,4}, {2,5},
221 {3,1}, {3,2}, {3,3}, {3,4}, {3,5}, 217 {3,1}, {3,2}, {3,3}, {3,4}, {3,5},
222 {4,1}, {4,2}, {4,3}, {4,4}, {4,5}, 218 {4,1}, {4,2}, {4,3}, {4,4}, {4,5},
223 {1920, 1080}, 219 {1920, 1080},
224 {720, 480}, 220 {720, 480},
225 {1377, 523}, 221 {1377, 523},
226 {325, 241} }; 222 {325, 241} };
227 int dest_sizes[][2] = { {1280, 1024}, {480, 270}, {177, 123} }; 223 int dest_sizes[][2] = { {1280, 1024}, {480, 270}, {177, 123} };
(...skipping 11 matching lines...) Expand all
239 235
240 // Preparing convolve coefficients. 236 // Preparing convolve coefficients.
241 ConvolutionFilter1D x_filter, y_filter; 237 ConvolutionFilter1D x_filter, y_filter;
242 for (unsigned int p = 0; p < dest_width; ++p) { 238 for (unsigned int p = 0; p < dest_width; ++p) {
243 unsigned int offset = source_width * p / dest_width; 239 unsigned int offset = source_width * p / dest_width;
244 EXPECT_LT(offset, source_width); 240 EXPECT_LT(offset, source_width);
245 x_filter.AddFilter(offset, filter, 241 x_filter.AddFilter(offset, filter,
246 std::min<int>(arraysize(filter), 242 std::min<int>(arraysize(filter),
247 source_width - offset)); 243 source_width - offset));
248 } 244 }
249 x_filter.PaddingForSIMD(8); 245 x_filter.PaddingForSIMD();
250 for (unsigned int p = 0; p < dest_height; ++p) { 246 for (unsigned int p = 0; p < dest_height; ++p) {
251 unsigned int offset = source_height * p / dest_height; 247 unsigned int offset = source_height * p / dest_height;
252 y_filter.AddFilter(offset, filter, 248 y_filter.AddFilter(offset, filter,
253 std::min<int>(arraysize(filter), 249 std::min<int>(arraysize(filter),
254 source_height - offset)); 250 source_height - offset));
255 } 251 }
256 y_filter.PaddingForSIMD(8); 252 y_filter.PaddingForSIMD();
257 253
258 // Allocate input and output skia bitmap. 254 // Allocate input and output skia bitmap.
259 SkBitmap source, result_c, result_sse; 255 SkBitmap source, result_c, result_sse;
260 source.setConfig(SkBitmap::kARGB_8888_Config, 256 source.setConfig(SkBitmap::kARGB_8888_Config,
261 source_width, source_height); 257 source_width, source_height);
262 source.allocPixels(); 258 source.allocPixels();
263 result_c.setConfig(SkBitmap::kARGB_8888_Config, 259 result_c.setConfig(SkBitmap::kARGB_8888_Config,
264 dest_width, dest_height); 260 dest_width, dest_height);
265 result_c.allocPixels(); 261 result_c.allocPixels();
266 result_sse.setConfig(SkBitmap::kARGB_8888_Config, 262 result_sse.setConfig(SkBitmap::kARGB_8888_Config,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 for (unsigned int i = 0; i < dest_height; i++) { 315 for (unsigned int i = 0; i < dest_height; i++) {
320 for (unsigned int x = 0; x < dest_width * 4; x++) { // RGBA always. 316 for (unsigned int x = 0; x < dest_width * 4; x++) { // RGBA always.
321 EXPECT_EQ(r1[x], r2[x]); 317 EXPECT_EQ(r1[x], r2[x]);
322 } 318 }
323 r1 += result_c.rowBytes(); 319 r1 += result_c.rowBytes();
324 r2 += result_sse.rowBytes(); 320 r2 += result_sse.rowBytes();
325 } 321 }
326 } 322 }
327 } 323 }
328 } 324 }
329 #endif
330 } 325 }
331 326
332 } // namespace skia 327 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698