Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/image/ImageWrapper.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_ImageWrapper_h
7
#define mozilla_image_ImageWrapper_h
8
9
#include "mozilla/MemoryReporting.h"
10
#include "Image.h"
11
12
namespace mozilla {
13
namespace image {
14
15
/**
16
 * Abstract superclass for Images that wrap other Images.
17
 */
18
class ImageWrapper : public Image
19
{
20
public:
21
  NS_DECL_ISUPPORTS
22
  NS_DECL_IMGICONTAINER
23
24
  // Inherited methods from Image.
25
  nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
26
  size_t GetNativeSizesLength() const override;
27
  virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
28
29
  virtual size_t
30
    SizeOfSourceWithComputedFallback(SizeOfState& aState) const override;
31
  virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
32
                                     MallocSizeOf aMallocSizeOf) const override;
33
34
  virtual void IncrementAnimationConsumers() override;
35
  virtual void DecrementAnimationConsumers() override;
36
#ifdef DEBUG
37
  virtual uint32_t GetAnimationConsumers() override;
38
#endif
39
40
  virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
41
                                        nsISupports* aContext,
42
                                        nsIInputStream* aInStr,
43
                                        uint64_t aSourceOffset,
44
                                        uint32_t aCount) override;
45
  virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
46
                                       nsISupports* aContext,
47
                                       nsresult aStatus,
48
                                       bool aLastPart) override;
49
50
  virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
51
52
  virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
53
  virtual uint64_t InnerWindowID() const override;
54
55
  virtual bool HasError() override;
56
  virtual void SetHasError() override;
57
58
  nsIURI* GetURI() const override;
59
60
protected:
61
  explicit ImageWrapper(Image* aInnerImage)
62
    : mInnerImage(aInnerImage)
63
0
  {
64
0
    MOZ_ASSERT(aInnerImage, "Need an image to wrap");
65
0
  }
66
67
0
  virtual ~ImageWrapper() { }
68
69
  /**
70
   * Returns a weak reference to the inner image wrapped by this ImageWrapper.
71
   */
72
0
  Image* InnerImage() const { return mInnerImage.get(); }
73
74
  void SetInnerImage(Image* aInnerImage)
75
0
  {
76
0
    MOZ_ASSERT(aInnerImage, "Need an image to wrap");
77
0
    mInnerImage = aInnerImage;
78
0
  }
79
80
private:
81
  RefPtr<Image> mInnerImage;
82
};
83
84
} // namespace image
85
} // namespace mozilla
86
87
#endif // mozilla_image_ImageWrapper_h