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

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

Issue 1158273007: switch bitmapshader internals over to pixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix neon/mips to use pixmpas Created 5 years, 6 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') | src/opts/SkBitmapProcState_opts_SSSE3.cpp » ('j') | 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"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkUtils.h" 12 #include "SkUtils.h"
13 13
14 void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s, 14 void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s,
15 const uint32_t* xy, 15 const uint32_t* xy,
16 int count, uint32_t* colors) { 16 int count, uint32_t* colors) {
17 SkASSERT(count > 0 && colors != NULL); 17 SkASSERT(count > 0 && colors != NULL);
18 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); 18 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
19 SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); 19 SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
20 SkASSERT(s.fAlphaScale == 256); 20 SkASSERT(s.fAlphaScale == 256);
21 21
22 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); 22 const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
23 size_t rb = s.fBitmap->rowBytes(); 23 size_t rb = s.fPixmap.rowBytes();
24 uint32_t XY = *xy++; 24 uint32_t XY = *xy++;
25 unsigned y0 = XY >> 14; 25 unsigned y0 = XY >> 14;
26 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); 26 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
27 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb); 27 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb);
28 unsigned subY = y0 & 0xF; 28 unsigned subY = y0 & 0xF;
29 29
30 // ( 0, 0, 0, 0, 0, 0, 0, 16) 30 // ( 0, 0, 0, 0, 0, 0, 0, 16)
31 __m128i sixteen = _mm_cvtsi32_si128(16); 31 __m128i sixteen = _mm_cvtsi32_si128(16);
32 32
33 // ( 0, 0, 0, 0, 16, 16, 16, 16) 33 // ( 0, 0, 0, 0, 16, 16, 16, 16)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Extract low int and store. 115 // Extract low int and store.
116 *colors++ = _mm_cvtsi128_si32(sum); 116 *colors++ = _mm_cvtsi128_si32(sum);
117 } while (--count > 0); 117 } while (--count > 0);
118 } 118 }
119 119
120 void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s, 120 void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s,
121 const uint32_t* xy, 121 const uint32_t* xy,
122 int count, uint32_t* colors) { 122 int count, uint32_t* colors) {
123 SkASSERT(count > 0 && colors != NULL); 123 SkASSERT(count > 0 && colors != NULL);
124 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); 124 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
125 SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); 125 SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
126 SkASSERT(s.fAlphaScale < 256); 126 SkASSERT(s.fAlphaScale < 256);
127 127
128 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); 128 const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
129 size_t rb = s.fBitmap->rowBytes(); 129 size_t rb = s.fPixmap.rowBytes();
130 uint32_t XY = *xy++; 130 uint32_t XY = *xy++;
131 unsigned y0 = XY >> 14; 131 unsigned y0 = XY >> 14;
132 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); 132 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
133 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb); 133 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb);
134 unsigned subY = y0 & 0xF; 134 unsigned subY = y0 & 0xF;
135 135
136 // ( 0, 0, 0, 0, 0, 0, 0, 16) 136 // ( 0, 0, 0, 0, 0, 0, 0, 16)
137 __m128i sixteen = _mm_cvtsi32_si128(16); 137 __m128i sixteen = _mm_cvtsi32_si128(16);
138 138
139 // ( 0, 0, 0, 0, 16, 16, 16, 16) 139 // ( 0, 0, 0, 0, 16, 16, 16, 16)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 242
243 /* SSE version of ClampX_ClampY_filter_scale() 243 /* SSE version of ClampX_ClampY_filter_scale()
244 * portable version is in core/SkBitmapProcState_matrix.h 244 * portable version is in core/SkBitmapProcState_matrix.h
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.fBitmap->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; 255 SkFixed fx;
256 256
257 SkPoint pt; 257 SkPoint pt;
258 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 258 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
259 SkIntToScalar(y) + SK_ScalarHalf, &pt); 259 SkIntToScalar(y) + SK_ScalarHalf, &pt);
260 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); 260 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
261 const unsigned maxY = s.fBitmap->height() - 1; 261 const unsigned maxY = s.fPixmap.height() - 1;
262 // compute our two Y values up front 262 // compute our two Y values up front
263 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); 263 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY);
264 // now initialize fx 264 // now initialize fx
265 fx = SkScalarToFixed(pt.fX) - (one >> 1); 265 fx = SkScalarToFixed(pt.fX) - (one >> 1);
266 266
267 // test if we don't need to apply the tile proc 267 // test if we don't need to apply the tile proc
268 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && 268 if (dx > 0 && (unsigned)(fx >> 16) <= maxX &&
269 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { 269 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) {
270 if (count >= 4) { 270 if (count >= 4) {
271 // SSE version of decal_filter_scale 271 // SSE version of decal_filter_scale
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 366
367 /* SSE version of ClampX_ClampY_nofilter_scale() 367 /* SSE version of ClampX_ClampY_nofilter_scale()
368 * portable version is in core/SkBitmapProcState_matrix.h 368 * portable version is in core/SkBitmapProcState_matrix.h
369 */ 369 */
370 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, 370 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s,
371 uint32_t xy[], int count, int x, int y) { 371 uint32_t xy[], int count, int x, int y) {
372 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | 372 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
373 SkMatrix::kScale_Mask)) == 0); 373 SkMatrix::kScale_Mask)) == 0);
374 374
375 // we store y, x, x, x, x, x 375 // we store y, x, x, x, x, x
376 const unsigned maxX = s.fBitmap->width() - 1; 376 const unsigned maxX = s.fPixmap.width() - 1;
377 SkFixed fx; 377 SkFixed fx;
378 SkPoint pt; 378 SkPoint pt;
379 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 379 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
380 SkIntToScalar(y) + SK_ScalarHalf, &pt); 380 SkIntToScalar(y) + SK_ScalarHalf, &pt);
381 fx = SkScalarToFixed(pt.fY); 381 fx = SkScalarToFixed(pt.fY);
382 const unsigned maxY = s.fBitmap->height() - 1; 382 const unsigned maxY = s.fPixmap.height() - 1;
383 *xy++ = SkClampMax(fx >> 16, maxY); 383 *xy++ = SkClampMax(fx >> 16, maxY);
384 fx = SkScalarToFixed(pt.fX); 384 fx = SkScalarToFixed(pt.fX);
385 385
386 if (0 == maxX) { 386 if (0 == maxX) {
387 // all of the following X values must be 0 387 // all of the following X values must be 0
388 memset(xy, 0, count * sizeof(uint16_t)); 388 memset(xy, 0, count * sizeof(uint16_t));
389 return; 389 return;
390 } 390 }
391 391
392 const SkFixed dx = s.fInvSx; 392 const SkFixed dx = s.fInvSx;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 s.fInvProc(s.fInvMatrix, 493 s.fInvProc(s.fInvMatrix,
494 SkIntToScalar(x) + SK_ScalarHalf, 494 SkIntToScalar(x) + SK_ScalarHalf,
495 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 495 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
496 496
497 SkFixed oneX = s.fFilterOneX; 497 SkFixed oneX = s.fFilterOneX;
498 SkFixed oneY = s.fFilterOneY; 498 SkFixed oneY = s.fFilterOneY;
499 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); 499 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1);
500 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); 500 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
501 SkFixed dx = s.fInvSx; 501 SkFixed dx = s.fInvSx;
502 SkFixed dy = s.fInvKy; 502 SkFixed dy = s.fInvKy;
503 unsigned maxX = s.fBitmap->width() - 1; 503 unsigned maxX = s.fPixmap.width() - 1;
504 unsigned maxY = s.fBitmap->height() - 1; 504 unsigned maxY = s.fPixmap.height() - 1;
505 505
506 if (count >= 2 && (maxX <= 0xFFFF)) { 506 if (count >= 2 && (maxX <= 0xFFFF)) {
507 SkFixed dx2 = dx + dx; 507 SkFixed dx2 = dx + dx;
508 SkFixed dy2 = dy + dy; 508 SkFixed dy2 = dy + dy;
509 509
510 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy); 510 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy);
511 __m128i wide_d2 = _mm_set_epi32(dx2, dy2, dx2, dy2); 511 __m128i wide_d2 = _mm_set_epi32(dx2, dy2, dx2, dy2);
512 __m128i wide_one = _mm_set_epi32(oneX, oneY, oneX, oneY); 512 __m128i wide_one = _mm_set_epi32(oneX, oneY, oneX, oneY);
513 __m128i wide_max = _mm_set_epi32(maxX, maxY, maxX, maxY); 513 __m128i wide_max = _mm_set_epi32(maxX, maxY, maxX, maxY);
514 __m128i wide_mask = _mm_set1_epi32(0xF); 514 __m128i wide_mask = _mm_set1_epi32(0xF);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 567
568 SkPoint srcPt; 568 SkPoint srcPt;
569 s.fInvProc(s.fInvMatrix, 569 s.fInvProc(s.fInvMatrix,
570 SkIntToScalar(x) + SK_ScalarHalf, 570 SkIntToScalar(x) + SK_ScalarHalf,
571 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 571 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
572 572
573 SkFixed fx = SkScalarToFixed(srcPt.fX); 573 SkFixed fx = SkScalarToFixed(srcPt.fX);
574 SkFixed fy = SkScalarToFixed(srcPt.fY); 574 SkFixed fy = SkScalarToFixed(srcPt.fY);
575 SkFixed dx = s.fInvSx; 575 SkFixed dx = s.fInvSx;
576 SkFixed dy = s.fInvKy; 576 SkFixed dy = s.fInvKy;
577 int maxX = s.fBitmap->width() - 1; 577 int maxX = s.fPixmap.width() - 1;
578 int maxY = s.fBitmap->height() - 1; 578 int maxY = s.fPixmap.height() - 1;
579 579
580 if (count >= 4 && (maxX <= 0xFFFF)) { 580 if (count >= 4 && (maxX <= 0xFFFF)) {
581 while (((size_t)xy & 0x0F) != 0) { 581 while (((size_t)xy & 0x0F) != 0) {
582 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | 582 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) |
583 SkClampMax(fx >> 16, maxX); 583 SkClampMax(fx >> 16, maxX);
584 fx += dx; 584 fx += dx;
585 fy += dy; 585 fy += dy;
586 count--; 586 count--;
587 } 587 }
588 588
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 /* SSE version of S32_D16_filter_DX_SSE2 636 /* SSE version of S32_D16_filter_DX_SSE2
637 * Definition is in section of "D16 functions for SRC == 8888" in SkBitmapProcS tate.cpp 637 * Definition is in section of "D16 functions for SRC == 8888" in SkBitmapProcS tate.cpp
638 * It combines S32_opaque_D32_filter_DX_SSE2 and SkPixel32ToPixel16 638 * It combines S32_opaque_D32_filter_DX_SSE2 and SkPixel32ToPixel16
639 */ 639 */
640 void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s, 640 void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s,
641 const uint32_t* xy, 641 const uint32_t* xy,
642 int count, uint16_t* colors) { 642 int count, uint16_t* colors) {
643 SkASSERT(count > 0 && colors != NULL); 643 SkASSERT(count > 0 && colors != NULL);
644 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); 644 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
645 SkASSERT(kN32_SkColorType == s.fBitmap->colorType()); 645 SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
646 SkASSERT(s.fBitmap->isOpaque()); 646 SkASSERT(s.fPixmap.isOpaque());
647 647
648 SkPMColor dstColor; 648 SkPMColor dstColor;
649 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); 649 const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
650 size_t rb = s.fBitmap->rowBytes(); 650 size_t rb = s.fPixmap.rowBytes();
651 uint32_t XY = *xy++; 651 uint32_t XY = *xy++;
652 unsigned y0 = XY >> 14; 652 unsigned y0 = XY >> 14;
653 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb); 653 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
654 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb); 654 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3 FFF) * rb);
655 unsigned subY = y0 & 0xF; 655 unsigned subY = y0 & 0xF;
656 656
657 // ( 0, 0, 0, 0, 0, 0, 0, 16) 657 // ( 0, 0, 0, 0, 0, 0, 0, 16)
658 __m128i sixteen = _mm_cvtsi32_si128(16); 658 __m128i sixteen = _mm_cvtsi32_si128(16);
659 659
660 // ( 0, 0, 0, 0, 16, 16, 16, 16) 660 // ( 0, 0, 0, 0, 16, 16, 16, 16)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 739
740 // Pack lower 4 16 bit values of sum into lower 4 bytes. 740 // Pack lower 4 16 bit values of sum into lower 4 bytes.
741 sum = _mm_packus_epi16(sum, zero); 741 sum = _mm_packus_epi16(sum, zero);
742 742
743 // Extract low int and store. 743 // Extract low int and store.
744 dstColor = _mm_cvtsi128_si32(sum); 744 dstColor = _mm_cvtsi128_si32(sum);
745 745
746 *colors++ = SkPixel32ToPixel16(dstColor); 746 *colors++ = SkPixel32ToPixel16(dstColor);
747 } while (--count > 0); 747 } while (--count > 0);
748 } 748 }
OLDNEW
« no previous file with comments | « src/opts/SkBitmapProcState_matrix_neon.h ('k') | src/opts/SkBitmapProcState_opts_SSSE3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698