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

Side by Side Diff: src/core/SkConfig8888.cpp

Issue 1197713003: Move rect_memcopy from helper to global static. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/SkConfig8888.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 2014 Google Inc. 2 * Copyright 2014 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkConfig8888.h" 10 #include "SkConfig8888.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 size_t srcInc = fRowBytes >> 2; 119 size_t srcInc = fRowBytes >> 2;
120 size_t dstInc = dst->fRowBytes >> 2; 120 size_t dstInc = dst->fRowBytes >> 2;
121 for (int y = 0; y < height; ++y) { 121 for (int y = 0; y < height; ++y) {
122 proc(dstP, srcP, width); 122 proc(dstP, srcP, width);
123 dstP += dstInc; 123 dstP += dstInc;
124 srcP += srcInc; 124 srcP += srcInc;
125 } 125 }
126 return true; 126 return true;
127 } 127 }
128 128
129 static void rect_memcpy(void* dst, size_t dstRB, const void* src, size_t srcRB, size_t bytesPerRow,
130 int rowCount) {
131 SkASSERT(bytesPerRow <= srcRB);
132 SkASSERT(bytesPerRow <= dstRB);
133 for (int i = 0; i < rowCount; ++i) {
134 memcpy(dst, src, bytesPerRow);
135 dst = (char*)dst + dstRB;
136 src = (const char*)src + srcRB;
137 }
138 }
139
140 static void copy_g8_to_32(void* dst, size_t dstRB, const void* src, size_t srcRB , int w, int h) { 129 static void copy_g8_to_32(void* dst, size_t dstRB, const void* src, size_t srcRB , int w, int h) {
141 uint32_t* dst32 = (uint32_t*)dst; 130 uint32_t* dst32 = (uint32_t*)dst;
142 const uint8_t* src8 = (const uint8_t*)src; 131 const uint8_t* src8 = (const uint8_t*)src;
143 132
144 for (int y = 0; y < h; ++y) { 133 for (int y = 0; y < h; ++y) {
145 for (int x = 0; x < w; ++x) { 134 for (int x = 0; x < w; ++x) {
146 dst32[x] = SkPackARGB32(0xFF, src8[x], src8[x], src8[x]); 135 dst32[x] = SkPackARGB32(0xFF, src8[x], src8[x], src8[x]);
147 } 136 }
148 dst32 = (uint32_t*)((char*)dst32 + dstRB); 137 dst32 = (uint32_t*)((char*)dst32 + dstRB);
149 src8 += srcRB; 138 src8 += srcRB;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 break; 204 break;
216 case kIndex_8_SkColorType: 205 case kIndex_8_SkColorType:
217 case kARGB_4444_SkColorType: 206 case kARGB_4444_SkColorType:
218 if (srcInfo.alphaType() != dstInfo.alphaType()) { 207 if (srcInfo.alphaType() != dstInfo.alphaType()) {
219 return false; 208 return false;
220 } 209 }
221 break; 210 break;
222 default: 211 default:
223 return false; 212 return false;
224 } 213 }
225 rect_memcpy(dstPixels, dstRB, srcPixels, srcRB, width * srcInfo.bytesPer Pixel(), height); 214 SkRectMemcpy(dstPixels, dstRB, srcPixels, srcRB, width * srcInfo.bytesPe rPixel(), height);
226 return true; 215 return true;
227 } 216 }
228 217
229 /* 218 /*
230 * Begin section where we try to change colorTypes along the way. Not all c ombinations 219 * Begin section where we try to change colorTypes along the way. Not all c ombinations
231 * are supported. 220 * are supported.
232 */ 221 */
233 222
234 if (kGray_8_SkColorType == srcInfo.colorType() && 4 == dstInfo.bytesPerPixel ()) { 223 if (kGray_8_SkColorType == srcInfo.colorType() && 4 == dstInfo.bytesPerPixel ()) {
235 copy_g8_to_32(dstPixels, dstRB, srcPixels, srcRB, width, height); 224 copy_g8_to_32(dstPixels, dstRB, srcPixels, srcRB, width, height);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 286
298 SkPaint paint; 287 SkPaint paint;
299 paint.setDither(true); 288 paint.setDither(true);
300 289
301 canvas->clear(0); 290 canvas->clear(0);
302 canvas->drawBitmap(bm, 0, 0, &paint); 291 canvas->drawBitmap(bm, 0, 0, &paint);
303 return true; 292 return true;
304 } 293 }
305 } 294 }
306 295
OLDNEW
« no previous file with comments | « src/core/SkConfig8888.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698