OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 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) { |
130 uint32_t* dst32 = (uint32_t*)dst; | 130 uint32_t* dst32 = (uint32_t*)dst; |
131 const uint8_t* src8 = (const uint8_t*)src; | 131 const uint8_t* src8 = (const uint8_t*)src; |
132 | 132 |
133 for (int y = 0; y < h; ++y) { | 133 for (int y = 0; y < h; ++y) { |
134 for (int x = 0; x < w; ++x) { | 134 for (int x = 0; x < w; ++x) { |
135 dst32[x] = SkPackARGB32(0xFF, src8[x], src8[x], src8[x]); | 135 dst32[x] = SkPackARGB32(0xFF, src8[x], src8[x], src8[x]); |
136 } | 136 } |
137 dst32 = (uint32_t*)((char*)dst32 + dstRB); | 137 dst32 = (uint32_t*)((char*)dst32 + dstRB); |
138 src8 += srcRB; | 138 src8 += srcRB; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 static void copy_32_to_g8(void* dst, size_t dstRB, const void* src, size_t srcRB
, | 142 static void copy_32_to_g8(void* dst, size_t dstRB, const void* src, size_t srcRB
, |
(...skipping 23 matching lines...) Expand all Loading... |
166 dst8 += dstRB; | 166 dst8 += dstRB; |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
dstRB, | 170 bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
dstRB, |
171 const SkImageInfo& srcInfo, const void* srcPixels,
size_t srcRB, | 171 const SkImageInfo& srcInfo, const void* srcPixels,
size_t srcRB, |
172 SkColorTable* ctable) { | 172 SkColorTable* ctable) { |
173 if (srcInfo.dimensions() != dstInfo.dimensions()) { | 173 if (srcInfo.dimensions() != dstInfo.dimensions()) { |
174 return false; | 174 return false; |
175 } | 175 } |
176 | 176 |
177 const int width = srcInfo.width(); | 177 const int width = srcInfo.width(); |
178 const int height = srcInfo.height(); | 178 const int height = srcInfo.height(); |
179 | 179 |
180 // Do the easiest one first : both configs are equal | 180 // Do the easiest one first : both configs are equal |
181 if ((srcInfo == dstInfo) && !ctable) { | 181 if ((srcInfo == dstInfo) && !ctable) { |
182 size_t bytes = width * srcInfo.bytesPerPixel(); | 182 size_t bytes = width * srcInfo.bytesPerPixel(); |
183 for (int y = 0; y < height; ++y) { | 183 for (int y = 0; y < height; ++y) { |
184 memcpy(dstPixels, srcPixels, bytes); | 184 memcpy(dstPixels, srcPixels, bytes); |
185 srcPixels = (const char*)srcPixels + srcRB; | 185 srcPixels = (const char*)srcPixels + srcRB; |
186 dstPixels = (char*)dstPixels + dstRB; | 186 dstPixels = (char*)dstPixels + dstRB; |
187 } | 187 } |
188 return true; | 188 return true; |
189 } | 189 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 296 } |
297 | 297 |
298 SkPaint paint; | 298 SkPaint paint; |
299 paint.setDither(true); | 299 paint.setDither(true); |
300 | 300 |
301 canvas->clear(0); | 301 canvas->clear(0); |
302 canvas->drawBitmap(bm, 0, 0, &paint); | 302 canvas->drawBitmap(bm, 0, 0, &paint); |
303 return true; | 303 return true; |
304 } | 304 } |
305 } | 305 } |
306 | |
OLD | NEW |