Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #include "config.h" | |
| 27 #include "core/platform/graphics/DecodingImageGenerator.h" | |
| 28 | |
| 29 #include "SkData.h" | |
| 30 #include "SkImageInfo.h" | |
| 31 #include "core/platform/graphics/ImageFrameGenerator.h" | |
| 32 #include "platform/SharedBuffer.h" | |
| 33 #include "platform/TraceEvent.h" | |
| 34 | |
| 35 namespace WebCore { | |
| 36 | |
| 37 DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> f rameGenerator, const SkImageInfo& info, size_t index) | |
| 38 : m_frameGenerator(frameGenerator) | |
| 39 , m_imageInfo(info) | |
| 40 , m_frameIndex(index) | |
| 41 { | |
| 42 } | |
| 43 | |
| 44 DecodingImageGenerator::~DecodingImageGenerator() | |
| 45 { | |
| 46 } | |
| 47 | |
| 48 SkData* DecodingImageGenerator::refEncodedData() | |
| 49 { | |
| 50 // FIXME: If the image has been clipped or scaled, do not return the origina l | |
| 51 // encoded data, since on playback it will not be known how the clipping/sca ling | |
| 52 // was done. | |
| 53 RefPtr<SharedBuffer> buffer = 0; | |
| 54 bool allDataReceived = false; | |
| 55 m_frameGenerator->copyData(&buffer, &allDataReceived); | |
| 56 if (buffer && allDataReceived) { | |
| 57 SkData* skdata = SkData::NewWithCopy(buffer->data(), buffer->size()); | |
|
Stephen White
2013/12/05 21:52:14
Nit: no need for the temporary; could just be
ret
Alpha Left Google
2013/12/08 00:30:11
Done.
| |
| 58 return skdata; | |
| 59 } | |
| 60 return 0; | |
| 61 } | |
| 62 | |
| 63 bool DecodingImageGenerator::getInfo(SkImageInfo* info) | |
| 64 { | |
| 65 *info = m_imageInfo; | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 bool DecodingImageGenerator::getPixels(const SkImageInfo& info, void* pixels, si ze_t rowBytes) | |
| 70 { | |
| 71 TRACE_EVENT1("webkit", "DecodingImageGenerator::getPixels", "index", static_ cast<int>(m_frameIndex)); | |
| 72 | |
| 73 // Implementation doesn't support scaling yet so make sure we're not given | |
| 74 // a different size. | |
| 75 ASSERT(info.fWidth == m_imageInfo.fWidth); | |
| 76 ASSERT(info.fHeight == m_imageInfo.fHeight); | |
| 77 ASSERT(info.fColorType == m_imageInfo.fColorType); | |
| 78 ASSERT(info.fAlphaType == m_imageInfo.fAlphaType); | |
| 79 return m_frameGenerator->decodeAndScale(m_imageInfo, m_frameIndex, pixels, r owBytes); | |
| 80 } | |
| 81 | |
| 82 } // namespace blink | |
| OLD | NEW |