REGRESSION(r215211): [GTK] Several webgl related tests are failing
authormagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2017 11:53:52 +0000 (11:53 +0000)
committermagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2017 11:53:52 +0000 (11:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170730

Reviewed by Said Abou-Hallawa.

Source/WebCore:

There is a wrong situation in the image decoders where the complete data has been assigned
to them but the size of the image hasn't been decoded yet. This is causing rendering
issues in webgl when decoding the images used as textures. To fix this, we refactor how the
encoded data status is stored to avoid that situation: the status is handled completely
by ImageDecoder.h, and it's the one forcing the decode of the size when data gets assigned
to the decoders.

Covered by existent tests.

* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageDecoder::isAllDataReceived):
(WebCore::ImageDecoder::setData):
(WebCore::ImageDecoder::encodedDataStatus):
(WebCore::ImageDecoder::isSizeAvailable):
(WebCore::ImageDecoder::setSize):
(WebCore::ImageDecoder::setFailed):
(WebCore::ImageDecoder::failed):
* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::frameBufferAtIndex):
(WebCore::BMPImageDecoder::decode):
(WebCore::BMPImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/bmp/BMPImageDecoder.h:
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::frameCount):
(WebCore::GIFImageDecoder::frameBufferAtIndex):
(WebCore::GIFImageDecoder::decode):
(WebCore::GIFImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/gif/GIFImageDecoder.h:
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::setData):
(WebCore::ICOImageDecoder::frameCount):
(WebCore::ICOImageDecoder::frameBufferAtIndex):
(WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
(WebCore::ICOImageDecoder::decode):
(WebCore::ICOImageDecoder::decodeAtIndex):
(WebCore::ICOImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/ico/ICOImageDecoder.h:
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::frameBufferAtIndex):
(WebCore::JPEGImageDecoder::decode):
(WebCore::JPEGImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/jpeg/JPEGImageDecoder.h:
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::frameBufferAtIndex):
(WebCore::PNGImageDecoder::decode):
(WebCore::PNGImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/png/PNGImageDecoder.h:
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::frameBufferAtIndex):
(WebCore::WEBPImageDecoder::decode):
(WebCore::WEBPImageDecoder::encodedDataStatus): Deleted.
* platform/image-decoders/webp/WEBPImageDecoder.h:

LayoutTests:

Adjust test expectations for the tests that were failing. They must pass now.

* platform/gtk/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215924 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/image-decoders/ImageDecoder.h
Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp
Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h
Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h
Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp
Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h

index 0c65744..c61026d 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-28  Miguel Gomez  <magomez@igalia.com>
+
+        REGRESSION(r215211): [GTK] Several webgl related tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=170730
+
+        Reviewed by Said Abou-Hallawa.
+
+        Adjust test expectations for the tests that were failing. They must pass now.
+
+        * platform/gtk/TestExpectations:
+
 2017-04-27  Andy VanWagoner  <thetalecrafter@gmail.com>
 
         [INTL] Implement the caseFirst option for Intl.Collator
index daf1043..3a976b5 100644 (file)
@@ -3525,31 +3525,6 @@ webkit.org/b/170053 media/video-load-require-user-gesture.html [ Failure ]
 webkit.org/b/170335 canvas/philip/tests/2d.pattern.animated.gif.html [ Failure ]
 webkit.org/b/170335 svg/animations/animated-svg-image-outside-viewport-paused.html [ Failure ]
 
-webkit.org/b/170730 fast/canvas/webgl/gl-teximage.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/oes-texture-half-float-with-image.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-and-sub-image-2d-with-potentially-subsampled-image.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-with-format-and-type.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/tex-image-with-greyscale-image.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/texture-color-profile.html [ Failure ]
-webkit.org/b/170730 fast/canvas/webgl/texture-transparent-pixels-initialized.html [ Failure ]
-webkit.org/b/170730 fast/images/webgl-teximage2d.html [ Failure ]
-webkit.org/b/170730 http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html [ Failure ]
-webkit.org/b/170730 http/tests/security/webgl-remote-read-remote-image-allowed.html [ Failure ]
-webkit.org/b/170730 http/tests/webgl/1.0.2/texImage2DHTML.html [ Failure ]
-webkit.org/b/170730 http/tests/webgl/1.0.2/texSubImage2DHTML.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/extensions/oes-texture-float-with-image.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/gl-teximage.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/tex-image-and-sub-image-2d-with-image-rgb565.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba4444.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba5551.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/tex-image-and-sub-image-2d-with-image.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.2/conformance/textures/tex-image-with-format-and-type.html [ Failure ]
-webkit.org/b/170730 webgl/1.0.3/conformance/extensions/oes-texture-half-float-with-image.html [ Failure ]
-
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of non-crashing, non-flaky tests failing
 #////////////////////////////////////////////////////////////////////////////////////////
index 4d7931b..103cecf 100644 (file)
@@ -1,3 +1,63 @@
+2017-04-28  Miguel Gomez  <magomez@igalia.com>
+
+        REGRESSION(r215211): [GTK] Several webgl related tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=170730
+
+        Reviewed by Said Abou-Hallawa.
+
+        There is a wrong situation in the image decoders where the complete data has been assigned
+        to them but the size of the image hasn't been decoded yet. This is causing rendering
+        issues in webgl when decoding the images used as textures. To fix this, we refactor how the
+        encoded data status is stored to avoid that situation: the status is handled completely
+        by ImageDecoder.h, and it's the one forcing the decode of the size when data gets assigned
+        to the decoders.
+
+        Covered by existent tests.
+
+        * platform/image-decoders/ImageDecoder.h:
+        (WebCore::ImageDecoder::isAllDataReceived):
+        (WebCore::ImageDecoder::setData):
+        (WebCore::ImageDecoder::encodedDataStatus):
+        (WebCore::ImageDecoder::isSizeAvailable):
+        (WebCore::ImageDecoder::setSize):
+        (WebCore::ImageDecoder::setFailed):
+        (WebCore::ImageDecoder::failed):
+        * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+        (WebCore::BMPImageDecoder::frameBufferAtIndex):
+        (WebCore::BMPImageDecoder::decode):
+        (WebCore::BMPImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/bmp/BMPImageDecoder.h:
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::frameCount):
+        (WebCore::GIFImageDecoder::frameBufferAtIndex):
+        (WebCore::GIFImageDecoder::decode):
+        (WebCore::GIFImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/gif/GIFImageDecoder.h:
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::setData):
+        (WebCore::ICOImageDecoder::frameCount):
+        (WebCore::ICOImageDecoder::frameBufferAtIndex):
+        (WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
+        (WebCore::ICOImageDecoder::decode):
+        (WebCore::ICOImageDecoder::decodeAtIndex):
+        (WebCore::ICOImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/ico/ICOImageDecoder.h:
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageDecoder::frameBufferAtIndex):
+        (WebCore::JPEGImageDecoder::decode):
+        (WebCore::JPEGImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/jpeg/JPEGImageDecoder.h:
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::frameBufferAtIndex):
+        (WebCore::PNGImageDecoder::decode):
+        (WebCore::PNGImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/png/PNGImageDecoder.h:
+        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+        (WebCore::WEBPImageDecoder::frameBufferAtIndex):
+        (WebCore::WEBPImageDecoder::decode):
+        (WebCore::WEBPImageDecoder::encodedDataStatus): Deleted.
+        * platform/image-decoders/webp/WEBPImageDecoder.h:
+
 2017-04-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Move UUID from WebCore/platform to WTF
index fea79fc..13d8d0b 100644 (file)
@@ -67,37 +67,39 @@ public:
     static RefPtr<ImageDecoder> create(const SharedBuffer& data, const URL&, AlphaOption, GammaAndColorProfileOption);
 
     virtual String filenameExtension() const = 0;
-    
-    bool premultiplyAlpha() const { return m_premultiplyAlpha; }
 
-    bool isAllDataReceived() const { return m_isAllDataReceived; }
+    bool premultiplyAlpha() const { return m_premultiplyAlpha; }
 
-    virtual void setData(SharedBuffer& data, bool allDataReceived)
+    bool isAllDataReceived() const
     {
-        if (m_failed)
-            return;
-        m_data = &data;
-        m_isAllDataReceived = allDataReceived;
+        ASSERT(!m_decodingSizeFromSetData);
+        return m_encodedDataStatus == EncodedDataStatus::Complete;
     }
 
-    // Lazily-decodes enough of the image to get the size (if possible).
-    // FIXME: Right now that has to be done by each subclass; factor the
-    // decode call out and use it here.
-    virtual EncodedDataStatus encodedDataStatus() const
+    virtual void setData(SharedBuffer& data, bool allDataReceived)
     {
-        if (m_failed)
-            return EncodedDataStatus::Error;
+        if (m_encodedDataStatus == EncodedDataStatus::Error)
+            return;
 
-        if (m_isAllDataReceived)
-            return EncodedDataStatus::Complete;
+        m_data = &data;
+        if (m_encodedDataStatus == EncodedDataStatus::TypeAvailable) {
+            m_decodingSizeFromSetData = true;
+            tryDecodeSize(allDataReceived);
+            m_decodingSizeFromSetData = false;
+        }
 
-        if (m_sizeAvailable)
-            return EncodedDataStatus::SizeAvailable;
+        if (m_encodedDataStatus == EncodedDataStatus::Error)
+            return;
 
-        return EncodedDataStatus::TypeAvailable;
+        if (allDataReceived) {
+            ASSERT(m_encodedDataStatus == EncodedDataStatus::SizeAvailable);
+            m_encodedDataStatus = EncodedDataStatus::Complete;
+        }
     }
 
-    bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }
+    EncodedDataStatus encodedDataStatus() const { return m_encodedDataStatus; }
+
+    bool isSizeAvailable() { return m_encodedDataStatus >= EncodedDataStatus::SizeAvailable; }
 
     virtual IntSize size() { return isSizeAvailable() ? m_size : IntSize(); }
 
@@ -123,7 +125,7 @@ public:
         if (ImageBackingStore::isOverSize(size))
             return setFailed();
         m_size = size;
-        m_sizeAvailable = true;
+        m_encodedDataStatus = EncodedDataStatus::SizeAvailable;
         return true;
     }
 
@@ -184,11 +186,11 @@ public:
     // clean up any local data.
     virtual bool setFailed()
     {
-        m_failed = true;
+        m_encodedDataStatus = EncodedDataStatus::Error;
         return false;
     }
 
-    bool failed() const { return m_failed; }
+    bool failed() const { return m_encodedDataStatus == EncodedDataStatus::Error; }
 
     // Clears decoded pixel data from before the provided frame unless that
     // data may be needed to decode future frames (e.g. due to GIF frame
@@ -217,15 +219,16 @@ protected:
     ImageOrientation m_orientation;
 
 private:
+    virtual void tryDecodeSize(bool) = 0;
+
     IntSize m_size;
-    bool m_sizeAvailable { false };
+    EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::TypeAvailable };
+    bool m_decodingSizeFromSetData { false };
 #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
     static const int m_maxNumPixels { 1024 * 1024 };
 #else
     static const int m_maxNumPixels { -1 };
 #endif
