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

Side by Side Diff: src/core/SkBitmapProcState_sample.h

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/core/SkBitmapProcState_procs.h ('k') | src/core/SkBitmapProcState_shaderproc.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkUtils.h" 8 #include "SkUtils.h"
9 9
10 #if DSTSIZE==32 10 #if DSTSIZE==32
(...skipping 30 matching lines...) Expand all
41 void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s, 41 void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s,
42 const uint32_t* SK_RESTRICT xy, 42 const uint32_t* SK_RESTRICT xy,
43 int count, DSTTYPE* SK_RESTRICT colors) { 43 int count, DSTTYPE* SK_RESTRICT colors) {
44 SkASSERT(count > 0 && colors != NULL); 44 SkASSERT(count > 0 && colors != NULL);
45 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 45 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
46 SkDEBUGCODE(CHECKSTATE(s);) 46 SkDEBUGCODE(CHECKSTATE(s);)
47 47
48 #ifdef PREAMBLE 48 #ifdef PREAMBLE
49 PREAMBLE(s); 49 PREAMBLE(s);
50 #endif 50 #endif
51 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); 51 const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
52 size_t rb = s.fBitmap->rowBytes(); 52 size_t rb = s.fPixmap.rowBytes();
53 53
54 uint32_t XY; 54 uint32_t XY;
55 SRCTYPE src; 55 SRCTYPE src;
56 56
57 for (int i = (count >> 1); i > 0; --i) { 57 for (int i = (count >> 1); i > 0; --i) {
58 XY = *xy++; 58 XY = *xy++;
59 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && 59 SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
60 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); 60 (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
61 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; 61 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
62 *colors++ = RETURNDST(src); 62 *colors++ = RETURNDST(src);
63 63
64 XY = *xy++; 64 XY = *xy++;
65 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && 65 SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
66 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); 66 (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
67 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; 67 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
68 *colors++ = RETURNDST(src); 68 *colors++ = RETURNDST(src);
69 } 69 }
70 if (count & 1) { 70 if (count & 1) {
71 XY = *xy++; 71 XY = *xy++;
72 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && 72 SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
73 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); 73 (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
74 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; 74 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
75 *colors++ = RETURNDST(src); 75 *colors++ = RETURNDST(src);
76 } 76 }
77 77
78 #ifdef POSTAMBLE 78 #ifdef POSTAMBLE
79 POSTAMBLE(s); 79 POSTAMBLE(s);
80 #endif 80 #endif
81 } 81 }
82 82
83 void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, 83 void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s,
84 const uint32_t* SK_RESTRICT xy, 84 const uint32_t* SK_RESTRICT xy,
85 int count, DSTTYPE* SK_RESTRICT colors) { 85 int count, DSTTYPE* SK_RESTRICT colors) {
86 SkASSERT(count > 0 && colors != NULL); 86 SkASSERT(count > 0 && colors != NULL);
87 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); 87 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
88 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 88 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
89 SkDEBUGCODE(CHECKSTATE(s);) 89 SkDEBUGCODE(CHECKSTATE(s);)
90 90
91 #ifdef PREAMBLE 91 #ifdef PREAMBLE
92 PREAMBLE(s); 92 PREAMBLE(s);
93 #endif 93 #endif
94 const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fBitmap->getPixels(); 94 const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fPixmap.addr();
95 95
96 // buffer is y32, x16, x16, x16, x16, x16 96 // buffer is y32, x16, x16, x16, x16, x16
97 // bump srcAddr to the proper row, since we're told Y never changes 97 // bump srcAddr to the proper row, since we're told Y never changes
98 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); 98 SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height());
99 srcAddr = (const SRCTYPE*)((const char*)srcAddr + 99 srcAddr = (const SRCTYPE*)((const char*)srcAddr +
100 xy[0] * s.fBitmap->rowBytes()); 100 xy[0] * s.fPixmap.rowBytes());
101 xy += 1; 101 xy += 1;
102 102
103 SRCTYPE src; 103 SRCTYPE src;
104 104
105 if (1 == s.fBitmap->width()) { 105 if (1 == s.fPixmap.width()) {
106 src = srcAddr[0]; 106 src = srcAddr[0];
107 DSTTYPE dstValue = RETURNDST(src); 107 DSTTYPE dstValue = RETURNDST(src);
108 BITMAPPROC_MEMSET(colors, dstValue, count); 108 BITMAPPROC_MEMSET(colors, dstValue, count);
109 } else { 109 } else {
110 int i; 110 int i;
111 for (i = (count >> 2); i > 0; --i) { 111 for (i = (count >> 2); i > 0; --i) {
112 uint32_t xx0 = *xy++; 112 uint32_t xx0 = *xy++;
113 uint32_t xx1 = *xy++; 113 uint32_t xx1 = *xy++;
114 SRCTYPE x0 = srcAddr[UNPACK_PRIMARY_SHORT(xx0)]; 114 SRCTYPE x0 = srcAddr[UNPACK_PRIMARY_SHORT(xx0)];
115 SRCTYPE x1 = srcAddr[UNPACK_SECONDARY_SHORT(xx0)]; 115 SRCTYPE x1 = srcAddr[UNPACK_SECONDARY_SHORT(xx0)];
116 SRCTYPE x2 = srcAddr[UNPACK_PRIMARY_SHORT(xx1)]; 116 SRCTYPE x2 = srcAddr[UNPACK_PRIMARY_SHORT(xx1)];
117 SRCTYPE x3 = srcAddr[UNPACK_SECONDARY_SHORT(xx1)]; 117 SRCTYPE x3 = srcAddr[UNPACK_SECONDARY_SHORT(xx1)];
118 118
119 *colors++ = RETURNDST(x0); 119 *colors++ = RETURNDST(x0);
120 *colors++ = RETURNDST(x1); 120 *colors++ = RETURNDST(x1);
121 *colors++ = RETURNDST(x2); 121 *colors++ = RETURNDST(x2);
122 *colors++ = RETURNDST(x3); 122 *colors++ = RETURNDST(x3);
123 } 123 }
124 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy); 124 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy);
125 for (i = (count & 3); i > 0; --i) { 125 for (i = (count & 3); i > 0; --i) {
126 SkASSERT(*xx < (unsigned)s.fBitmap->width()); 126 SkASSERT(*xx < (unsigned)s.fPixmap.width());
127 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); 127 src = srcAddr[*xx++]; *colors++ = RETURNDST(src);
128 } 128 }
129 } 129 }
130 130
131 #ifdef POSTAMBLE 131 #ifdef POSTAMBLE
132 POSTAMBLE(s); 132 POSTAMBLE(s);
133 #endif 133 #endif
134 } 134 }
135 135
136 /////////////////////////////////////////////////////////////////////////////// 136 ///////////////////////////////////////////////////////////////////////////////
137 137
138 void MAKENAME(_filter_DX)(const SkBitmapProcState& s, 138 void MAKENAME(_filter_DX)(const SkBitmapProcState& s,
139 const uint32_t* SK_RESTRICT xy, 139 const uint32_t* SK_RESTRICT xy,
140 int count, DSTTYPE* SK_RESTRICT colors) { 140 int count, DSTTYPE* SK_RESTRICT colors) {
141 SkASSERT(count > 0 && colors != NULL); 141 SkASSERT(count > 0 && colors != NULL);
142 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); 142 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
143 SkDEBUGCODE(CHECKSTATE(s);) 143 SkDEBUGCODE(CHECKSTATE(s);)
144 144
145 #ifdef PREAMBLE 145 #ifdef PREAMBLE
146 PREAMBLE(s); 146 PREAMBLE(s);
147 #endif 147 #endif
148 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); 148 const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
149 size_t rb = s.fBitmap->rowBytes(); 149 size_t rb = s.fPixmap.rowBytes();
150 unsigned subY; 150 unsigned subY;
151 const SRCTYPE* SK_RESTRICT row0; 151 const SRCTYPE* SK_RESTRICT row0;
152 const SRCTYPE* SK_RESTRICT row1; 152 const SRCTYPE* SK_RESTRICT row1;
153 153
154 // setup row ptrs and update proc_table 154 // setup row ptrs and update proc_table
155 { 155 {
156 uint32_t XY = *xy++; 156 uint32_t XY = *xy++;
157 unsigned y0 = XY >> 14; 157 unsigned y0 = XY >> 14;
158 row0 = (const SRCTYPE*)(srcAddr + (y0 >> 4) * rb); 158 row0 = (const SRCTYPE*)(srcAddr + (y0 >> 4) * rb);
159 row1 = (const SRCTYPE*)(srcAddr + (XY & 0x3FFF) * rb); 159 row1 = (const SRCTYPE*)(srcAddr + (XY & 0x3FFF) * rb);
(...skipping 24 matching lines...) Expand all
184 void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, 184 void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s,
185 const uint32_t* SK_RESTRICT xy, 185 const uint32_t* SK_RESTRICT xy,
186 int count, DSTTYPE* SK_RESTRICT colors) { 186 int count, DSTTYPE* SK_RESTRICT colors) {
187 SkASSERT(count > 0 && colors != NULL); 187 SkASSERT(count > 0 && colors != NULL);
188 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); 188 SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
189 SkDEBUGCODE(CHECKSTATE(s);) 189 SkDEBUGCODE(CHECKSTATE(s);)
190 190
191 #ifdef PREAMBLE 191 #ifdef PREAMBLE
192 PREAMBLE(s); 192 PREAMBLE(s);
193 #endif 193 #endif
194 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); 194 const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
195 size_t rb = s.fBitmap->rowBytes(); 195 size_t rb = s.fPixmap.rowBytes();
196 196
197 do { 197 do {
198 uint32_t data = *xy++; 198 uint32_t data = *xy++;
199 unsigned y0 = data >> 14; 199 unsigned y0 = data >> 14;
200 unsigned y1 = data & 0x3FFF; 200 unsigned y1 = data & 0x3FFF;
201 unsigned subY = y0 & 0xF; 201 unsigned subY = y0 & 0xF;
202 y0 >>= 4; 202 y0 >>= 4;
203 203
204 data = *xy++; 204 data = *xy++;
205 unsigned x0 = data >> 14; 205 unsigned x0 = data >> 14;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 #ifdef POSTAMBLE 239 #ifdef POSTAMBLE
240 #undef POSTAMBLE 240 #undef POSTAMBLE
241 #endif 241 #endif
242 242
243 #undef FILTER_PROC_TYPE 243 #undef FILTER_PROC_TYPE
244 #undef GET_FILTER_TABLE 244 #undef GET_FILTER_TABLE
245 #undef GET_FILTER_ROW 245 #undef GET_FILTER_ROW
246 #undef GET_FILTER_ROW_PROC 246 #undef GET_FILTER_ROW_PROC
247 #undef GET_FILTER_PROC 247 #undef GET_FILTER_PROC
248 #undef BITMAPPROC_MEMSET 248 #undef BITMAPPROC_MEMSET
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState_procs.h ('k') | src/core/SkBitmapProcState_shaderproc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698