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

Side by Side Diff: Source/platform/graphics/DeferredImageDecoder.cpp

Issue 244243002: Pass SharedBuffer by reference to DeferredImageDecoder::setData() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // ImageFrameGenerator has the latest known alpha state. There will 110 // ImageFrameGenerator has the latest known alpha state. There will
111 // be a performance boost if this frame is opaque. 111 // be a performance boost if this frame is opaque.
112 m_lazyDecodedFrames[index]->setHasAlpha(m_frameGenerator->hasAlpha(index )); 112 m_lazyDecodedFrames[index]->setHasAlpha(m_frameGenerator->hasAlpha(index ));
113 return m_lazyDecodedFrames[index].get(); 113 return m_lazyDecodedFrames[index].get();
114 } 114 }
115 if (m_actualDecoder) 115 if (m_actualDecoder)
116 return m_actualDecoder->frameBufferAtIndex(index); 116 return m_actualDecoder->frameBufferAtIndex(index);
117 return 0; 117 return 0;
118 } 118 }
119 119
120 void DeferredImageDecoder::setData(SharedBuffer* data, bool allDataReceived) 120 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
121 { 121 {
122 if (m_actualDecoder) { 122 if (m_actualDecoder) {
123 const bool firstData = !m_data && data; 123 const bool firstData = !m_data;
124 const bool moreData = data && data->size() > m_lastDataSize; 124 const bool moreData = data.size() > m_lastDataSize;
125 m_dataChanged = firstData || moreData; 125 m_dataChanged = firstData || moreData;
126 m_data = data; 126 m_data = RefPtr<SharedBuffer>(data);
127 m_lastDataSize = data->size(); 127 m_lastDataSize = data.size();
Inactive 2014/04/20 13:16:51 There was no null check here.
128 m_allDataReceived = allDataReceived; 128 m_allDataReceived = allDataReceived;
129 m_actualDecoder->setData(data, allDataReceived); 129 m_actualDecoder->setData(&data, allDataReceived);
130 prepareLazyDecodedFrames(); 130 prepareLazyDecodedFrames();
131 } 131 }
132 132
133 if (m_frameGenerator) 133 if (m_frameGenerator)
134 m_frameGenerator->setData(data, allDataReceived); 134 m_frameGenerator->setData(&data, allDataReceived);
135 } 135 }
136 136
137 bool DeferredImageDecoder::isSizeAvailable() 137 bool DeferredImageDecoder::isSizeAvailable()
138 { 138 {
139 // m_actualDecoder is 0 only if image decoding is deferred and that 139 // m_actualDecoder is 0 only if image decoding is deferred and that
140 // means image header decoded successfully and size is available. 140 // means image header decoded successfully and size is available.
141 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; 141 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true;
142 } 142 }
143 143
144 IntSize DeferredImageDecoder::size() const 144 IntSize DeferredImageDecoder::size() const
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return bitmap; 326 return bitmap;
327 } 327 }
328 328
329 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 329 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
330 { 330 {
331 // TODO: Implement. 331 // TODO: Implement.
332 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 332 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
333 } 333 }
334 334
335 } // namespace WebCore 335 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoder.h ('k') | Source/platform/graphics/DeferredImageDecoderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698