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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h

Issue 1866243003: Revert of Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h
diff --git a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h
index 4b316343f7e5f1833aa5fe9236cc892f0b4a090a..73ac628811b9fd0e6b47262ab62582dc79c0d63e 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h
+++ b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h
@@ -27,7 +27,7 @@
#define ImageFrameGenerator_h
#include "platform/PlatformExport.h"
-#include "platform/image-decoders/SegmentReader.h"
+#include "platform/graphics/ThreadSafeDataTransport.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkSize.h"
#include "third_party/skia/include/core/SkTypes.h"
@@ -47,6 +47,7 @@
namespace blink {
class ImageDecoder;
+class SharedBuffer;
class PLATFORM_EXPORT ImageDecoderFactory {
USING_FAST_MALLOC(ImageDecoderFactory);
@@ -60,23 +61,27 @@
class PLATFORM_EXPORT ImageFrameGenerator final : public ThreadSafeRefCounted<ImageFrameGenerator> {
WTF_MAKE_NONCOPYABLE(ImageFrameGenerator);
public:
- static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, bool isMultiFrame = false)
+ static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived, bool isMultiFrame = false)
{
- return adoptRef(new ImageFrameGenerator(fullSize, isMultiFrame));
+ return adoptRef(new ImageFrameGenerator(fullSize, data, allDataReceived, isMultiFrame));
}
~ImageFrameGenerator();
+ void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
+
+ // Return our encoded image data. Caller takes ownership and must unref the data
+ // according to the contract SkImageGenerator::refEncodedData. Returns null if
+ // the data is has not been fully received.
+ SkData* refEncodedData();
+
// Decodes and scales the specified frame at |index|. The dimensions and output
// format are given in SkImageInfo. Decoded pixels are written into |pixels| with
// a stride of |rowBytes|. Returns true if decoding was successful.
- bool decodeAndScale(SegmentReader*, bool allDataReceived, size_t index, const SkImageInfo&, void* pixels, size_t rowBytes);
+ bool decodeAndScale(size_t index, const SkImageInfo&, void* pixels, size_t rowBytes);
// Decodes YUV components directly into the provided memory planes.
- // Must not be called unless getYUVComponentSizes has been called and returned true.
- // YUV decoding does not currently support progressive decoding. In order to support it, ImageDecoder needs something
- // analagous to its ImageFrame cache to hold partial planes, and the GPU code needs to handle them.
- bool decodeToYUV(SegmentReader*, size_t index, const SkISize componentSizes[3], void* planes[3], const size_t rowBytes[3]);
+ bool decodeToYUV(size_t index, const SkISize componentSizes[3], void* planes[3], const size_t rowBytes[3]);
const SkISize& getFullSize() const { return m_fullSize; }
@@ -85,12 +90,10 @@
bool hasAlpha(size_t index);
- // Must not be called unless the SkROBuffer has all the data.
- // YUV decoding does not currently support progressive decoding. See comment above on decodeToYUV.
- bool getYUVComponentSizes(SegmentReader*, SkYUVSizeInfo*);
+ bool getYUVComponentSizes(SkYUVSizeInfo*);
private:
- ImageFrameGenerator(const SkISize& fullSize, bool isMultiFrame);
+ ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame);
friend class ImageFrameGeneratorTest;
friend class DeferredImageDecoderTest;
@@ -99,17 +102,25 @@
void setHasAlpha(size_t index, bool hasAlpha);
- SkBitmap tryToResumeDecode(SegmentReader*, bool allDataReceived, size_t index, const SkISize& scaledSize, SkBitmap::Allocator*);
- // This method should only be called while m_decodeMutex is locked.
- bool decode(SegmentReader*, bool allDataReceived, size_t index, ImageDecoder**, SkBitmap*, SkBitmap::Allocator*);
+ // These methods are called while m_decodeMutex is locked.
+ SkBitmap tryToResumeDecode(size_t index, const SkISize& scaledSize);
+ bool decode(size_t index, ImageDecoder**, SkBitmap*);
- const SkISize m_fullSize;
+ SkISize m_fullSize;
- const bool m_isMultiFrame;
+ // ThreadSafeDataTransport is referenced by this class and m_encodedData.
+ // In case that ImageFrameGenerator get's deleted before m_encodedData,
+ // m_encodedData would hold the reference to it (and underlying data).
+ RefPtr<ThreadSafeDataTransport> m_data;
+
+ bool m_isMultiFrame;
bool m_decodeFailed;
bool m_yuvDecodingFailed;
size_t m_frameCount;
Vector<bool> m_hasAlpha;
+
+ class ExternalMemoryAllocator;
+ OwnPtr<ExternalMemoryAllocator> m_externalAllocator;
OwnPtr<ImageDecoderFactory> m_imageDecoderFactory;
@@ -118,6 +129,13 @@
// Protect concurrent access to m_hasAlpha.
Mutex m_alphaMutex;
+
+ // Our encoded image data returned in refEncodedData.
+ SkData* m_encodedData;
+
+#if COMPILER(MSVC)
+ friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>;
+#endif
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698