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

Side by Side Diff: src/opts/SkBitmapProcState_opts_SSE2.cpp

Issue 1661613002: Use SkBitmapProcStateAutoMapper for filter samplers also (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/opts/SkBitmapProcState_matrix_neon.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 2009 The Android Open Source Project 2 * Copyright 2009 The Android Open Source Project
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 <emmintrin.h> 8 #include <emmintrin.h>
9 #include "SkBitmapProcState_opts_SSE2.h" 9 #include "SkBitmapProcState_opts_SSE2.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 */ 245 */
246 void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[], 246 void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[],
247 int count, int x, int y) { 247 int count, int x, int y) {
248 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | 248 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
249 SkMatrix::kScale_Mask)) == 0); 249 SkMatrix::kScale_Mask)) == 0);
250 SkASSERT(s.fInvKy == 0); 250 SkASSERT(s.fInvKy == 0);
251 251
252 const unsigned maxX = s.fPixmap.width() - 1; 252 const unsigned maxX = s.fPixmap.width() - 1;
253 const SkFixed one = s.fFilterOneX; 253 const SkFixed one = s.fFilterOneX;
254 const SkFixed dx = s.fInvSx; 254 const SkFixed dx = s.fInvSx;
255 SkFixed fx;
256 255
257 SkPoint pt; 256 const SkBitmapProcStateAutoMapper mapper(s, x, y);
258 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 257 const SkFixed fy = SkFractionalIntToFixed(mapper.y());
259 SkIntToScalar(y) + SK_ScalarHalf, &pt);
260 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
261 const unsigned maxY = s.fPixmap.height() - 1; 258 const unsigned maxY = s.fPixmap.height() - 1;
262 // compute our two Y values up front 259 // compute our two Y values up front
263 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); 260 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY);
264 // now initialize fx 261 // now initialize fx
265 fx = SkScalarToFixed(pt.fX) - (one >> 1); 262 SkFixed fx = SkFractionalIntToFixed(mapper.x());
266 263
267 // test if we don't need to apply the tile proc 264 // test if we don't need to apply the tile proc
268 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && 265 if (dx > 0 && (unsigned)(fx >> 16) <= maxX &&
269 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { 266 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) {
270 if (count >= 4) { 267 if (count >= 4) {
271 // SSE version of decal_filter_scale 268 // SSE version of decal_filter_scale
272 while ((size_t(xy) & 0x0F) != 0) { 269 while ((size_t(xy) & 0x0F) != 0) {
273 SkASSERT((fx >> (16 + 14)) == 0); 270 SkASSERT((fx >> (16 + 14)) == 0);
274 *xy++ = (fx >> 12 << 14) | ((fx >> 16) + 1); 271 *xy++ = (fx >> 12 << 14) | ((fx >> 16) + 1);
275 fx += dx; 272 fx += dx;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 fx += dx; 475 fx += dx;
479 } 476 }
480 } 477 }
481 } 478 }
482 479
483 /* SSE version of ClampX_ClampY_filter_affine() 480 /* SSE version of ClampX_ClampY_filter_affine()
484 * portable version is in core/SkBitmapProcState_matrix.h 481 * portable version is in core/SkBitmapProcState_matrix.h
485 */ 482 */
486 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, 483 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s,
487 uint32_t xy[], int count, int x, int y) { 484 uint32_t xy[], int count, int x, int y) {
488 SkPoint srcPt; 485 const SkBitmapProcStateAutoMapper mapper(s, x, y);
489 s.fInvProc(s.fInvMatrix,
490 SkIntToScalar(x) + SK_ScalarHalf,
491 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
492 486
493 SkFixed oneX = s.fFilterOneX; 487 SkFixed oneX = s.fFilterOneX;
494 SkFixed oneY = s.fFilterOneY; 488 SkFixed oneY = s.fFilterOneY;
495 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); 489 SkFixed fx = SkFractionalIntToFixed(mapper.x());
496 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); 490 SkFixed fy = SkFractionalIntToFixed(mapper.y());
497 SkFixed dx = s.fInvSx; 491 SkFixed dx = s.fInvSx;
498 SkFixed dy = s.fInvKy; 492 SkFixed dy = s.fInvKy;
499 unsigned maxX = s.fPixmap.width() - 1; 493 unsigned maxX = s.fPixmap.width() - 1;
500 unsigned maxY = s.fPixmap.height() - 1; 494 unsigned maxY = s.fPixmap.height() - 1;
501 495
502 if (count >= 2 && (maxX <= 0xFFFF)) { 496 if (count >= 2 && (maxX <= 0xFFFF)) {
503 SkFixed dx2 = dx + dx; 497 SkFixed dx2 = dx + dx;
504 SkFixed dy2 = dy + dy; 498 SkFixed dy2 = dy + dy;
505 499
506 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy); 500 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } // while count >= 4 612 } // while count >= 4
619 } // if count >= 4 613 } // if count >= 4
620 614
621 while (count-- > 0) { 615 while (count-- > 0) {
622 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | 616 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) |
623 SkClampMax(fx >> 16, maxX); 617 SkClampMax(fx >> 16, maxX);
624 fx += dx; 618 fx += dx;
625 fy += dy; 619 fy += dy;
626 } 620 }
627 } 621 }
OLDNEW
« no previous file with comments | « src/opts/SkBitmapProcState_matrix_neon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698