-    bool m_isAllDataReceived { false };
-    bool m_failed { false };
 };
 
 } // namespace WebCore
index 525a87b..13b5c08 100644 (file)
@@ -56,14 +56,6 @@ void BMPImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
         m_reader->setData(&data);
 }
 
-EncodedDataStatus BMPImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<BMPImageDecoder*>(this)->decode(true);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 ImageFrame* BMPImageDecoder::frameBufferAtIndex(size_t index)
 {
     if (index)
@@ -74,7 +66,7 @@ ImageFrame* BMPImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame* buffer = &m_frameBufferCache.first();
     if (!buffer->isComplete())
-        decode(false);
+        decode(false, isAllDataReceived());
     return buffer;
 }
 
@@ -84,14 +76,14 @@ bool BMPImageDecoder::setFailed()
     return ImageDecoder::setFailed();
 }
 
-void BMPImageDecoder::decode(bool onlySize)
+void BMPImageDecoder::decode(bool onlySize, bool allDataReceived)
 {
     if (failed())
         return;
 
     // If we couldn't decode the image but we've received all the data, decoding
     // has failed.
-    if (!decodeHelper(onlySize) && isAllDataReceived())
+    if (!decodeHelper(onlySize) && allDataReceived)
         setFailed();
     // If we're done decoding the image, we don't need the BMPImageReader
     // anymore.  (If we failed, |m_reader| has already been cleared.)
index f0358f9..c627690 100644 (file)
@@ -45,7 +45,6 @@ namespace WebCore {
         // ImageDecoder
         String filenameExtension() const override { return ASCIILiteral("bmp"); }
         void setData(SharedBuffer&, bool allDataReceived) override;
-        EncodedDataStatus encodedDataStatus() const override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid
         // accessing deleted memory, especially when calling this from inside
@@ -54,6 +53,7 @@ namespace WebCore {
 
     private:
         BMPImageDecoder(AlphaOption, GammaAndColorProfileOption);
+        void tryDecodeSize(bool allDataReceived) override { decode(true, allDataReceived); }
 
         inline uint32_t readUint32(int offset) const
         {
@@ -63,7 +63,7 @@ namespace WebCore {
         // Decodes the image.  If |onlySize| is true, stops decoding after
         // calculating the image size.  If decoding fails but there is no more
         // data coming, sets the "decode failure" flag.
-        void decode(bool onlySize);
+        void decode(bool onlySize, bool allDataReceived);
 
         // Decodes the image.  If |onlySize| is true, stops decoding after
         // calculating the image size.  Returns whether decoding succeeded.
index 8f5729a..f37a77c 100644 (file)
@@ -50,14 +50,6 @@ void GIFImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
         m_reader->setData(&data);
 }
 
-EncodedDataStatus GIFImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<GIFImageDecoder*>(this)->decode(0, GIFSizeQuery);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 bool GIFImageDecoder::setSize(const IntSize& size)
 {
     if (ImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable && this->size() == size)
@@ -72,7 +64,7 @@ bool GIFImageDecoder::setSize(const IntSize& size)
 
 size_t GIFImageDecoder::frameCount() const
 {
-    const_cast<GIFImageDecoder*>(this)->decode(std::numeric_limits<unsigned>::max(), GIFFrameCountQuery);
+    const_cast<GIFImageDecoder*>(this)->decode(std::numeric_limits<unsigned>::max(), GIFFrameCountQuery, isAllDataReceived());
     return m_frameBufferCache.size();
 }
 
@@ -116,7 +108,7 @@ ImageFrame* GIFImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame& frame = m_frameBufferCache[index];
     if (!frame.isComplete())
-        decode(index + 1, GIFFullQuery);
+        decode(index + 1, GIFFullQuery, isAllDataReceived());
     return &frame;
 }
 
@@ -305,7 +297,7 @@ void GIFImageDecoder::gifComplete()
     m_reader = nullptr;
 }
 
-void GIFImageDecoder::decode(unsigned haltAtFrame, GIFQuery query)
+void GIFImageDecoder::decode(unsigned haltAtFrame, GIFQuery query, bool allDataReceived)
 {
     if (failed())
         return;
@@ -339,7 +331,7 @@ void GIFImageDecoder::decode(unsigned haltAtFrame, GIFQuery query)
 
     // It is also a fatal error if all data is received but we failed to decode
     // all frames completely.
-    if (isAllDataReceived() && haltAtFrame >= m_frameBufferCache.size() && m_reader)
+    if (allDataReceived && haltAtFrame >= m_frameBufferCache.size() && m_reader)
         setFailed();
 }
 
index f94a9cb..d6cba39 100644 (file)
@@ -47,7 +47,6 @@ namespace WebCore {
         // ImageDecoder
         String filenameExtension() const override { return ASCIILiteral("gif"); }
         void setData(SharedBuffer& data, bool allDataReceived) override;
-        EncodedDataStatus encodedDataStatus() const override;
         bool setSize(const IntSize&) override;
         size_t frameCount() const override;
         RepetitionCount repetitionCount() const override;
@@ -65,12 +64,13 @@ namespace WebCore {
 
     private:
         GIFImageDecoder(AlphaOption, GammaAndColorProfileOption);
+        void tryDecodeSize(bool allDataReceived) override { decode(0, GIFSizeQuery, allDataReceived); }
 
         // If the query is GIFFullQuery, decodes the image up to (but not
         // including) |haltAtFrame|.  Otherwise, decodes as much as is needed to
         // answer the query, ignoring bitmap data.  If decoding fails but there
         // is no more data coming, sets the "decode failure" flag.
-        void decode(unsigned haltAtFrame, GIFQuery);
+        void decode(unsigned haltAtFrame, GIFQuery, bool allDataReceived);
 
         // Called to initialize the frame buffer with the given index, based on
         // the previous frame's disposal method. Returns true on success. On
index a5f98c9..363ae28 100644 (file)
@@ -69,14 +69,6 @@ void ICOImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
         setDataForPNGDecoderAtIndex(i);
 }
 
-EncodedDataStatus ICOImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<ICOImageDecoder*>(this)->decode(0, true);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 IntSize ICOImageDecoder::size()
 {
     return m_frameSize.isEmpty() ? ImageDecoder::size() : m_frameSize;
@@ -96,7 +88,7 @@ bool ICOImageDecoder::setSize(const IntSize& size)
 
 size_t ICOImageDecoder::frameCount() const
 {
-    const_cast<ICOImageDecoder*>(this)->decode(0, true);
+    const_cast<ICOImageDecoder*>(this)->decode(0, true, isAllDataReceived());
     return m_frameBufferCache.size();
 }
 
@@ -108,7 +100,7 @@ ImageFrame* ICOImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame* buffer = &m_frameBufferCache[index];
     if (!buffer->isComplete())
-        decode(index, false);
+        decode(index, false, isAllDataReceived());
     return buffer;
 }
 
@@ -158,14 +150,14 @@ void ICOImageDecoder::setDataForPNGDecoderAtIndex(size_t index)
     m_pngDecoders[index]->setData(*pngData, isAllDataReceived());
 }
 
-void ICOImageDecoder::decode(size_t index, bool onlySize)
+void ICOImageDecoder::decode(size_t index, bool onlySize, bool allDataReceived)
 {
     if (failed())
         return;
 
     // If we couldn't decode the image but we've received all the data, decoding
     // has failed.
-    if ((!decodeDirectory() || (!onlySize && !decodeAtIndex(index))) && isAllDataReceived())
+    if ((!decodeDirectory() || (!onlySize && !decodeAtIndex(index))) && allDataReceived)
         setFailed();
     // If we're done decoding this frame, we don't need the BMPImageReader or
     // PNGImageDecoder anymore.  (If we failed, these have already been
index 86bab8f..e4bb60b 100644 (file)
@@ -46,7 +46,6 @@ namespace WebCore {
         // ImageDecoder
         String filenameExtension() const override { return ASCIILiteral("ico"); }
         void setData(SharedBuffer&, bool allDataReceived) override;
-        EncodedDataStatus encodedDataStatus() const override;
         IntSize size() override;
         IntSize frameSizeAtIndex(size_t, SubsamplingLevel) override;
         bool setSize(const IntSize&) override;
@@ -78,6 +77,7 @@ namespace WebCore {
         };
 
         ICOImageDecoder(AlphaOption, GammaAndColorProfileOption);
+        void tryDecodeSize(bool allDataReceived) override { decode(0, true, allDataReceived); }
 
         // Returns true if |a| is a preferable icon entry to |b|.
         // Larger sizes, or greater bitdepths at the same size, are preferable.
@@ -99,7 +99,7 @@ namespace WebCore {
         // Decodes the entry at |index|.  If |onlySize| is true, stops decoding
         // after calculating the image size.  If decoding fails but there is no
         // more data coming, sets the "decode failure" flag.
-        void decode(size_t index, bool onlySize);
+        void decode(size_t index, bool onlySize, bool allDataReceived);
 
         // Decodes the directory and directory entries at the beginning of the
         // data, and initializes members.  Returns true if all decoding
index 895ddec..836c553 100644 (file)
@@ -510,14 +510,6 @@ JPEGImageDecoder::~JPEGImageDecoder()
 {
 }
 
-EncodedDataStatus JPEGImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<JPEGImageDecoder*>(this)->decode(true);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 bool JPEGImageDecoder::setSize(const IntSize& size)
 {
     if (!ImageDecoder::setSize(size))
@@ -537,7 +529,7 @@ ImageFrame* JPEGImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame& frame = m_frameBufferCache[0];
     if (!frame.isComplete())
-        decode(false);
+        decode(false, isAllDataReceived());
     return &frame;
 }
 
@@ -663,7 +655,7 @@ void JPEGImageDecoder::jpegComplete()
     buffer.setDecoding(ImageFrame::Decoding::Complete);
 }
 
-void JPEGImageDecoder::decode(bool onlySize)
+void JPEGImageDecoder::decode(bool onlySize, bool allDataReceived)
 {
     if (failed())
         return;
@@ -673,7 +665,7 @@ void JPEGImageDecoder::decode(bool onlySize)
 
     // If we couldn't decode the image but we've received all the data, decoding
     // has failed.
-    if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
+    if (!m_reader->decode(*m_data, onlySize) && allDataReceived)
         setFailed();
     // If we're done decoding the image, we don't need the JPEGImageReader
     // anymore.  (If we failed, |m_reader| has already been cleared.)
index ca2171f..5a46dff 100644 (file)
@@ -52,7 +52,6 @@ namespace WebCore {
 
         // ImageDecoder
         String filenameExtension() const override { return ASCIILiteral("jpg"); }
-        EncodedDataStatus encodedDataStatus() const override;
         bool setSize(const IntSize&) override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid
@@ -73,11 +72,12 @@ namespace WebCore {
 
     private:
         JPEGImageDecoder(AlphaOption, GammaAndColorProfileOption);
+        void tryDecodeSize(bool allDataReceived) override { decode(true, allDataReceived); }
 
         // Decodes the image.  If |onlySize| is true, stops decoding after
         // calculating the image size.  If decoding fails but there is no more
         // data coming, sets the "decode failure" flag.
-        void decode(bool onlySize);
+        void decode(bool onlySize, bool allDataReceived);
 
         template <J_COLOR_SPACE colorSpace>
         bool outputScanlines(ImageFrame& buffer);
index c85d824..cfc8bf9 100644 (file)
@@ -244,14 +244,6 @@ RepetitionCount PNGImageDecoder::repetitionCount() const
 }
 #endif
 
-EncodedDataStatus PNGImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<PNGImageDecoder*>(this)->decode(true, 0);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 bool PNGImageDecoder::setSize(const IntSize& size)
 {
     if (!ImageDecoder::setSize(size))
@@ -279,7 +271,7 @@ ImageFrame* PNGImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame& frame = m_frameBufferCache[index];
     if (!frame.isComplete())
-        decode(false, index);
+        decode(false, index, isAllDataReceived());
     return &frame;
 }
 
@@ -566,7 +558,7 @@ void PNGImageDecoder::pngComplete()
         m_frameBufferCache.first().setDecoding(ImageFrame::Decoding::Complete);
 }
 
-void PNGImageDecoder::decode(bool onlySize, unsigned haltAtFrame)
+void PNGImageDecoder::decode(bool onlySize, unsigned haltAtFrame, bool allDataReceived)
 {
     if (failed())
         return;
@@ -576,7 +568,7 @@ void PNGImageDecoder::decode(bool onlySize, unsigned haltAtFrame)
 
     // If we couldn't decode the image but we've received all the data, decoding
     // has failed.
-    if (!m_reader->decode(*m_data, onlySize, haltAtFrame) && isAllDataReceived())
+    if (!m_reader->decode(*m_data, onlySize, haltAtFrame) && allDataReceived)
         setFailed();
     // If we're done decoding the image, we don't need the PNGImageReader
     // anymore.  (If we failed, |m_reader| has already been cleared.)
index 0c4293a..03e1fbc 100644 (file)
@@ -50,7 +50,6 @@ namespace WebCore {
         size_t frameCount() const override { return m_frameCount; }
         RepetitionCount repetitionCount() const override;
 #endif
-        EncodedDataStatus encodedDataStatus() const override;
         bool setSize(const IntSize&) override;
         ImageFrame* frameBufferAtIndex(size_t index) override;
         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid
@@ -90,11 +89,12 @@ namespace WebCore {
 
     private:
         PNGImageDecoder(AlphaOption, GammaAndColorProfileOption);
+        void tryDecodeSize(bool allDataReceived) override { decode(true, 0, allDataReceived); }
 
         // Decodes the image.  If |onlySize| is true, stops decoding after
         // calculating the image size.  If decoding fails but there is no more
         // data coming, sets the "decode failure" flag.
-        void decode(bool onlySize, unsigned haltAtFrame);
+        void decode(bool onlySize, unsigned haltAtFrame, bool allDataReceived);
 #if ENABLE(APNG)
         void initFrameBuffer(size_t frameIndex);
         void frameComplete();
index 8ba0b73..e88a81a 100644 (file)
@@ -64,14 +64,6 @@ void WEBPImageDecoder::clear()
     m_decoder = 0;
 }
 
-EncodedDataStatus WEBPImageDecoder::encodedDataStatus() const
-{
-    if (ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)
-        const_cast<WEBPImageDecoder*>(this)->decode(true);
-
-    return ImageDecoder::encodedDataStatus();
-}
-
 ImageFrame* WEBPImageDecoder::frameBufferAtIndex(size_t index)
 {
     if (index)
@@ -82,11 +74,11 @@ ImageFrame* WEBPImageDecoder::frameBufferAtIndex(size_t index)
 
     ImageFrame& frame = m_frameBufferCache[0];
     if (!frame.isComplete())
-        decode(false);
+        decode(false, isAllDataReceived());
     return &frame;
 }
 
-bool WEBPImageDecoder::decode(bool onlySize)
+bool WEBPImageDecoder::decode(bool onlySize, bool)
 {
     if (failed())
         return false;
@@ -151,7 +143,7 @@ bool WEBPImageDecoder::decode(bool onlySize)
     case VP8_STATUS_SUSPENDED:
         return false;
     default:
-        clear();                         
+        clear();
         return setFailed();
     }
 }
index e222fab..d7956f0 100644 (file)
@@ -46,13 +46,13 @@ public:
     virtual ~WEBPImageDecoder();
 
     String filenameExtension() const override { return ASCIILiteral("webp"); }
-    EncodedDataStatus encodedDataStatus() const override;
     ImageFrame* frameBufferAtIndex(size_t index) override;
 
 private:
     WEBPImageDecoder(AlphaOption, GammaAndColorProfileOption);
+    void tryDecodeSize(bool allDataReceived) override { decode(true, allDataReceived); }
 
-    bool decode(bool onlySize);
+    bool decode(bool onlySize, bool allDataReceived);
 
     WebPIDecoder* m_decoder;
     bool m_hasAlpha;