image/src/FrozenImage.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/src/FrozenImage.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_IMAGELIB_FROZENIMAGE_H_
    1.10 +#define MOZILLA_IMAGELIB_FROZENIMAGE_H_
    1.11 +
    1.12 +#include "ImageWrapper.h"
    1.13 +#include "mozilla/gfx/2D.h"
    1.14 +#include "mozilla/RefPtr.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace image {
    1.18 +
    1.19 +/**
    1.20 + * An Image wrapper that disables animation, freezing the image at its first
    1.21 + * frame. It does this using two strategies. If this is the only instance of the
    1.22 + * image, animation will never start, because IncrementAnimationConsumers is
    1.23 + * ignored. If there is another instance that is animated, that's still OK,
    1.24 + * because any imgIContainer method that is affected by animation gets its
    1.25 + * aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage.
    1.26 + *
    1.27 + * XXX(seth): There a known (performance, not correctness) issue with
    1.28 + * GetImageContainer. See the comments for that method for more information.
    1.29 + */
    1.30 +class FrozenImage : public ImageWrapper
    1.31 +{
    1.32 +  typedef mozilla::gfx::SourceSurface SourceSurface;
    1.33 +
    1.34 +public:
    1.35 +  NS_DECL_ISUPPORTS
    1.36 +
    1.37 +  virtual ~FrozenImage() { }
    1.38 +
    1.39 +  virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
    1.40 +  virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
    1.41 +  virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
    1.42 +
    1.43 +  NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
    1.44 +  NS_IMETHOD_(TemporaryRef<SourceSurface>)
    1.45 +    GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
    1.46 +  NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
    1.47 +  NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
    1.48 +                               layers::ImageContainer** _retval) MOZ_OVERRIDE;
    1.49 +  NS_IMETHOD Draw(gfxContext* aContext,
    1.50 +                  GraphicsFilter aFilter,
    1.51 +                  const gfxMatrix& aUserSpaceToImageSpace,
    1.52 +                  const gfxRect& aFill,
    1.53 +                  const nsIntRect& aSubimage,
    1.54 +                  const nsIntSize& aViewportSize,
    1.55 +                  const SVGImageContext* aSVGContext,
    1.56 +                  uint32_t aWhichFrame,
    1.57 +                  uint32_t aFlags) MOZ_OVERRIDE;
    1.58 +  NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime) MOZ_OVERRIDE;
    1.59 +  NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
    1.60 +  NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
    1.61 +  NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
    1.62 +  NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
    1.63 +
    1.64 +protected:
    1.65 +  FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
    1.66 +
    1.67 +private:
    1.68 +  friend class ImageOps;
    1.69 +};
    1.70 +
    1.71 +} // namespace image
    1.72 +} // namespace mozilla
    1.73 +
    1.74 +#endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_

mercurial