image/src/FrozenImage.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef MOZILLA_IMAGELIB_FROZENIMAGE_H_
     7 #define MOZILLA_IMAGELIB_FROZENIMAGE_H_
     9 #include "ImageWrapper.h"
    10 #include "mozilla/gfx/2D.h"
    11 #include "mozilla/RefPtr.h"
    13 namespace mozilla {
    14 namespace image {
    16 /**
    17  * An Image wrapper that disables animation, freezing the image at its first
    18  * frame. It does this using two strategies. If this is the only instance of the
    19  * image, animation will never start, because IncrementAnimationConsumers is
    20  * ignored. If there is another instance that is animated, that's still OK,
    21  * because any imgIContainer method that is affected by animation gets its
    22  * aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage.
    23  *
    24  * XXX(seth): There a known (performance, not correctness) issue with
    25  * GetImageContainer. See the comments for that method for more information.
    26  */
    27 class FrozenImage : public ImageWrapper
    28 {
    29   typedef mozilla::gfx::SourceSurface SourceSurface;
    31 public:
    32   NS_DECL_ISUPPORTS
    34   virtual ~FrozenImage() { }
    36   virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
    37   virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
    38   virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
    40   NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
    41   NS_IMETHOD_(TemporaryRef<SourceSurface>)
    42     GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
    43   NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
    44   NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
    45                                layers::ImageContainer** _retval) MOZ_OVERRIDE;
    46   NS_IMETHOD Draw(gfxContext* aContext,
    47                   GraphicsFilter aFilter,
    48                   const gfxMatrix& aUserSpaceToImageSpace,
    49                   const gfxRect& aFill,
    50                   const nsIntRect& aSubimage,
    51                   const nsIntSize& aViewportSize,
    52                   const SVGImageContext* aSVGContext,
    53                   uint32_t aWhichFrame,
    54                   uint32_t aFlags) MOZ_OVERRIDE;
    55   NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime) MOZ_OVERRIDE;
    56   NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
    57   NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
    58   NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
    59   NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
    61 protected:
    62   FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
    64 private:
    65   friend class ImageOps;
    66 };
    68 } // namespace image
    69 } // namespace mozilla
    71 #endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_

mercurial