WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-93590-20120816154653.patch (text/plain), 25.10 KB, created by
Dongseong Hwang
on 2012-08-15 23:47:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dongseong Hwang
Created:
2012-08-15 23:47:49 PDT
Size:
25.10 KB
patch
obsolete
>Subversion Revision: 125750 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 52e155e21a84499870b7d5b2158c72a2760f8e60..4aafc3bd1aa0e153d8714ded05a0ed64a9bf4d9f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,65 @@ >+2012-08-10 Huang Dongsung <luxtella@company100.net> >+ >+ Add NonImmediateBitmapImage to mark it is safe to decode asynchronously. >+ https://bugs.webkit.org/show_bug.cgi?id=93590 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Because image decoding is used in various contexts in WebKit, it is simply >+ impossible to make all decoding asynchronous. Instead, we selectively use async >+ image decoders where possible and use the existing sequential image decoders otherwise. >+ NonImmediateBitmapImage wraps a BitmapImage and helps decide when it is safe and beneficial >+ to use async image decoders. >+ >+ No new tests - existing image tests cover these cases. >+ Test: compositing/images/* >+ fast/images/* >+ fast/dom/HTMLImageElement/* >+ http/tests/images/* >+ css3/images/* >+ >+ * CMakeLists.txt: >+ * GNUmakefile.list.am: >+ * Target.pri: >+ * WebCore.gypi: >+ * WebCore.vcproj/WebCore.vcproj: >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/graphics/BitmapImage.cpp: >+ (WebCore::BitmapImage::cacheFrame): >+ (WebCore): >+ (WebCore::BitmapImage::nonImmediateRendering): >+ * platform/graphics/BitmapImage.h: >+ (BitmapImage): >+ * platform/graphics/NonImmediateBitmapImage.cpp: Added. >+ (WebCore): >+ (WebCore::NonImmediateBitmapImage::create): >+ (WebCore::NonImmediateBitmapImage::NonImmediateBitmapImage): >+ (WebCore::NonImmediateBitmapImage::hasSingleSecurityOrigin): >+ (WebCore::NonImmediateBitmapImage::size): >+ (WebCore::NonImmediateBitmapImage::getHotSpot): >+ (WebCore::NonImmediateBitmapImage::dataChanged): >+ (WebCore::NonImmediateBitmapImage::filenameExtension): >+ (WebCore::NonImmediateBitmapImage::destroyDecodedData): >+ (WebCore::NonImmediateBitmapImage::decodedSize): >+ (WebCore::NonImmediateBitmapImage::startAnimation): >+ (WebCore::NonImmediateBitmapImage::stopAnimation): >+ (WebCore::NonImmediateBitmapImage::resetAnimation): >+ (WebCore::NonImmediateBitmapImage::nativeImageForCurrentFrame): >+ (WebCore::NonImmediateBitmapImage::currentFrameHasAlpha): >+ (WebCore::NonImmediateBitmapImage::draw): >+ (WebCore::NonImmediateBitmapImage::mayFillWithSolidColor): >+ (WebCore::NonImmediateBitmapImage::solidColor): >+ (WebCore::toNonImmediateBitmapImageIfPossible): >+ * platform/graphics/NonImmediateBitmapImage.h: Added. >+ (WebCore): >+ (NonImmediateBitmapImage): >+ (WebCore::NonImmediateBitmapImage::nonImmediateRendering): >+ * rendering/RenderImage.cpp: >+ (WebCore::RenderImage::paintReplaced): >+ (WebCore::RenderImage::paintIntoRect): >+ * rendering/svg/RenderSVGImage.cpp: >+ (WebCore::RenderSVGImage::paint): >+ > 2012-08-15 Huang Dongsung <luxtella@company100.net> > > Make the API of ImageDecoder decode a frame explicitly. >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 930a91a2b61c2dd685fe1317518c7ec5b829cad3..90058e2f6bba0d41bc43021e7ae046865ad67f0d 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1837,6 +1837,7 @@ SET(WebCore_SOURCES > platform/graphics/ImageOrientation.cpp > platform/graphics/IntRect.cpp > platform/graphics/MediaPlayer.cpp >+ platform/graphics/NonImmediateBitmapImage.cpp > platform/graphics/Path.cpp > platform/graphics/PathTraversalState.cpp > platform/graphics/Pattern.cpp >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 78767828e2f7b5d5ff76f402d6b75d04f9ea3d09..234b030f1f4a829a69a7f13dd8aba647d3470a98 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -4351,6 +4351,8 @@ webcore_sources += \ > Source/WebCore/platform/graphics/MediaPlayer.cpp \ > Source/WebCore/platform/graphics/MediaPlayer.h \ > Source/WebCore/platform/graphics/MediaPlayerPrivate.h \ >+ Source/WebCore/platform/graphics/NonImmediateBitmapImage.cpp \ >+ Source/WebCore/platform/graphics/NonImmediateBitmapImage.h \ > Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \ > Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \ > Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \ >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 51d30f46748b297d4fe8e403eb0f140dd9c67f90..120903f776d02d4978b97bedf7e9bb33fb45e965 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -958,6 +958,7 @@ SOURCES += \ > platform/graphics/ImageOrientation.cpp \ > platform/graphics/ImageSource.cpp \ > platform/graphics/IntRect.cpp \ >+ platform/graphics/NonImmediateBitmapImage.cpp \ > platform/graphics/Path.cpp \ > platform/graphics/PathTraversalState.cpp \ > platform/graphics/Pattern.cpp \ >@@ -2089,6 +2090,7 @@ HEADERS += \ > platform/graphics/IntRect.h \ > platform/graphics/MediaPlayer.h \ > platform/graphics/NativeImagePtr.h \ >+ platform/graphics/NonImmediateBitmapImage.h \ > platform/graphics/opentype/OpenTypeVerticalData.h \ > platform/graphics/Path.h \ > platform/graphics/PathTraversalState.h \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 6e1a2262c03073bad6ae06c91fc2e5c5c2bbf5f2..475223b396152b71060ceca2af91f650ed410029 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -3526,6 +3526,8 @@ > 'platform/graphics/MediaPlayer.cpp', > 'platform/graphics/MediaPlayerPrivate.h', > 'platform/graphics/NativeImagePtr.h' , >+ 'platform/graphics/NonImmediateBitmapImage.cpp', >+ 'platform/graphics/NonImmediateBitmapImage.h', > 'platform/graphics/Path.cpp', > 'platform/graphics/PathTraversalState.cpp', > 'platform/graphics/PathTraversalState.h', >diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >index c3d4cb516097bbc773927031cd54179a9d5c6255..9031389e0249d66dd4a483040376587a2684323f 100755 >--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj >+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >@@ -29562,6 +29562,14 @@ > > > </File> > <File >+ RelativePath="..\platform\graphics\NonImmediateBitmapImage.cpp" >+ > >+ </File> >+ <File >+ RelativePath="..\platform\graphics\NonImmediateBitmapImage.h" >+ > >+ </File> >+ <File > RelativePath="..\platform\graphics\Path.cpp" > > > </File> >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 715da6cb9bb0195cc4be5d84927939aa43ee9374..cf191fef0b39d19fe35c685406516e5f4a929b63 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4835,6 +4835,8 @@ > B275357C0B053814002CE64F /* IntPointMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B275354F0B053814002CE64F /* IntPointMac.mm */; }; > B275357D0B053814002CE64F /* IntRectMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B27535500B053814002CE64F /* IntRectMac.mm */; }; > B275357E0B053814002CE64F /* IntSizeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B27535510B053814002CE64F /* IntSizeMac.mm */; }; >+ 5B3480930EEF50D400AC1B41 /* NonImmediateBitmapImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B3480910EEF50D400AC1B41 /* NonImmediateBitmapImage.cpp */; }; >+ 5B3480940EEF50D400AC1B41 /* NonImmediateBitmapImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B3480920EEF50D400AC1B41 /* NonImmediateBitmapImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B275357F0B053814002CE64F /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535520B053814002CE64F /* Path.cpp */; }; > B27535800B053814002CE64F /* Path.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535530B053814002CE64F /* Path.h */; settings = {ATTRIBUTES = (Private, ); }; }; > A99943290B42338800D7C802 /* SynchronousImageSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A99943270B42338700D7C802 /* SynchronousImageSource.cpp */; }; >@@ -12075,6 +12077,8 @@ > B275354F0B053814002CE64F /* IntPointMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntPointMac.mm; sourceTree = "<group>"; }; > B27535500B053814002CE64F /* IntRectMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntRectMac.mm; sourceTree = "<group>"; }; > B27535510B053814002CE64F /* IntSizeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntSizeMac.mm; sourceTree = "<group>"; }; >+ 5B3480910EEF50D400AC1B41 /* NonImmediateBitmapImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = NonImmediateBitmapImage.cpp; sourceTree = "<group>"; }; >+ 5B3480920EEF50D400AC1B41 /* NonImmediateBitmapImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NonImmediateBitmapImage.h; sourceTree = "<group>"; }; > B27535520B053814002CE64F /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Path.cpp; sourceTree = "<group>"; }; > B27535530B053814002CE64F /* Path.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Path.h; sourceTree = "<group>"; }; > A99943270B42338700D7C802 /* SynchronousImageSource.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronousImageSource.cpp; sourceTree = "<group>"; }; >@@ -19841,6 +19845,8 @@ > E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */, > 079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */, > 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */, >+ 5B3480910EEF50D400AC1B41 /* NonImmediateBitmapImage.cpp */, >+ 5B3480920EEF50D400AC1B41 /* NonImmediateBitmapImage.h */, > B27535520B053814002CE64F /* Path.cpp */, > B27535530B053814002CE64F /* Path.h */, > A88DD4880B4629B000C02990 /* PathTraversalState.cpp */, >@@ -24360,6 +24366,7 @@ > A7F5D9501384F02D00A29A87 /* NodeRenderingContext.h in Headers */, > 63D7B32D0E78CD3F00F7617C /* NodeRenderStyle.h in Headers */, > 9382AAB40D8C386100F357A6 /* NodeWithIndex.h in Headers */, >+ 5B3480940EEF50D400AC1B41 /* NonImmediateBitmapImage.h in Headers */, > A8EA7EBE0A1945D000A8EF5F /* Notation.h in Headers */, > 312C0C41146DC6CC0016C911 /* Notification.h in Headers */, > 3390CA560FFC157B00921962 /* NotificationCenter.h in Headers */, >@@ -27635,6 +27642,7 @@ > 854FE7320A2297BE0058D7AD /* NodeFilterCondition.cpp in Sources */, > 854FE7340A2297BE0058D7AD /* NodeIterator.cpp in Sources */, > A7F5D94F1384F02D00A29A87 /* NodeRenderingContext.cpp in Sources */, >+ 5B3480930EEF50D400AC1B41 /* NonImmediateBitmapImage.cpp in Sources */, > A8EA7EBF0A1945D000A8EF5F /* Notation.cpp in Sources */, > 33503CC71017A1B1003B47E1 /* Notification.cpp in Sources */, > 3390CA550FFC157B00921962 /* NotificationCenter.cpp in Sources */, >diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp >index e97173e1dde831bed72016e697842d9d8a71e6b9..8d58512f5d80a5b264a5471be20a5970e20200fd 100644 >--- a/Source/WebCore/platform/graphics/BitmapImage.cpp >+++ b/Source/WebCore/platform/graphics/BitmapImage.cpp >@@ -135,7 +135,12 @@ void BitmapImage::cacheFrame(size_t index) > if (m_frames.size() < numFrames) > m_frames.grow(numFrames); > >- m_source.requestFrameAtIndex(index); >+ m_source.requestFrameAtIndex(index, nonImmediateRendering()); >+} >+ >+bool BitmapImage::nonImmediateRendering() const >+{ >+ return m_nonImmediateImage.get() && m_nonImmediateImage->nonImmediateRendering(); > } > > void BitmapImage::didDecodeFrameAtIndex(size_t index, NativeImagePtr nativeImage) >diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h >index e808666e21938bd199d9f832fb5103a84c4898bc..4a8b4ac97177b8da1c1ec24c09ae940c6187873b 100644 >--- a/Source/WebCore/platform/graphics/BitmapImage.h >+++ b/Source/WebCore/platform/graphics/BitmapImage.h >@@ -34,6 +34,7 @@ > #include "ImageSource.h" > #include "ImageSourceObserver.h" > #include "IntSize.h" >+#include "NonImmediateBitmapImage.h" > > #if PLATFORM(MAC) > #include <wtf/RetainPtr.h> >@@ -101,10 +102,12 @@ public: > // ================================================= > > class BitmapImage : public Image, public ImageSourceObserver { >+ friend class NonImmediateBitmapImage; > friend class GeneratedImage; > friend class CrossfadeGeneratedImage; > friend class GeneratorGeneratedImage; > friend class GraphicsContext; >+ friend Image* toNonImmediateBitmapImageIfPossible(Image*); > public: > static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0) > { >@@ -274,6 +277,8 @@ protected: > virtual bool mayFillWithSolidColor(); > virtual Color solidColor() const; > >+ bool nonImmediateRendering() const; >+ > ImageSource m_source; > mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image). > mutable IntSize m_sizeRespectingOrientation; >@@ -298,6 +303,8 @@ protected: > mutable unsigned m_decodedPropertiesSize; // The size of data decoded by the source to determine image properties (e.g. size, frame count, etc). > size_t m_frameCount; > >+ RefPtr<NonImmediateBitmapImage> m_nonImmediateImage; >+ > bool m_isSolidColor : 1; // Whether or not we are a 1x1 solid image. > bool m_checkedForSolidColor : 1; // Whether we've checked the frame for solid color. > >diff --git a/Source/WebCore/platform/graphics/NonImmediateBitmapImage.cpp b/Source/WebCore/platform/graphics/NonImmediateBitmapImage.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..043a5f61dfe1427826299ededc1d48007c8528d0 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/NonImmediateBitmapImage.cpp >@@ -0,0 +1,134 @@ >+/* >+ * Copyright (C) 2012 Company 100 Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NonImmediateBitmapImage.h" >+ >+#include "BitmapImage.h" >+#include <wtf/TemporaryChange.h> >+ >+namespace WebCore { >+ >+PassRefPtr<NonImmediateBitmapImage> NonImmediateBitmapImage::create(BitmapImage* bitmapImage) >+{ >+ return adoptRef(new NonImmediateBitmapImage(bitmapImage)); >+} >+ >+NonImmediateBitmapImage::NonImmediateBitmapImage(BitmapImage* bitmapImage) >+ : m_bitmapImage(bitmapImage) >+ , m_nonImmediateRendering(false) >+{ >+} >+ >+bool NonImmediateBitmapImage::hasSingleSecurityOrigin() const >+{ >+ return m_bitmapImage->hasSingleSecurityOrigin(); >+} >+ >+IntSize NonImmediateBitmapImage::size() const >+{ >+ return m_bitmapImage->size(); >+} >+ >+bool NonImmediateBitmapImage::getHotSpot(IntPoint& point) const >+{ >+ return m_bitmapImage->getHotSpot(point); >+} >+ >+bool NonImmediateBitmapImage::dataChanged(bool allDataReceived) >+{ >+ return m_bitmapImage->dataChanged(allDataReceived); >+} >+ >+String NonImmediateBitmapImage::filenameExtension() const >+{ >+ return m_bitmapImage->filenameExtension(); >+} >+ >+void NonImmediateBitmapImage::destroyDecodedData(bool destroyAll) >+{ >+ m_bitmapImage->destroyDecodedData(destroyAll); >+} >+ >+unsigned NonImmediateBitmapImage::decodedSize() const >+{ >+ return m_bitmapImage->decodedSize(); >+} >+ >+void NonImmediateBitmapImage::startAnimation(bool catchUpIfNecessary) >+{ >+ m_bitmapImage->startAnimation(catchUpIfNecessary); >+} >+ >+void NonImmediateBitmapImage::stopAnimation() >+{ >+ m_bitmapImage->stopAnimation(); >+} >+ >+void NonImmediateBitmapImage::resetAnimation() >+{ >+ m_bitmapImage->resetAnimation(); >+} >+ >+NativeImagePtr NonImmediateBitmapImage::nativeImageForCurrentFrame() >+{ >+ TemporaryChange<bool> nonImmediateRenderingSaver(m_nonImmediateRendering, true); >+ return m_bitmapImage->nativeImageForCurrentFrame(); >+} >+ >+bool NonImmediateBitmapImage::currentFrameHasAlpha() >+{ >+ return m_bitmapImage->currentFrameHasAlpha(); >+} >+ >+void NonImmediateBitmapImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op) >+{ >+ TemporaryChange<bool> nonImmediateRenderingSaver(m_nonImmediateRendering, true); >+ m_bitmapImage->draw(context, dstRect, srcRect, styleColorSpace, op); >+} >+ >+bool NonImmediateBitmapImage::mayFillWithSolidColor() >+{ >+ return m_bitmapImage->mayFillWithSolidColor(); >+} >+ >+Color NonImmediateBitmapImage::solidColor() const >+{ >+ return m_bitmapImage->solidColor(); >+} >+ >+Image* toNonImmediateBitmapImageIfPossible(Image* image) >+{ >+ if (image && image->isBitmapImage()) { >+ BitmapImage* bitmapImage = static_cast<BitmapImage*>(image); >+ if (!bitmapImage->m_nonImmediateImage) >+ bitmapImage->m_nonImmediateImage = NonImmediateBitmapImage::create(bitmapImage); >+ >+ return bitmapImage->m_nonImmediateImage.get(); >+ } >+ return image; >+} >+ >+} >diff --git a/Source/WebCore/platform/graphics/NonImmediateBitmapImage.h b/Source/WebCore/platform/graphics/NonImmediateBitmapImage.h >new file mode 100644 >index 0000000000000000000000000000000000000000..daddf709e595a71e3a552a4bef92995369afbc9a >--- /dev/null >+++ b/Source/WebCore/platform/graphics/NonImmediateBitmapImage.h >@@ -0,0 +1,85 @@ >+/* >+ * Copyright (C) 2012 Company 100 Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef NonImmediateBitmapImage_h >+#define NonImmediateBitmapImage_h >+ >+#include "Image.h" >+ >+namespace WebCore { >+ >+class BitmapImage; >+class GraphicsContext; >+ >+// NonImmediateBitmapImage is used in order to mark it is safe to decode asynchronously. >+// Clients only use this class when they call nativeImageForCurrentFrame() and GraphicsContext::drawImage(toNonImmediateBitmapImageIfPossible(image)). >+// Although clients can call only nativeImageForCurrentFrame(), NonImmediateBitmapImage overrides all virtual methods of Image, >+// because GraphicsContext::drawImage() can call other virtual methods. >+// For instance, in current code, GraphicsContext::drawImage() calls size(), which is a virtual methods of Image. >+class NonImmediateBitmapImage : public Image { >+ friend class GraphicsContext; >+public: >+ static PassRefPtr<NonImmediateBitmapImage> create(BitmapImage*); >+ >+ virtual ~NonImmediateBitmapImage() { } >+ >+ virtual NativeImagePtr nativeImageForCurrentFrame() OVERRIDE; >+ >+ inline bool nonImmediateRendering() const { return m_nonImmediateRendering; } >+ >+private: >+ explicit NonImmediateBitmapImage(BitmapImage*); >+ >+ virtual bool currentFrameHasAlpha() OVERRIDE; >+ >+ virtual bool hasSingleSecurityOrigin() const OVERRIDE; >+ >+ virtual IntSize size() const OVERRIDE; >+ virtual bool getHotSpot(IntPoint&) const OVERRIDE; >+ >+ virtual bool dataChanged(bool allDataReceived) OVERRIDE; >+ virtual String filenameExtension() const OVERRIDE; >+ >+ virtual void destroyDecodedData(bool destroyAll = true) OVERRIDE; >+ virtual unsigned decodedSize() const OVERRIDE; >+ >+ virtual void startAnimation(bool catchUpIfNecessary = true) OVERRIDE; >+ virtual void stopAnimation() OVERRIDE; >+ virtual void resetAnimation() OVERRIDE; >+ >+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator) OVERRIDE; >+ >+ virtual bool mayFillWithSolidColor() OVERRIDE; >+ virtual Color solidColor() const OVERRIDE; >+ >+ BitmapImage* m_bitmapImage; >+ mutable bool m_nonImmediateRendering; >+}; >+ >+Image* toNonImmediateBitmapImageIfPossible(Image*); >+ >+} >+ >+#endif >diff --git a/Source/WebCore/rendering/RenderImage.cpp b/Source/WebCore/rendering/RenderImage.cpp >index 48ea05470ddf04bd1042d5eb30c16bfce78d3b14..b92c243fcb5c48cf2a04cc25883a07207e015325 100644 >--- a/Source/WebCore/rendering/RenderImage.cpp >+++ b/Source/WebCore/rendering/RenderImage.cpp >@@ -328,7 +328,7 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf > if (centerY < 0) > centerY = 0; > imageOffset = LayoutSize(leftBorder + leftPad + centerX + 1, topBorder + topPad + centerY + 1); >- context->drawImage(image.get(), style()->colorSpace(), IntRect(roundedIntPoint(paintOffset + imageOffset), imageSize), CompositeSourceOver, shouldRespectImageOrientation()); >+ context->drawImage(toNonImmediateBitmapImageIfPossible(image.get()), style()->colorSpace(), IntRect(roundedIntPoint(paintOffset + imageOffset), imageSize), CompositeSourceOver, shouldRespectImageOrientation()); > errorPictureDrawn = true; > } > >@@ -450,7 +450,7 @@ void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect > CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver; > Image* image = m_imageResource->image().get(); > bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size()); >- context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, shouldRespectImageOrientation(), useLowQualityScaling); >+ context->drawImage(toNonImmediateBitmapImageIfPossible(m_imageResource->image(alignedRect.width(), alignedRect.height()).get()), style()->colorSpace(), alignedRect, compositeOperator, shouldRespectImageOrientation(), useLowQualityScaling); > } > > bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const >diff --git a/Source/WebCore/rendering/svg/RenderSVGImage.cpp b/Source/WebCore/rendering/svg/RenderSVGImage.cpp >index 56be5cd416bcde26e0a855be1adcea2b43fc0b95..5d88772101793c54558ec2dea88f992b7ababa48 100644 >--- a/Source/WebCore/rendering/svg/RenderSVGImage.cpp >+++ b/Source/WebCore/rendering/svg/RenderSVGImage.cpp >@@ -33,6 +33,7 @@ > #include "FloatQuad.h" > #include "GraphicsContext.h" > #include "LayoutRepainter.h" >+#include "NonImmediateBitmapImage.h" > #include "PointerEventsHitRules.h" > #include "RenderImageResource.h" > #include "RenderLayer.h" >@@ -134,7 +135,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&) > SVGImageElement* imageElement = static_cast<SVGImageElement*>(node()); > imageElement->preserveAspectRatio().transformRect(destRect, srcRect); > >- childPaintInfo.context->drawImage(image.get(), ColorSpaceDeviceRGB, destRect, srcRect); >+ childPaintInfo.context->drawImage(toNonImmediateBitmapImageIfPossible(image.get()), ColorSpaceDeviceRGB, destRect, srcRect); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 93590
:
157418
|
157704
| 158722