| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 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 | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 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 | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef DecodingImageGenerator_h | 26 #ifndef DecodingImageGenerator_h |
| 27 #define DecodingImageGenerator_h | 27 #define DecodingImageGenerator_h |
| 28 | 28 |
| 29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
| 30 #include "platform/image-decoders/SegmentReader.h" | |
| 31 #include "third_party/skia/include/core/SkImageGenerator.h" | 30 #include "third_party/skia/include/core/SkImageGenerator.h" |
| 32 #include "third_party/skia/include/core/SkImageInfo.h" | 31 #include "third_party/skia/include/core/SkImageInfo.h" |
| 33 #include "wtf/Allocator.h" | 32 #include "wtf/Allocator.h" |
| 34 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/PassRefPtr.h" | |
| 36 #include "wtf/RefPtr.h" | 34 #include "wtf/RefPtr.h" |
| 37 | 35 |
| 38 class SkData; | 36 class SkData; |
| 39 | 37 |
| 40 namespace blink { | 38 namespace blink { |
| 41 | 39 |
| 42 class ImageFrameGenerator; | 40 class ImageFrameGenerator; |
| 43 | 41 |
| 44 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem
ory | 42 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem
ory |
| 45 // with a decoded image frame. ImageFrameGenerator does the actual decoding. | 43 // with a decoded image frame. ImageFrameGenerator does the actual decoding. |
| 46 // | 44 // |
| 47 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator { | 45 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator { |
| 48 USING_FAST_MALLOC(DecodingImageGenerator); | 46 USING_FAST_MALLOC(DecodingImageGenerator); |
| 49 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator); | 47 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator); |
| 50 public: | 48 public: |
| 51 static SkImageGenerator* create(SkData*); | 49 static SkImageGenerator* create(SkData*); |
| 52 | 50 |
| 53 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&,
PassRefPtr<SegmentReader>, bool allDataReceived, size_t index); | 51 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&,
size_t index); |
| 54 ~DecodingImageGenerator() override; | 52 ~DecodingImageGenerator() override; |
| 55 | 53 |
| 56 void setGenerationId(size_t id) { m_generationId = id; } | 54 void setGenerationId(size_t id) { m_generationId = id; } |
| 57 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; } | 55 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; } |
| 58 | 56 |
| 59 protected: | 57 protected: |
| 60 SkData* onRefEncodedData() override; | 58 SkData* onRefEncodedData() override; |
| 61 | 59 |
| 62 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo
r table[], int* tableCount) override; | 60 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo
r table[], int* tableCount) override; |
| 63 | 61 |
| 64 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; | 62 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; |
| 65 | 63 |
| 66 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; | 64 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 RefPtr<ImageFrameGenerator> m_frameGenerator; | 67 RefPtr<ImageFrameGenerator> m_frameGenerator; |
| 70 const RefPtr<SegmentReader> m_data; // Data source. | 68 size_t m_frameIndex; |
| 71 const bool m_allDataReceived; | |
| 72 const size_t m_frameIndex; | |
| 73 size_t m_generationId; | 69 size_t m_generationId; |
| 74 bool m_canYUVDecode; | 70 bool m_canYUVDecode; |
| 75 }; | 71 }; |
| 76 | 72 |
| 77 } // namespace blink | 73 } // namespace blink |
| 78 | 74 |
| 79 #endif // DecodingImageGenerator_h_ | 75 #endif // DecodingImageGenerator_h_ |
| OLD | NEW |