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

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: Created 4 years, 9 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"
31 #include "skia/ext/refptr.h"
scroggo_chromium 2016/03/22 20:18:41 No longer needed. Will remove.
scroggo_chromium 2016/03/24 13:59:44 Done.
30 #include "third_party/skia/include/core/SkImageGenerator.h" 32 #include "third_party/skia/include/core/SkImageGenerator.h"
31 #include "third_party/skia/include/core/SkImageInfo.h" 33 #include "third_party/skia/include/core/SkImageInfo.h"
32 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
33 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include "wtf/PassRefPtr.h"
34 #include "wtf/RefPtr.h" 37 #include "wtf/RefPtr.h"
35 38
36 class SkData; 39 class SkData;
37 40
38 namespace blink { 41 namespace blink {
39 42
40 class ImageFrameGenerator; 43 class ImageFrameGenerator;
41 44
42 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem ory 45 // Implements SkImageGenerator, used by SkPixelRef to populate a discardable mem ory
43 // with a decoded image frame. ImageFrameGenerator does the actual decoding. 46 // with a decoded image frame. ImageFrameGenerator does the actual decoding.
44 // 47 //
45 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator { 48 class PLATFORM_EXPORT DecodingImageGenerator final : public SkImageGenerator {
46 USING_FAST_MALLOC(DecodingImageGenerator); 49 USING_FAST_MALLOC(DecodingImageGenerator);
47 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator); 50 WTF_MAKE_NONCOPYABLE(DecodingImageGenerator);
48 public: 51 public:
49 static SkImageGenerator* create(SkData*); 52 static SkImageGenerator* create(SkData*);
50 53
51 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&, size_t index); 54 DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&, PassRefPtr<SegmentReader>, bool allDataReceived, size_t index);
52 ~DecodingImageGenerator() override; 55 ~DecodingImageGenerator() override;
53 56
54 void setGenerationId(size_t id) { m_generationId = id; } 57 void setGenerationId(size_t id) { m_generationId = id; }
55 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; } 58 void setCanYUVDecode(bool yes) { m_canYUVDecode = yes; }
56 59
57 protected: 60 protected:
58 SkData* onRefEncodedData() override; 61 SkData* onRefEncodedData() override;
59 62
60 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo r table[], int* tableCount) override; 63 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo r table[], int* tableCount) override;
61 64
62 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], SkYUVColorSpace*) override; 65 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], SkYUVColorSpace*) override;
63 66
64 private: 67 private:
65 RefPtr<ImageFrameGenerator> m_frameGenerator; 68 RefPtr<ImageFrameGenerator> m_frameGenerator;
66 size_t m_frameIndex; 69 const RefPtr<SegmentReader> m_data; // Data source.
70 const bool m_allDataReceived;
71 const size_t m_frameIndex;
67 size_t m_generationId; 72 size_t m_generationId;
68 bool m_canYUVDecode; 73 bool m_canYUVDecode;
69 }; 74 };
70 75
71 } // namespace blink 76 } // namespace blink
72 77
73 #endif // DecodingImageGenerator_h_ 78 #endif // DecodingImageGenerator_h_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698