| 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 | 9 |
| 10 /* Fill out buffer with the compressed format Ganesh expects from a colortable | 10 /* Fill out buffer with the compressed format Ganesh expects from a colortable |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 SkAutoLockPixels alp(bitmap); | 24 SkAutoLockPixels alp(bitmap); |
| 25 if (!bitmap.readyToDraw()) { | 25 if (!bitmap.readyToDraw()) { |
| 26 SkDEBUGFAIL("bitmap not ready to draw!"); | 26 SkDEBUGFAIL("bitmap not ready to draw!"); |
| 27 return; | 27 return; |
| 28 } | 28 } |
| 29 | 29 |
| 30 SkColorTable* ctable = bitmap.getColorTable(); | 30 SkColorTable* ctable = bitmap.getColorTable(); |
| 31 char* dst = (char*)buffer; | 31 char* dst = (char*)buffer; |
| 32 | 32 |
| 33 memcpy(dst, ctable->lockColors(), ctable->count() * sizeof(SkPMColor)); | 33 memcpy(dst, ctable->lockColors(), ctable->count() * sizeof(SkPMColor)); |
| 34 ctable->unlockColors(); | 34 ctable->unlockColors(false); |
| 35 | 35 |
| 36 // always skip a full 256 number of entries, even if we memcpy'd fewer | 36 // always skip a full 256 number of entries, even if we memcpy'd fewer |
| 37 dst += kGrColorTableSize; | 37 dst += kGrColorTableSize; |
| 38 | 38 |
| 39 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { | 39 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { |
| 40 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); | 40 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); |
| 41 } else { | 41 } else { |
| 42 // need to trim off the extra bytes per row | 42 // need to trim off the extra bytes per row |
| 43 size_t width = bitmap.width(); | 43 size_t width = bitmap.width(); |
| 44 size_t rowBytes = bitmap.rowBytes(); | 44 size_t rowBytes = bitmap.rowBytes(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return kRGB_565_GrPixelConfig; | 207 return kRGB_565_GrPixelConfig; |
| 208 case SkBitmap::kARGB_4444_Config: | 208 case SkBitmap::kARGB_4444_Config: |
| 209 return kRGBA_4444_GrPixelConfig; | 209 return kRGBA_4444_GrPixelConfig; |
| 210 case SkBitmap::kARGB_8888_Config: | 210 case SkBitmap::kARGB_8888_Config: |
| 211 return kSkia8888_GrPixelConfig; | 211 return kSkia8888_GrPixelConfig; |
| 212 default: | 212 default: |
| 213 // kNo_Config, kA1_Config missing | 213 // kNo_Config, kA1_Config missing |
| 214 return kUnknown_GrPixelConfig; | 214 return kUnknown_GrPixelConfig; |
| 215 } | 215 } |
| 216 } | 216 } |
| OLD | NEW |