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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // this. skbug.com/5485 | 63 // this. skbug.com/5485 |
| 64 if (ctx && !m_allDataReceived) | 64 if (ctx && !m_allDataReceived) |
| 65 return nullptr; | 65 return nullptr; |
| 66 | 66 |
| 67 // Other clients are serializers, which want the data even if it requires | 67 // Other clients are serializers, which want the data even if it requires |
| 68 // copying, and even if the data is incomplete. (Otherwise they would | 68 // copying, and even if the data is incomplete. (Otherwise they would |
| 69 // potentially need to decode the partial image in order to re-encode it.) | 69 // potentially need to decode the partial image in order to re-encode it.) |
| 70 return m_data->getAsSkData().release(); | 70 return m_data->getAsSkData().release(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, | 73 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& dstInfo, |
| 74 void* pixels, | 74 void* pixels, |
| 75 size_t rowBytes, | 75 size_t rowBytes, |
| 76 SkPMColor table[], | 76 SkPMColor*, |
| 77 int* tableCount) { | 77 int*) { |
| 78 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", | 78 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", |
| 79 static_cast<int>(m_frameIndex)); | 79 static_cast<int>(m_frameIndex)); |
| 80 | 80 |
| 81 // Implementation doesn't support scaling yet, so make sure we're not given a | 81 // Implementation doesn't support scaling yet, so make sure we're not given a |
| 82 // different size. | 82 // different size. |
| 83 if (info.width() != getInfo().width() || info.height() != getInfo().height()) | 83 if (dstInfo.width() != getInfo().width() || |
|
scroggo_chromium
2017/04/07 18:06:06
nit: I think you originally changed "info" to "dst
msarett1
2017/04/10 14:42:45
Acknowledged.
Moving the xform more logic to this
| |
| 84 return false; | 84 dstInfo.height() != getInfo().height()) { |
| 85 | |
| 86 if (info.colorType() != getInfo().colorType()) { | |
| 87 // blink::ImageFrame may have changed the owning SkBitmap to | |
| 88 // kOpaque_SkAlphaType after fully decoding the image frame, so if we see a | |
| 89 // request for opaque, that is ok even if our initial alpha type was not | |
| 90 // opaque. | |
| 91 return false; | 85 return false; |
| 92 } | 86 } |
| 93 | 87 |
| 88 if (kN32_SkColorType != dstInfo.colorType()) { | |
|
scroggo_chromium
2017/04/07 18:06:05
This change also appears to be unnecessary, I'm gu
msarett1
2017/04/10 14:42:45
Yes, but I think this is more clear. Regardless o
scroggo_chromium
2017/04/10 17:31:23
Fair enough.
| |
| 89 return false; | |
| 90 } | |
| 91 | |
| 92 // Skip the check for alphaType. blink::ImageFrame may have changed the | |
| 93 // owning SkBitmap to kOpaque_SkAlphaType after fully decoding the image | |
| 94 // frame, so if we see a request for opaque, that is ok even if our initial | |
| 95 // alpha type was not opaque. | |
| 96 | |
| 94 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID()); | 97 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID()); |
| 95 bool decoded = m_frameGenerator->decodeAndScale( | 98 bool decoded = m_frameGenerator->decodeAndScale( |
| 96 m_data.get(), m_allDataReceived, m_frameIndex, getInfo(), pixels, | 99 m_data.get(), m_allDataReceived, m_frameIndex, dstInfo, pixels, rowBytes); |
| 97 rowBytes); | |
| 98 PlatformInstrumentation::didDecodeLazyPixelRef(); | 100 PlatformInstrumentation::didDecodeLazyPixelRef(); |
| 99 | 101 |
| 100 return decoded; | 102 return decoded; |
|
scroggo_chromium
2017/04/07 18:06:06
One difference between doing the conversion here v
msarett1
2017/04/10 14:42:45
I think it should not (for now). We are typically
| |
| 101 } | 103 } |
| 102 | 104 |
| 103 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, | 105 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, |
| 104 SkYUVColorSpace* colorSpace) const { | 106 SkYUVColorSpace* colorSpace) const { |
| 105 // YUV decoding does not currently support progressive decoding. See comment | 107 // YUV decoding does not currently support progressive decoding. See comment |
| 106 // in ImageFrameGenerator.h. | 108 // in ImageFrameGenerator.h. |
| 107 if (!m_canYUVDecode || !m_allDataReceived) | 109 if (!m_canYUVDecode || !m_allDataReceived) |
| 108 return false; | 110 return false; |
| 109 | 111 |
| 110 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", | 112 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 ColorBehavior::transformToGlobalTarget()); | 147 ColorBehavior::transformToGlobalTarget()); |
| 146 if (!decoder || !decoder->isSizeAvailable()) | 148 if (!decoder || !decoder->isSizeAvailable()) |
| 147 return nullptr; | 149 return nullptr; |
| 148 | 150 |
| 149 const IntSize size = decoder->size(); | 151 const IntSize size = decoder->size(); |
| 150 const SkImageInfo info = | 152 const SkImageInfo info = |
| 151 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType, | 153 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType, |
| 152 decoder->colorSpaceForSkImages()); | 154 decoder->colorSpaceForSkImages()); |
| 153 | 155 |
| 154 RefPtr<ImageFrameGenerator> frame = | 156 RefPtr<ImageFrameGenerator> frame = |
| 155 ImageFrameGenerator::create(SkISize::Make(size.width(), size.height()), | 157 ImageFrameGenerator::create(info, false, decoder->colorBehavior()); |
| 156 false, decoder->colorBehavior()); | |
| 157 if (!frame) | 158 if (!frame) |
| 158 return nullptr; | 159 return nullptr; |
| 159 | 160 |
| 160 return new DecodingImageGenerator(frame, info, segmentReader.release(), true, | 161 return new DecodingImageGenerator(frame, info, segmentReader.release(), true, |
| 161 0); | 162 0); |
| 162 } | 163 } |
| 163 | 164 |
| 164 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |