Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/image/FrozenImage.h
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#ifndef mozilla_image_FrozenImage_h
7
#define mozilla_image_FrozenImage_h
8
9
#include "ImageWrapper.h"
10
#include "mozilla/gfx/2D.h"
11
#include "mozilla/RefPtr.h"
12
13
namespace mozilla {
14
namespace image {
15
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 gfx::SourceSurface SourceSurface;
30
31
public:
32
  NS_INLINE_DECL_REFCOUNTING_INHERITED(FrozenImage, ImageWrapper)
33
34
  virtual void IncrementAnimationConsumers() override;
35
  virtual void DecrementAnimationConsumers() override;
36
37
  NS_IMETHOD GetAnimated(bool* aAnimated) override;
38
  NS_IMETHOD_(already_AddRefed<SourceSurface>)
39
    GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
40
  NS_IMETHOD_(already_AddRefed<SourceSurface>)
41
    GetFrameAtSize(const gfx::IntSize& aSize,
42
                   uint32_t aWhichFrame,
43
                   uint32_t aFlags) override;
44
  NS_IMETHOD_(bool) IsImageContainerAvailable(layers::LayerManager* aManager,
45
                                              uint32_t aFlags) override;
46
  NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
47
    GetImageContainer(layers::LayerManager* aManager,
48
                      uint32_t aFlags) override;
49
  NS_IMETHOD_(bool)
50
    IsImageContainerAvailableAtSize(layers::LayerManager* aManager,
51
                                    const gfx::IntSize& aSize,
52
                                    uint32_t aFlags) override;
53
  NS_IMETHOD_(ImgDrawResult)
54
    GetImageContainerAtSize(layers::LayerManager* aManager,
55
                            const gfx::IntSize& aSize,
56
                            const Maybe<SVGImageContext>& aSVGContext,
57
                            uint32_t aFlags,
58
                            layers::ImageContainer** aOutContainer) override;
59
  NS_IMETHOD_(ImgDrawResult) Draw(gfxContext* aContext,
60
                               const nsIntSize& aSize,
61
                               const ImageRegion& aRegion,
62
                               uint32_t aWhichFrame,
63
                               gfx::SamplingFilter aSamplingFilter,
64
                               const Maybe<SVGImageContext>& aSVGContext,
65
                               uint32_t aFlags,
66
                               float aOpacity) override;
67
  NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) override;
68
  NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) override;
69
  NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) override;
70
  NS_IMETHOD ResetAnimation() override;
71
  NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) override;
72
73
protected:
74
0
  explicit FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
75
0
  virtual ~FrozenImage() { }
76
77
private:
78
  friend class ImageOps;
79
};
80
81
} // namespace image
82
} // namespace mozilla
83
84
#endif // mozilla_image_FrozenImage_h