Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_imagelib_VectorImage_h_ |
michael@0 | 7 | #define mozilla_imagelib_VectorImage_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "Image.h" |
michael@0 | 10 | #include "nsIStreamListener.h" |
michael@0 | 11 | #include "mozilla/MemoryReporting.h" |
michael@0 | 12 | |
michael@0 | 13 | class nsIRequest; |
michael@0 | 14 | class gfxDrawable; |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace layers { |
michael@0 | 18 | class LayerManager; |
michael@0 | 19 | class ImageContainer; |
michael@0 | 20 | } |
michael@0 | 21 | namespace image { |
michael@0 | 22 | |
michael@0 | 23 | struct SVGDrawingParameters; |
michael@0 | 24 | class SVGDocumentWrapper; |
michael@0 | 25 | class SVGRootRenderingObserver; |
michael@0 | 26 | class SVGLoadEventListener; |
michael@0 | 27 | class SVGParseCompleteListener; |
michael@0 | 28 | |
michael@0 | 29 | class VectorImage : public ImageResource, |
michael@0 | 30 | public nsIStreamListener |
michael@0 | 31 | { |
michael@0 | 32 | public: |
michael@0 | 33 | NS_DECL_ISUPPORTS |
michael@0 | 34 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 35 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 36 | NS_DECL_IMGICONTAINER |
michael@0 | 37 | |
michael@0 | 38 | // (no public constructor - use ImageFactory) |
michael@0 | 39 | virtual ~VectorImage(); |
michael@0 | 40 | |
michael@0 | 41 | // Methods inherited from Image |
michael@0 | 42 | nsresult Init(const char* aMimeType, |
michael@0 | 43 | uint32_t aFlags); |
michael@0 | 44 | virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; |
michael@0 | 45 | |
michael@0 | 46 | virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 47 | virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 48 | virtual size_t NonHeapSizeOfDecoded() const; |
michael@0 | 49 | virtual size_t OutOfProcessSizeOfDecoded() const; |
michael@0 | 50 | |
michael@0 | 51 | virtual nsresult OnImageDataAvailable(nsIRequest* aRequest, |
michael@0 | 52 | nsISupports* aContext, |
michael@0 | 53 | nsIInputStream* aInStr, |
michael@0 | 54 | uint64_t aSourceOffset, |
michael@0 | 55 | uint32_t aCount) MOZ_OVERRIDE; |
michael@0 | 56 | virtual nsresult OnImageDataComplete(nsIRequest* aRequest, |
michael@0 | 57 | nsISupports* aContext, |
michael@0 | 58 | nsresult aResult, |
michael@0 | 59 | bool aLastPart) MOZ_OVERRIDE; |
michael@0 | 60 | virtual nsresult OnNewSourceData() MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Callback for SVGRootRenderingObserver. |
michael@0 | 64 | * |
michael@0 | 65 | * This just sets a dirty flag that we check in VectorImage::RequestRefresh, |
michael@0 | 66 | * which is called under the ticks of the refresh driver of any observing |
michael@0 | 67 | * documents that we may have. Only then (after all animations in this image |
michael@0 | 68 | * have been updated) do we send out "frame changed" notifications, |
michael@0 | 69 | */ |
michael@0 | 70 | void InvalidateObserversOnNextRefreshDriverTick(); |
michael@0 | 71 | |
michael@0 | 72 | // Callback for SVGParseCompleteListener. |
michael@0 | 73 | void OnSVGDocumentParsed(); |
michael@0 | 74 | |
michael@0 | 75 | // Callbacks for SVGLoadEventListener. |
michael@0 | 76 | void OnSVGDocumentLoaded(); |
michael@0 | 77 | void OnSVGDocumentError(); |
michael@0 | 78 | |
michael@0 | 79 | protected: |
michael@0 | 80 | VectorImage(imgStatusTracker* aStatusTracker = nullptr, |
michael@0 | 81 | ImageURL* aURI = nullptr); |
michael@0 | 82 | |
michael@0 | 83 | virtual nsresult StartAnimation(); |
michael@0 | 84 | virtual nsresult StopAnimation(); |
michael@0 | 85 | virtual bool ShouldAnimate(); |
michael@0 | 86 | |
michael@0 | 87 | void CreateDrawableAndShow(const SVGDrawingParameters& aParams); |
michael@0 | 88 | void Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams); |
michael@0 | 89 | |
michael@0 | 90 | private: |
michael@0 | 91 | void CancelAllListeners(); |
michael@0 | 92 | void SendInvalidationNotifications(); |
michael@0 | 93 | |
michael@0 | 94 | nsRefPtr<SVGDocumentWrapper> mSVGDocumentWrapper; |
michael@0 | 95 | nsRefPtr<SVGRootRenderingObserver> mRenderingObserver; |
michael@0 | 96 | nsRefPtr<SVGLoadEventListener> mLoadEventListener; |
michael@0 | 97 | nsRefPtr<SVGParseCompleteListener> mParseCompleteListener; |
michael@0 | 98 | |
michael@0 | 99 | bool mIsInitialized; // Have we been initalized? |
michael@0 | 100 | bool mIsFullyLoaded; // Has the SVG document finished loading? |
michael@0 | 101 | bool mIsDrawing; // Are we currently drawing? |
michael@0 | 102 | bool mHaveAnimations; // Is our SVG content SMIL-animated? |
michael@0 | 103 | // (Only set after mIsFullyLoaded.) |
michael@0 | 104 | bool mHasPendingInvalidation; // Invalidate observers next refresh |
michael@0 | 105 | // driver tick. |
michael@0 | 106 | |
michael@0 | 107 | // Initializes imgStatusTracker and resets it on RasterImage destruction. |
michael@0 | 108 | nsAutoPtr<imgStatusTrackerInit> mStatusTrackerInit; |
michael@0 | 109 | |
michael@0 | 110 | friend class ImageFactory; |
michael@0 | 111 | }; |
michael@0 | 112 | |
michael@0 | 113 | inline NS_IMETHODIMP VectorImage::GetAnimationMode(uint16_t *aAnimationMode) { |
michael@0 | 114 | return GetAnimationModeInternal(aAnimationMode); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | inline NS_IMETHODIMP VectorImage::SetAnimationMode(uint16_t aAnimationMode) { |
michael@0 | 118 | return SetAnimationModeInternal(aAnimationMode); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | } // namespace image |
michael@0 | 122 | } // namespace mozilla |
michael@0 | 123 | |
michael@0 | 124 | #endif // mozilla_imagelib_VectorImage_h_ |