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

Side by Side Diff: third_party/WebKit/Source/web/WebImageDecoder.cpp

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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "public/web/WebImageDecoder.h" 31 #include "public/web/WebImageDecoder.h"
32 32
33 #include "platform/SharedBuffer.h" 33 #include "platform/SharedBuffer.h"
34 #include "platform/image-decoders/SharedBufferSegmentReader.h"
34 #include "platform/image-decoders/bmp/BMPImageDecoder.h" 35 #include "platform/image-decoders/bmp/BMPImageDecoder.h"
35 #include "platform/image-decoders/ico/ICOImageDecoder.h" 36 #include "platform/image-decoders/ico/ICOImageDecoder.h"
36 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
37 #include "public/platform/WebData.h" 38 #include "public/platform/WebData.h"
38 #include "public/platform/WebImage.h" 39 #include "public/platform/WebImage.h"
39 #include "public/platform/WebSize.h" 40 #include "public/platform/WebSize.h"
40 #include "wtf/OwnPtr.h" 41 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
42 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
43 44
(...skipping 14 matching lines...) Expand all
58 break; 59 break;
59 case TypeICO: 60 case TypeICO:
60 m_private = new ICOImageDecoder(ImageDecoder::AlphaPremultiplied, ImageD ecoder::GammaAndColorProfileApplied, maxDecodedBytes); 61 m_private = new ICOImageDecoder(ImageDecoder::AlphaPremultiplied, ImageD ecoder::GammaAndColorProfileApplied, maxDecodedBytes);
61 break; 62 break;
62 } 63 }
63 } 64 }
64 65
65 void WebImageDecoder::setData(const WebData& data, bool allDataReceived) 66 void WebImageDecoder::setData(const WebData& data, bool allDataReceived)
66 { 67 {
67 ASSERT(m_private); 68 ASSERT(m_private);
68 m_private->setData(PassRefPtr<SharedBuffer>(data).get(), allDataReceived); 69 RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data).get();
Peter Kasting 2016/03/23 02:42:59 Nit: Can't we just do something like RefPtr<Shared
scroggo_chromium 2016/03/24 13:59:46 I don't think so. WebData has a "operator PassRefP
Peter Kasting 2016/03/24 22:05:43 Yeah, I had been hoping the compiler could figure
70 RefPtr<SharedBufferSegmentReader> segmentReader = adoptRef(new SharedBufferS egmentReader(buffer.get()));
71 m_private->setData(segmentReader.get(), allDataReceived);
69 } 72 }
70 73
71 bool WebImageDecoder::isFailed() const 74 bool WebImageDecoder::isFailed() const
72 { 75 {
73 ASSERT(m_private); 76 ASSERT(m_private);
74 return m_private->failed(); 77 return m_private->failed();
75 } 78 }
76 79
77 bool WebImageDecoder::isSizeAvailable() const 80 bool WebImageDecoder::isSizeAvailable() const
78 { 81 {
(...skipping 25 matching lines...) Expand all
104 WebImage WebImageDecoder::getFrameAtIndex(int index = 0) const 107 WebImage WebImageDecoder::getFrameAtIndex(int index = 0) const
105 { 108 {
106 ASSERT(m_private); 109 ASSERT(m_private);
107 ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index); 110 ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
108 if (!frameBuffer) 111 if (!frameBuffer)
109 return WebImage(); 112 return WebImage();
110 return WebImage(frameBuffer->bitmap()); 113 return WebImage(frameBuffer->bitmap());
111 } 114 }
112 115
113 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698