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 const int count = ctable->count(); | 37 uint32_t* colorTableDst = reinterpret_cast<uint32_t*>(dst); |
38 | 38 const uint32_t* colorTableSrc = reinterpret_cast<const uint32_t*>(ctable->lo
ckColors()); |
39 SkDstPixelInfo dstPI; | 39 SkConvertConfig8888Pixels(colorTableDst, 0, SkCanvas::kRGBA_Premul_Config888
8, |
40 dstPI.fColorType = kRGBA_8888_SkColorType; | 40 colorTableSrc, 0, SkCanvas::kNative_Premul_Config8
888, |
41 dstPI.fAlphaType = kPremul_SkAlphaType; | 41 ctable->count(), 1); |
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 | |
53 ctable->unlockColors(); | 42 ctable->unlockColors(); |
54 | 43 |
55 // always skip a full 256 number of entries, even if we memcpy'd fewer | 44 // always skip a full 256 number of entries, even if we memcpy'd fewer |
56 dst += kGrColorTableSize; | 45 dst += kGrColorTableSize; |
57 | 46 |
58 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { | 47 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { |
59 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); | 48 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); |
60 } else { | 49 } else { |
61 // need to trim off the extra bytes per row | 50 // need to trim off the extra bytes per row |
62 size_t width = bitmap.width(); | 51 size_t width = bitmap.width(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ct = kBGRA_8888_SkColorType; | 305 ct = kBGRA_8888_SkColorType; |
317 break; | 306 break; |
318 default: | 307 default: |
319 return false; | 308 return false; |
320 } | 309 } |
321 if (ctOut) { | 310 if (ctOut) { |
322 *ctOut = ct; | 311 *ctOut = ct; |
323 } | 312 } |
324 return true; | 313 return true; |
325 } | 314 } |
OLD | NEW |