OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int rowCount) { | 214 int rowCount) { |
215 SkASSERT(bytesPerRow <= srcRB); | 215 SkASSERT(bytesPerRow <= srcRB); |
216 SkASSERT(bytesPerRow <= dstRB); | 216 SkASSERT(bytesPerRow <= dstRB); |
217 for (int i = 0; i < rowCount; ++i) { | 217 for (int i = 0; i < rowCount; ++i) { |
218 memcpy(dst, src, bytesPerRow); | 218 memcpy(dst, src, bytesPerRow); |
219 dst = (char*)dst + dstRB; | 219 dst = (char*)dst + dstRB; |
220 src = (const char*)src + srcRB; | 220 src = (const char*)src + srcRB; |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
| 224 static bool info2config8888(const SkImageInfo& info, SkCanvas::Config8888* confi
g) { |
| 225 bool pre; |
| 226 switch (info.alphaType()) { |
| 227 case kPremul_SkAlphaType: |
| 228 case kOpaque_SkAlphaType: |
| 229 pre = true; |
| 230 break; |
| 231 case kUnpremul_SkAlphaType: |
| 232 pre = false; |
| 233 break; |
| 234 default: |
| 235 return false; |
| 236 } |
| 237 switch (info.colorType()) { |
| 238 case kRGBA_8888_SkColorType: |
| 239 *config = pre ? SkCanvas::kRGBA_Premul_Config8888 : SkCanvas::kRGBA_
Unpremul_Config8888; |
| 240 return true; |
| 241 case kBGRA_8888_SkColorType: |
| 242 *config = pre ? SkCanvas::kBGRA_Premul_Config8888 : SkCanvas::kBGRA_
Unpremul_Config8888; |
| 243 return true; |
| 244 default: |
| 245 return false; |
| 246 } |
| 247 } |
| 248 |
| 249 // TODO: make this guy real, and not rely on legacy config8888 utility |
224 #include "SkConfig8888.h" | 250 #include "SkConfig8888.h" |
225 | |
226 static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstR
owBytes, | 251 static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstR
owBytes, |
227 const SkImageInfo& srcInfo, const void* srcPixels, size_
t srcRowBytes) { | 252 const SkImageInfo& srcInfo, const void* srcPixels, size_
t srcRowBytes) { |
228 if (srcInfo.dimensions() != dstInfo.dimensions()) { | 253 if (srcInfo.dimensions() != dstInfo.dimensions()) { |
229 return false; | 254 return false; |
230 } | 255 } |
231 if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) { | 256 if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) { |
232 SkDstPixelInfo dstPI; | 257 SkCanvas::Config8888 srcConfig, dstConfig; |
233 dstPI.fColorType = dstInfo.colorType(); | 258 if (!info2config8888(srcInfo, &srcConfig) || !info2config8888(dstInfo, &
dstConfig)) { |
234 dstPI.fAlphaType = dstInfo.alphaType(); | 259 return false; |
235 dstPI.fPixels = dstPixels; | 260 } |
236 dstPI.fRowBytes = dstRowBytes; | 261 SkConvertConfig8888Pixels((uint32_t*)dstPixels, dstRowBytes, dstConfig, |
237 | 262 (const uint32_t*)srcPixels, srcRowBytes, srcCo
nfig, |
238 SkSrcPixelInfo srcPI; | 263 srcInfo.width(), srcInfo.height()); |
239 srcPI.fColorType = srcInfo.colorType(); | 264 return true; |
240 srcPI.fAlphaType = srcInfo.alphaType(); | |
241 srcPI.fPixels = srcPixels; | |
242 srcPI.fRowBytes = srcRowBytes; | |
243 | |
244 return srcPI.convertPixelsTo(&dstPI, srcInfo.width(), srcInfo.height()); | |
245 } | 265 } |
246 if (srcInfo.colorType() == dstInfo.colorType()) { | 266 if (srcInfo.colorType() == dstInfo.colorType()) { |
247 switch (srcInfo.colorType()) { | 267 switch (srcInfo.colorType()) { |
248 case kRGB_565_SkColorType: | 268 case kRGB_565_SkColorType: |
249 case kAlpha_8_SkColorType: | 269 case kAlpha_8_SkColorType: |
250 break; | 270 break; |
251 case kARGB_4444_SkColorType: | 271 case kARGB_4444_SkColorType: |
252 if (srcInfo.alphaType() != dstInfo.alphaType()) { | 272 if (srcInfo.alphaType() != dstInfo.alphaType()) { |
253 return false; | 273 return false; |
254 } | 274 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 paint.getStyle() != SkPaint::kFill_Style || | 539 paint.getStyle() != SkPaint::kFill_Style || |
520 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | 540 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { |
521 // turn off lcd | 541 // turn off lcd |
522 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | 542 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; |
523 flags->fHinting = paint.getHinting(); | 543 flags->fHinting = paint.getHinting(); |
524 return true; | 544 return true; |
525 } | 545 } |
526 // we're cool with the paint as is | 546 // we're cool with the paint as is |
527 return false; | 547 return false; |
528 } | 548 } |
OLD | NEW |