| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 DecodingImageGenerator::~DecodingImageGenerator() | 49 DecodingImageGenerator::~DecodingImageGenerator() |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 SkData* DecodingImageGenerator::onRefEncodedData(GrContext* ctx) | 53 SkData* DecodingImageGenerator::onRefEncodedData(GrContext* ctx) |
| 54 { | 54 { |
| 55 TRACE_EVENT0("blink", "DecodingImageGenerator::refEncodedData"); | 55 TRACE_EVENT0("blink", "DecodingImageGenerator::refEncodedData"); |
| 56 | 56 |
| 57 return m_allDataReceived ? m_data->getAsSkData().leakRef() : nullptr; | 57 // The GPU only wants the data if it has all been received, since the GPU |
| 58 // only wants a complete texture. getAsSkData() may require copying, so |
| 59 // skip it and just return nullptr to avoid a slowdown. (See |
| 60 // crbug.com/568016 for details about such a slowdown.) |
| 61 // TODO (scroggo): Stop relying on the internal knowledge of how Skia uses |
| 62 // this. skbug.com/5485 |
| 63 if (ctx && !m_allDataReceived) |
| 64 return nullptr; |
| 65 |
| 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 |
| 68 // potentially need to decode the partial image in order to re-encode it.) |
| 69 return m_data->getAsSkData().leakRef(); |
| 58 } | 70 } |
| 59 | 71 |
| 60 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) |
| 61 { | 73 { |
| 62 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)); |
| 63 | 75 |
| 64 // 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. |
| 65 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) | 77 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) |
| 66 return false; | 78 return false; |
| 67 | 79 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh
t()); | 138 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh
t()); |
| 127 | 139 |
| 128 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), false); | 140 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), false); |
| 129 if (!frame) | 141 if (!frame) |
| 130 return 0; | 142 return 0; |
| 131 | 143 |
| 132 return new DecodingImageGenerator(frame, info, segmentReader.release(), true
, 0); | 144 return new DecodingImageGenerator(frame, info, segmentReader.release(), true
, 0); |
| 133 } | 145 } |
| 134 | 146 |
| 135 } // namespace blink | 147 } // namespace blink |
| OLD | NEW |