| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
| 9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
| 10 #include "SkMessageBus.h" | 10 #include "SkMessageBus.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 SkAutoLockPixels alp(bitmap); | 28 SkAutoLockPixels alp(bitmap); |
| 29 if (!bitmap.readyToDraw()) { | 29 if (!bitmap.readyToDraw()) { |
| 30 SkDEBUGFAIL("bitmap not ready to draw!"); | 30 SkDEBUGFAIL("bitmap not ready to draw!"); |
| 31 return; | 31 return; |
| 32 } | 32 } |
| 33 | 33 |
| 34 SkColorTable* ctable = bitmap.getColorTable(); | 34 SkColorTable* ctable = bitmap.getColorTable(); |
| 35 char* dst = (char*)buffer; | 35 char* dst = (char*)buffer; |
| 36 | 36 |
| 37 uint32_t* colorTableDst = reinterpret_cast<uint32_t*>(dst); | 37 const int count = ctable->count(); |
| 38 const uint32_t* colorTableSrc = reinterpret_cast<const uint32_t*>(ctable->lo
ckColors()); | 38 |
| 39 SkConvertConfig8888Pixels(colorTableDst, 0, SkCanvas::kRGBA_Premul_Config888
8, | 39 SkDstPixelInfo dstPI; |
| 40 colorTableSrc, 0, SkCanvas::kNative_Premul_Config8
888, | 40 dstPI.fColorType = kRGBA_8888_SkColorType; |
| 41 ctable->count(), 1); | 41 dstPI.fAlphaType = kPremul_SkAlphaType; |
| 42 dstPI.fPixels = buffer; |
| 43 dstPI.fRowBytes = count * sizeof(SkPMColor); |
| 44 |
| 45 SkSrcPixelInfo srcPI; |
| 46 srcPI.fColorType = kPMColor_SkColorType; |
| 47 srcPI.fAlphaType = kPremul_SkAlphaType; |
| 48 srcPI.fPixels = ctable->lockColors(); |
| 49 srcPI.fRowBytes = count * sizeof(SkPMColor); |
| 50 |
| 51 srcPI.convertPixelsTo(&dstPI, count, 1); |
| 52 |
| 42 ctable->unlockColors(); | 53 ctable->unlockColors(); |
| 43 | 54 |
| 44 // always skip a full 256 number of entries, even if we memcpy'd fewer | 55 // always skip a full 256 number of entries, even if we memcpy'd fewer |
| 45 dst += kGrColorTableSize; | 56 dst += kGrColorTableSize; |
| 46 | 57 |
| 47 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { | 58 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { |
| 48 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); | 59 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); |
| 49 } else { | 60 } else { |
| 50 // need to trim off the extra bytes per row | 61 // need to trim off the extra bytes per row |
| 51 size_t width = bitmap.width(); | 62 size_t width = bitmap.width(); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 ct = kBGRA_8888_SkColorType; | 316 ct = kBGRA_8888_SkColorType; |
| 306 break; | 317 break; |
| 307 default: | 318 default: |
| 308 return false; | 319 return false; |
| 309 } | 320 } |
| 310 if (ctOut) { | 321 if (ctOut) { |
| 311 *ctOut = ct; | 322 *ctOut = ct; |
| 312 } | 323 } |
| 313 return true; | 324 return true; |
| 314 } | 325 } |
| OLD | NEW |