| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) | 62 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) |
| 63 return false; | 63 return false; |
| 64 | 64 |
| 65 if (info.colorType() != getInfo().colorType()) { | 65 if (info.colorType() != getInfo().colorType()) { |
| 66 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA
lphaType after fully decoding the image frame, | 66 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA
lphaType after fully decoding the image frame, |
| 67 // so if we see a request for opaque, that is ok even if our initial alp
ha type was not opaque. | 67 // so if we see a request for opaque, that is ok even if our initial alp
ha type was not opaque. |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 | 70 |
| 71 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); | 71 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); |
| 72 bool decoded = m_frameGenerator->decodeAndScale(m_frameIndex, getInfo(), pix
els, rowBytes); | 72 bool decoded = m_frameGenerator->decodeAndScale(m_frameIndex, getInfo(), pix
els, rowBytes, table, tableCount); |
| 73 PlatformInstrumentation::didDecodeLazyPixelRef(); | 73 PlatformInstrumentation::didDecodeLazyPixelRef(); |
| 74 | 74 |
| 75 return decoded; | 75 return decoded; |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3], SkYUVColorSpace* colorSpace) | 78 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3], SkYUVColorSpace* colorSpace) |
| 79 { | 79 { |
| 80 if (!m_canYUVDecode) | 80 if (!m_canYUVDecode) |
| 81 return false; | 81 return false; |
| 82 | 82 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 105 // we only need the size, it doesn't really matter about premul or not, or g
amma settings. | 105 // we only need the size, it doesn't really matter about premul or not, or g
amma settings. |
| 106 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*buffer.get(), ImageDeco
der::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 106 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*buffer.get(), ImageDeco
der::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 107 if (!decoder) | 107 if (!decoder) |
| 108 return 0; | 108 return 0; |
| 109 | 109 |
| 110 decoder->setData(buffer.get(), true); | 110 decoder->setData(buffer.get(), true); |
| 111 if (!decoder->isSizeAvailable()) | 111 if (!decoder->isSizeAvailable()) |
| 112 return 0; | 112 return 0; |
| 113 | 113 |
| 114 const IntSize size = decoder->size(); | 114 const IntSize size = decoder->size(); |
| 115 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh
t()); | 115 const SkImageInfo info = decoder->canDecodeTo(0, ImageFrame::Index8) |
| 116 ? SkImageInfo::Make(size.width(), size.height(), kIndex_8_SkColorType, k
Premul_SkAlphaType) |
| 117 : SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 116 | 118 |
| 117 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), buffer, true, false); | 119 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), buffer, true, false); |
| 118 if (!frame) | 120 if (!frame) |
| 119 return 0; | 121 return 0; |
| 120 | 122 |
| 121 return new DecodingImageGenerator(frame, info, 0); | 123 return new DecodingImageGenerator(frame, info, 0); |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |