Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // skip it and just return nullptr to avoid a slowdown. (See | 59 // skip it and just return nullptr to avoid a slowdown. (See |
| 60 // crbug.com/568016 for details about such a slowdown.) | 60 // crbug.com/568016 for details about such a slowdown.) |
| 61 // TODO (scroggo): Stop relying on the internal knowledge of how Skia uses | 61 // TODO (scroggo): Stop relying on the internal knowledge of how Skia uses |
| 62 // this. skbug.com/5485 | 62 // this. skbug.com/5485 |
| 63 if (ctx && !m_allDataReceived) | 63 if (ctx && !m_allDataReceived) |
| 64 return nullptr; | 64 return nullptr; |
| 65 | 65 |
| 66 // Other clients are serializers, which want the data even if it requires | 66 // Other clients are serializers, which want the data even if it requires |
| 67 // copying, and even if the data is incomplete. (Otherwise they would | 67 // copying, and even if the data is incomplete. (Otherwise they would |
| 68 // potentially need to decode the partial image in order to re-encode it.) | 68 // potentially need to decode the partial image in order to re-encode it.) |
| 69 return m_data->getAsSkData().leakRef(); | 69 return m_data->getAsSkData().release(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor table[], int* tableCount) | 72 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor table[], int* tableCount) |
| 73 { | 73 { |
| 74 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", st atic_cast<int>(m_frameIndex)); | 74 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", st atic_cast<int>(m_frameIndex)); |
| 75 | 75 |
| 76 // Implementation doesn't support scaling yet so make sure we're not given a different size. | 76 // Implementation doesn't support scaling yet so make sure we're not given a different size. |
| 77 if (info.width() != getInfo().width() || info.height() != getInfo().height() ) | 77 if (info.width() != getInfo().width() || info.height() != getInfo().height() ) |
| 78 return false; | 78 return false; |
| 79 | 79 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 | 120 |
| 121 SkImageGenerator* DecodingImageGenerator::create(SkData* data) | 121 SkImageGenerator* DecodingImageGenerator::create(SkData* data) |
| 122 { | 122 { |
| 123 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since | 123 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since |
| 124 // we only need the size, it doesn't really matter about premul or not, or g amma settings. | 124 // we only need the size, it doesn't really matter about premul or not, or g amma settings. |
| 125 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecoder::d etermineImageType(static_cast<const char*>(data->data()), data->size()), | 125 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecoder::d etermineImageType(static_cast<const char*>(data->data()), data->size()), |
| 126 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied); | 126 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied); |
| 127 if (!decoder) | 127 if (!decoder) |
| 128 return 0; | 128 return 0; |
| 129 | 129 |
| 130 // Blink does not know Skia has already adopted |data|. | 130 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(sk_sp< SkData>(data)); |
|
f(malita)
2016/08/03 19:23:05
Shouldn't this be sk_ref_sp(data)?
The prev varia
bungeman-chromium
2016/08/03 19:37:54
After taking a closer look, I think you're right h
| |
| 131 WTF::adopted(data); | |
|
f(malita)
2016/08/03 19:23:04
Nice to see this gone!
| |
| 132 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(data); | |
| 133 decoder->setData(segmentReader.get(), true); | 131 decoder->setData(segmentReader.get(), true); |
| 134 if (!decoder->isSizeAvailable()) | 132 if (!decoder->isSizeAvailable()) |
| 135 return 0; | 133 return 0; |
| 136 | 134 |
| 137 const IntSize size = decoder->size(); | 135 const IntSize size = decoder->size(); |
| 138 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t()); | 136 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t()); |
| 139 | 137 |
| 140 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false); | 138 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false); |
| 141 if (!frame) | 139 if (!frame) |
| 142 return 0; | 140 return 0; |
| 143 | 141 |
| 144 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0); | 142 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0); |
| 145 } | 143 } |
| 146 | 144 |
| 147 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |