2013-03-11 01:43:38 +00: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/. */
|
|
|
|
|
|
|
|
#include "ImageWrapper.h"
|
2014-04-15 18:02:23 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-25 07:19:42 +00:00
|
|
|
#include "Orientation.h"
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2013-06-30 16:26:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
namespace mozilla {
|
2014-07-10 15:00:31 +00:00
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
using dom::Document;
|
2014-07-10 15:00:31 +00:00
|
|
|
using gfx::DataSourceSurface;
|
2016-06-30 17:24:27 +00:00
|
|
|
using gfx::IntSize;
|
2016-05-25 16:01:18 +00:00
|
|
|
using gfx::SamplingFilter;
|
2014-07-10 15:00:31 +00:00
|
|
|
using gfx::SourceSurface;
|
|
|
|
using layers::ImageContainer;
|
|
|
|
using layers::LayerManager;
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
namespace image {
|
|
|
|
|
|
|
|
// Inherited methods from Image.
|
|
|
|
|
2014-11-15 04:10:47 +00:00
|
|
|
already_AddRefed<ProgressTracker> ImageWrapper::GetProgressTracker() {
|
|
|
|
return mInnerImage->GetProgressTracker();
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2017-07-28 10:10:04 +00:00
|
|
|
size_t ImageWrapper::SizeOfSourceWithComputedFallback(
|
|
|
|
SizeOfState& aState) const {
|
|
|
|
return mInnerImage->SizeOfSourceWithComputedFallback(aState);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 18:46:17 +00:00
|
|
|
void ImageWrapper::CollectSizeOfSurfaces(
|
|
|
|
nsTArray<SurfaceMemoryCounter>& aCounters,
|
|
|
|
MallocSizeOf aMallocSizeOf) const {
|
|
|
|
mInnerImage->CollectSizeOfSurfaces(aCounters, aMallocSizeOf);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageWrapper::IncrementAnimationConsumers() {
|
2013-09-28 18:28:43 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Main thread only to encourage serialization "
|
|
|
|
"with DecrementAnimationConsumers");
|
2013-03-11 01:43:38 +00:00
|
|
|
mInnerImage->IncrementAnimationConsumers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageWrapper::DecrementAnimationConsumers() {
|
2013-09-28 18:28:43 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Main thread only to encourage serialization "
|
|
|
|
"with IncrementAnimationConsumers");
|
2013-03-11 01:43:38 +00:00
|
|
|
mInnerImage->DecrementAnimationConsumers();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
uint32_t ImageWrapper::GetAnimationConsumers() {
|
|
|
|
return mInnerImage->GetAnimationConsumers();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult ImageWrapper::OnImageDataAvailable(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
|
|
|
uint32_t aCount) {
|
|
|
|
return mInnerImage->OnImageDataAvailable(aRequest, aContext, aInStr,
|
|
|
|
aSourceOffset, aCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ImageWrapper::OnImageDataComplete(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsresult aStatus, bool aLastPart) {
|
2014-12-04 19:43:00 +00:00
|
|
|
return mInnerImage->OnImageDataComplete(aRequest, aContext, aStatus,
|
|
|
|
aLastPart);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2017-03-16 08:06:06 +00:00
|
|
|
void ImageWrapper::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) {
|
|
|
|
return mInnerImage->OnSurfaceDiscarded(aSurfaceKey);
|
2014-11-28 03:55:57 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
void ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId) {
|
|
|
|
mInnerImage->SetInnerWindowID(aInnerWindowId);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t ImageWrapper::InnerWindowID() const {
|
|
|
|
return mInnerImage->InnerWindowID();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageWrapper::HasError() { return mInnerImage->HasError(); }
|
|
|
|
|
|
|
|
void ImageWrapper::SetHasError() { mInnerImage->SetHasError(); }
|
|
|
|
|
|
|
|
nsIURI* ImageWrapper::GetURI() const { return mInnerImage->GetURI(); }
|
|
|
|
|
|
|
|
// Methods inherited from XPCOM interfaces.
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(ImageWrapper, imgIContainer)
|
2013-03-11 01:43:38 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetWidth(int32_t* aWidth) {
|
|
|
|
return mInnerImage->GetWidth(aWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetHeight(int32_t* aHeight) {
|
|
|
|
return mInnerImage->GetHeight(aHeight);
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:05:36 +00:00
|
|
|
nsresult ImageWrapper::GetNativeSizes(nsTArray<IntSize>& aNativeSizes) const {
|
|
|
|
return mInnerImage->GetNativeSizes(aNativeSizes);
|
|
|
|
}
|
|
|
|
|
2017-09-05 11:58:44 +00:00
|
|
|
size_t ImageWrapper::GetNativeSizesLength() const {
|
|
|
|
return mInnerImage->GetNativeSizesLength();
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetIntrinsicSize(nsSize* aSize) {
|
|
|
|
return mInnerImage->GetIntrinsicSize(aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetIntrinsicRatio(nsSize* aSize) {
|
|
|
|
return mInnerImage->GetIntrinsicRatio(aSize);
|
|
|
|
}
|
|
|
|
|
2013-08-25 07:19:42 +00:00
|
|
|
NS_IMETHODIMP_(Orientation)
|
|
|
|
ImageWrapper::GetOrientation() { return mInnerImage->GetOrientation(); }
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetType(uint16_t* aType) { return mInnerImage->GetType(aType); }
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetAnimated(bool* aAnimated) {
|
|
|
|
return mInnerImage->GetAnimated(aAnimated);
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::GetFrame(uint32_t aWhichFrame, uint32_t aFlags) {
|
2013-12-13 08:34:24 +00:00
|
|
|
return mInnerImage->GetFrame(aWhichFrame, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-19 20:34:09 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
|
|
|
ImageWrapper::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return mInnerImage->GetFrameAtSize(aSize, aWhichFrame, aFlags);
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2016-08-23 02:15:38 +00:00
|
|
|
ImageWrapper::WillDrawOpaqueNow() { return mInnerImage->WillDrawOpaqueNow(); }
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2015-05-13 07:23:44 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
ImageWrapper::IsImageContainerAvailable(LayerManager* aManager,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return mInnerImage->IsImageContainerAvailable(aManager, aFlags);
|
|
|
|
}
|
|
|
|
|
2015-03-18 02:40:16 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
|
|
|
ImageWrapper::GetImageContainer(LayerManager* aManager, uint32_t aFlags) {
|
|
|
|
return mInnerImage->GetImageContainer(aManager, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 11:45:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
ImageWrapper::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|
|
|
const IntSize& aSize,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return mInnerImage->IsImageContainerAvailableAtSize(aManager, aSize, aFlags);
|
|
|
|
}
|
|
|
|
|
2018-09-13 23:48:21 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
|
|
|
ImageWrapper::GetImageContainerAtSize(layers::LayerManager* aManager,
|
|
|
|
const gfx::IntSize& aSize,
|
2017-11-17 19:08:52 +00:00
|
|
|
const Maybe<SVGImageContext>& aSVGContext,
|
2018-09-13 23:48:21 +00:00
|
|
|
uint32_t aFlags,
|
|
|
|
layers::ImageContainer** aOutContainer) {
|
|
|
|
return mInnerImage->GetImageContainerAtSize(aManager, aSize, aSVGContext,
|
|
|
|
aFlags, aOutContainer);
|
2017-11-17 11:45:26 +00:00
|
|
|
}
|
|
|
|
|
2017-12-11 15:37:59 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
2014-08-22 20:12:38 +00:00
|
|
|
const ImageRegion& aRegion, uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter aSamplingFilter,
|
2014-08-22 20:12:38 +00:00
|
|
|
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
|
2017-01-03 05:53:22 +00:00
|
|
|
float aOpacity) {
|
2014-08-22 20:12:38 +00:00
|
|
|
return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
|
2017-01-03 05:53:22 +00:00
|
|
|
aSamplingFilter, aSVGContext, aFlags, aOpacity);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-11-26 07:56:26 +00:00
|
|
|
ImageWrapper::StartDecoding(uint32_t aFlags) {
|
|
|
|
return mInnerImage->StartDecoding(aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2016-12-23 07:07:45 +00:00
|
|
|
bool ImageWrapper::StartDecodingWithResult(uint32_t aFlags) {
|
|
|
|
return mInnerImage->StartDecodingWithResult(aFlags);
|
|
|
|
}
|
|
|
|
|
2015-01-18 22:02:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) {
|
|
|
|
return mInnerImage->RequestDecodeForSize(aSize, aFlags);
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::LockImage() {
|
2013-09-28 18:28:43 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Main thread to encourage serialization with UnlockImage");
|
2013-03-11 01:43:38 +00:00
|
|
|
return mInnerImage->LockImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::UnlockImage() {
|
2013-09-28 18:28:43 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Main thread to encourage serialization with LockImage");
|
2013-03-11 01:43:38 +00:00
|
|
|
return mInnerImage->UnlockImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::RequestDiscard() { return mInnerImage->RequestDiscard(); }
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
2014-07-10 15:00:31 +00:00
|
|
|
ImageWrapper::RequestRefresh(const TimeStamp& aTime) {
|
2013-03-11 01:43:38 +00:00
|
|
|
return mInnerImage->RequestRefresh(aTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetAnimationMode(uint16_t* aAnimationMode) {
|
|
|
|
return mInnerImage->GetAnimationMode(aAnimationMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::SetAnimationMode(uint16_t aAnimationMode) {
|
|
|
|
return mInnerImage->SetAnimationMode(aAnimationMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::ResetAnimation() { return mInnerImage->ResetAnimation(); }
|
|
|
|
|
2013-04-25 22:58:20 +00:00
|
|
|
NS_IMETHODIMP_(float)
|
|
|
|
ImageWrapper::GetFrameIndex(uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->GetFrameIndex(aWhichFrame);
|
|
|
|
}
|
|
|
|
|
2013-05-17 17:42:20 +00:00
|
|
|
NS_IMETHODIMP_(int32_t)
|
|
|
|
ImageWrapper::GetFirstFrameDelay() { return mInnerImage->GetFirstFrameDelay(); }
|
|
|
|
|
2013-05-17 20:57:20 +00:00
|
|
|
NS_IMETHODIMP_(void)
|
2014-07-10 15:00:31 +00:00
|
|
|
ImageWrapper::SetAnimationStartTime(const TimeStamp& aTime) {
|
2013-05-17 20:57:20 +00:00
|
|
|
mInnerImage->SetAnimationStartTime(aTime);
|
|
|
|
}
|
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
void ImageWrapper::PropagateUseCounters(Document* aParentDocument) {
|
2015-06-03 17:42:07 +00:00
|
|
|
mInnerImage->PropagateUseCounters(aParentDocument);
|
|
|
|
}
|
|
|
|
|
2014-12-04 19:43:00 +00:00
|
|
|
nsIntSize ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest,
|
|
|
|
uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter aSamplingFilter,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame,
|
|
|
|
aSamplingFilter, aFlags);
|
2014-07-28 21:27:40 +00:00
|
|
|
}
|
|
|
|
|
2014-06-26 23:02:04 +00:00
|
|
|
NS_IMETHODIMP_(nsIntRect)
|
|
|
|
ImageWrapper::GetImageSpaceInvalidationRect(const nsIntRect& aRect) {
|
|
|
|
return mInnerImage->GetImageSpaceInvalidationRect(aRect);
|
|
|
|
}
|
|
|
|
|
2014-06-28 03:50:26 +00:00
|
|
|
already_AddRefed<imgIContainer> ImageWrapper::Unwrap() {
|
|
|
|
return mInnerImage->Unwrap();
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|