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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 // request for opaque, that is ok even if our initial alpha type was not | 89 // request for opaque, that is ok even if our initial alpha type was not |
| 90 // opaque. | 90 // opaque. |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| 94 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID()); | 94 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID()); |
| 95 bool decoded = m_frameGenerator->decodeAndScale( | 95 bool decoded = m_frameGenerator->decodeAndScale( |
| 96 m_data.get(), m_allDataReceived, m_frameIndex, getInfo(), pixels, | 96 m_data.get(), m_allDataReceived, m_frameIndex, getInfo(), pixels, |
| 97 rowBytes); | 97 rowBytes); |
| 98 PlatformInstrumentation::didDecodeLazyPixelRef(); | 98 PlatformInstrumentation::didDecodeLazyPixelRef(); |
| 99 if (!decoded) | |
| 100 return false; | |
| 99 | 101 |
| 100 return decoded; | 102 // Apply color space transformation if requested. Do not fail the decode if |
|
msarett1
2017/04/10 15:27:21
Why not? When is it ok to fail?
ccameron
2017/04/10 20:04:06
This is to match existing behavior -- see for inst
msarett1
2017/04/10 21:02:53
Acknowledged.
| |
| 103 // the color transform fails. | |
| 104 if (info.colorSpace() && | |
| 105 !SkColorSpace::Equals(info.colorSpace(), getInfo().colorSpace())) { | |
| 106 SkColorSpaceXform::ColorFormat xformColorFormat = | |
| 107 SkColorSpaceXform::kRGBA_8888_ColorFormat; | |
| 108 switch (info.colorType()) { | |
| 109 case kRGBA_8888_SkColorType: | |
| 110 xformColorFormat = SkColorSpaceXform::kRGBA_8888_ColorFormat; | |
| 111 break; | |
| 112 case kBGRA_8888_SkColorType: | |
| 113 xformColorFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat; | |
| 114 break; | |
| 115 case kRGBA_F16_SkColorType: | |
|
msarett1
2017/04/10 15:27:21
This case feels a little strange here. Supporting
ccameron
2017/04/10 20:04:06
(rebased on your patch instead)
| |
| 116 xformColorFormat = SkColorSpaceXform::kRGBA_F16_ColorFormat; | |
| 117 break; | |
| 118 case kRGB_565_SkColorType: | |
|
msarett1
2017/04/10 15:27:21
Let's not support 565 in Chrome. This ColorFormat
ccameron
2017/04/10 20:04:06
(rebased on your patch instead)
| |
| 119 xformColorFormat = SkColorSpaceXform::kBGR_565_ColorFormat; | |
| 120 break; | |
| 121 default: | |
| 122 // Not supported. | |
| 123 return true; | |
| 124 } | |
| 125 std::unique_ptr<SkColorSpaceXform> xform = | |
| 126 SkColorSpaceXform::New(getInfo().colorSpace(), info.colorSpace()); | |
| 127 if (!xform) | |
| 128 return true; | |
| 129 uint8_t* row = reinterpret_cast<uint8_t*>(pixels); | |
| 130 for (int y = 0; y < info.height(); y++) { | |
| 131 bool applyResult = xform->apply(xformColorFormat, row, xformColorFormat, | |
| 132 row, info.width(), info.alphaType()); | |
|
msarett1
2017/04/10 15:27:21
This won't handle alpha correctly. kOpaque will b
ccameron
2017/04/10 20:04:06
(rebased on your patch instead)
| |
| 133 DCHECK(applyResult); | |
| 134 row += rowBytes; | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 return true; | |
| 101 } | 139 } |
| 102 | 140 |
| 103 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, | 141 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, |
| 104 SkYUVColorSpace* colorSpace) const { | 142 SkYUVColorSpace* colorSpace) const { |
| 105 // YUV decoding does not currently support progressive decoding. See comment | 143 // YUV decoding does not currently support progressive decoding. See comment |
| 106 // in ImageFrameGenerator.h. | 144 // in ImageFrameGenerator.h. |
| 107 if (!m_canYUVDecode || !m_allDataReceived) | 145 if (!m_canYUVDecode || !m_allDataReceived) |
| 108 return false; | 146 return false; |
| 109 | 147 |
| 110 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", | 148 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 ImageFrameGenerator::create(SkISize::Make(size.width(), size.height()), | 193 ImageFrameGenerator::create(SkISize::Make(size.width(), size.height()), |
| 156 false, decoder->colorBehavior()); | 194 false, decoder->colorBehavior()); |
| 157 if (!frame) | 195 if (!frame) |
| 158 return nullptr; | 196 return nullptr; |
| 159 | 197 |
| 160 return new DecodingImageGenerator(frame, info, segmentReader.release(), true, | 198 return new DecodingImageGenerator(frame, info, segmentReader.release(), true, |
| 161 0); | 199 0); |
| 162 } | 200 } |
| 163 | 201 |
| 164 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |