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