| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
| 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 "SkPDFImage.h" | 8 #include "SkPDFImage.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, 0, 0, 0); | 368 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, 0, 0, 0); |
| 369 } else { | 369 } else { |
| 370 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, | 370 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, |
| 371 r / count, g / count, b / count); | 371 r / count, g / count, b / count); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap, | 375 static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap, |
| 376 const SkIRect& srcRect) { | 376 const SkIRect& srcRect) { |
| 377 SkBitmap outBitmap; | 377 SkBitmap outBitmap; |
| 378 SkAssertResult(outBitmap.allocPixels( | 378 outBitmap.allocPixels(bitmap.info().makeWH(srcRect.width(), srcRect.height()
)); |
| 379 bitmap.info().makeWH(srcRect.width(), srcRect.height()))); | |
| 380 int dstRow = 0; | 379 int dstRow = 0; |
| 381 | 380 |
| 382 SkAutoLockPixels outBitmapPixelLock(outBitmap); | 381 SkAutoLockPixels outBitmapPixelLock(outBitmap); |
| 383 SkAutoLockPixels bitmapPixelLock(bitmap); | 382 SkAutoLockPixels bitmapPixelLock(bitmap); |
| 384 switch (bitmap.colorType()) { | 383 switch (bitmap.colorType()) { |
| 385 case kARGB_4444_SkColorType: { | 384 case kARGB_4444_SkColorType: { |
| 386 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { | 385 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { |
| 387 uint16_t* dst = outBitmap.getAddr16(0, dstRow); | 386 uint16_t* dst = outBitmap.getAddr16(0, dstRow); |
| 388 uint16_t* src = bitmap.getAddr16(0, y); | 387 uint16_t* src = bitmap.getAddr16(0, y); |
| 389 for (int x = srcRect.fLeft; x < srcRect.fRight; x++) { | 388 for (int x = srcRect.fLeft; x < srcRect.fRight; x++) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 SkPicture::EncodeBitmap encoder) { | 709 SkPicture::EncodeBitmap encoder) { |
| 711 if (SkIRect::MakeWH(bitmap.width(), bitmap.height()) == subset) { | 710 if (SkIRect::MakeWH(bitmap.width(), bitmap.height()) == subset) { |
| 712 SkAutoTUnref<SkData> encodedData(ref_encoded_data(bitmap)); | 711 SkAutoTUnref<SkData> encodedData(ref_encoded_data(bitmap)); |
| 713 if (is_jfif_jpeg(encodedData)) { | 712 if (is_jfif_jpeg(encodedData)) { |
| 714 return SkNEW_ARGS(PDFJPEGImage, | 713 return SkNEW_ARGS(PDFJPEGImage, |
| 715 (encodedData, bitmap.width(), bitmap.height())); | 714 (encodedData, bitmap.width(), bitmap.height())); |
| 716 } | 715 } |
| 717 } | 716 } |
| 718 return SkPDFImage::CreateImage(bitmap, subset, encoder); | 717 return SkPDFImage::CreateImage(bitmap, subset, encoder); |
| 719 } | 718 } |
| OLD | NEW |