2013-03-10 18:43:38 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-14 20:52:05 -07:00
|
|
|
#ifndef mozilla_image_ImageWrapper_h
|
|
|
|
#define mozilla_image_ImageWrapper_h
|
2013-03-10 18:43:38 -07:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-03-10 18:43:38 -07:00
|
|
|
#include "Image.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract superclass for Images that wrap other Images.
|
|
|
|
*/
|
|
|
|
class ImageWrapper : public Image
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_IMGICONTAINER
|
|
|
|
|
|
|
|
// Inherited methods from Image.
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
|
2013-03-10 18:43:38 -07:00
|
|
|
|
2014-12-04 11:43:00 -08:00
|
|
|
virtual size_t
|
2015-04-28 11:46:17 -07:00
|
|
|
SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const override;
|
|
|
|
virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
|
|
|
|
MallocSizeOf aMallocSizeOf) const override;
|
2014-05-08 02:53:00 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void IncrementAnimationConsumers() override;
|
|
|
|
virtual void DecrementAnimationConsumers() override;
|
2013-03-10 18:43:38 -07:00
|
|
|
#ifdef DEBUG
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint32_t GetAnimationConsumers() override;
|
2013-03-10 18:43:38 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
2015-03-21 09:28:04 -07:00
|
|
|
uint32_t aCount) override;
|
2013-03-10 18:43:38 -07:00
|
|
|
virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsresult aStatus,
|
2015-03-21 09:28:04 -07:00
|
|
|
bool aLastPart) override;
|
2013-03-10 18:43:38 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void OnSurfaceDiscarded() override;
|
2014-11-27 19:55:57 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
|
|
|
|
virtual uint64_t InnerWindowID() const override;
|
2013-03-10 18:43:38 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual bool HasError() override;
|
|
|
|
virtual void SetHasError() override;
|
2013-03-10 18:43:38 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual ImageURL* GetURI() override;
|
2013-03-10 18:43:38 -07:00
|
|
|
|
|
|
|
protected:
|
2014-09-02 09:20:24 -07:00
|
|
|
explicit ImageWrapper(Image* aInnerImage)
|
2013-03-10 18:43:38 -07:00
|
|
|
: mInnerImage(aInnerImage)
|
|
|
|
{
|
2015-01-07 01:37:20 -08:00
|
|
|
MOZ_ASSERT(aInnerImage, "Need an image to wrap");
|
2013-03-10 18:43:38 -07:00
|
|
|
}
|
|
|
|
|
2014-06-23 11:49:08 -07:00
|
|
|
virtual ~ImageWrapper() { }
|
|
|
|
|
2013-03-10 18:43:38 -07:00
|
|
|
/**
|
|
|
|
* Returns a weak reference to the inner image wrapped by this ImageWrapper.
|
|
|
|
*/
|
2015-01-07 01:37:20 -08:00
|
|
|
Image* InnerImage() const { return mInnerImage.get(); }
|
|
|
|
|
|
|
|
void SetInnerImage(Image* aInnerImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aInnerImage, "Need an image to wrap");
|
|
|
|
mInnerImage = aInnerImage;
|
|
|
|
}
|
2013-03-10 18:43:38 -07:00
|
|
|
|
|
|
|
private:
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<Image> mInnerImage;
|
2013-03-10 18:43:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-14 20:52:05 -07:00
|
|
|
#endif // mozilla_image_ImageWrapper_h
|