Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.h

Issue 1812273003: Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
30 #include "third_party/skia/include/core/SkImageGenerator.h" 31 #include "third_party/skia/include/core/SkImageGenerator.h"
31 #include "third_party/skia/include/core/SkImageInfo.h" 32 #include "third_party/skia/include/core/SkImageInfo.h"
32 #include "wtf/Allocator.h" 33 #include "wtf/Allocator.h"
33 #include "wtf/Noncopyable.h" 34 #include "wtf/Noncopyable.h"
35 #include "wtf/PassRefPtr.h"
34 #include "wtf/RefPtr.h" 36 #include "wtf/RefPtr.h"
35 37
36 class SkData; 38 class SkData;
37 39
38 namespace blink { 40 namespace blink {
39 41
40 class ImageFrameGenerator; 42 class ImageFrameGenerator;
41 43
42 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem ory 44 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem ory
43 // with a decoded image frame. ImageFrameGenerator does the actual decoding. 45 // with a decoded image frame. ImageFrameGenerator does the actual decoding.
44 // 46 //
45 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator { 47 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator {
46 USING_FAST_MALLOC(DecodingImageGenerator); 48 USING_FAST_MALLOC(DecodingImageGenerator);
47 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator); 49 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator);
48 public: 50 public:
49 static SkImageGenerator* create(SkData*); 51 static SkImageGenerator* create(SkData*);
50 52
51 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&, size_t index); 53 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&, PassRefPtr<SegmentReader>, bool allDataReceived, size_t index);
52 ~DecodingImageGenerator() override; 54 ~DecodingImageGenerator() override;
53 55
54 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; } 56 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; }
55 57
56 protected: 58 protected:
57 SkData* onRefEncodedData() override; 59 SkData* onRefEncodedData() override;
58 60
59 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo r table[], int* tableCount) override; 61 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo r table[], int* tableCount) override;
60 62
61 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; 63 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override;
62 64
63 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; 65 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override;
64 66
65 private: 67 private:
66 RefPtr<ImageFrameGenerator> m_frameGenerator; 68 RefPtr<ImageFrameGenerator> m_frameGenerator;
67 size_t m_frameIndex; 69 const RefPtr<SegmentReader> m_data; // Data source.
70 const bool m_allDataReceived;
71 const size_t m_frameIndex;
68 bool m_canYUVDecode; 72 bool m_canYUVDecode;
69 }; 73 };
70 74
71 } // namespace blink 75 } // namespace blink
72 76
73 #endif // DecodingImageGenerator_h_ 77 #endif // DecodingImageGenerator_h_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698