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"
|
|
|
|
#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
|
|
|
|
|
|
|
using gfx::DataSourceSurface;
|
|
|
|
using gfx::SourceSurface;
|
|
|
|
using layers::LayerManager;
|
|
|
|
using layers::ImageContainer;
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
namespace image {
|
|
|
|
|
|
|
|
// Inherited methods from Image.
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ImageWrapper::Init(const char* aMimeType, uint32_t aFlags)
|
|
|
|
{
|
|
|
|
return mInnerImage->Init(aMimeType, aFlags);
|
|
|
|
}
|
|
|
|
|
2014-11-15 04:10:47 +00:00
|
|
|
already_AddRefed<ProgressTracker>
|
|
|
|
ImageWrapper::GetProgressTracker()
|
2013-03-11 01:43:38 +00:00
|
|
|
{
|
2014-11-15 04:10:47 +00:00
|
|
|
return mInnerImage->GetProgressTracker();
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect
|
|
|
|
ImageWrapper::FrameRect(uint32_t aWhichFrame)
|
|
|
|
{
|
|
|
|
return mInnerImage->FrameRect(aWhichFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ImageWrapper::SizeOfData()
|
|
|
|
{
|
|
|
|
return mInnerImage->SizeOfData();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2014-07-10 15:00:31 +00:00
|
|
|
ImageWrapper::HeapSizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const
|
2013-03-11 01:43:38 +00:00
|
|
|
{
|
|
|
|
return mInnerImage->HeapSizeOfSourceWithComputedFallback(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2014-07-10 15:00:31 +00:00
|
|
|
ImageWrapper::HeapSizeOfDecodedWithComputedFallback(MallocSizeOf aMallocSizeOf) const
|
2013-03-11 01:43:38 +00:00
|
|
|
{
|
|
|
|
return mInnerImage->HeapSizeOfDecodedWithComputedFallback(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ImageWrapper::NonHeapSizeOfDecoded() const
|
|
|
|
{
|
|
|
|
return mInnerImage->NonHeapSizeOfDecoded();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ImageWrapper::OutOfProcessSizeOfDecoded() const
|
|
|
|
{
|
|
|
|
return mInnerImage->OutOfProcessSizeOfDecoded();
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return mInnerImage->OnImageDataComplete(aRequest, aContext, aStatus, aLastPart);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ImageWrapper::OnNewSourceData()
|
|
|
|
{
|
|
|
|
return mInnerImage->OnNewSourceData();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 18:28:42 +00:00
|
|
|
ImageURL*
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::GetURI()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_(uint16_t)
|
|
|
|
ImageWrapper::GetType()
|
|
|
|
{
|
|
|
|
return mInnerImage->GetType();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetAnimated(bool* aAnimated)
|
|
|
|
{
|
|
|
|
return mInnerImage->GetAnimated(aAnimated);
|
|
|
|
}
|
|
|
|
|
2014-04-15 18:02:23 +00:00
|
|
|
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::GetFrame(uint32_t aWhichFrame,
|
2013-12-13 08:34:24 +00:00
|
|
|
uint32_t aFlags)
|
2013-03-11 01:43:38 +00:00
|
|
|
{
|
2013-12-13 08:34:24 +00:00
|
|
|
return mInnerImage->GetFrame(aWhichFrame, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame)
|
|
|
|
{
|
|
|
|
return mInnerImage->FrameIsOpaque(aWhichFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetImageContainer(LayerManager* aManager, ImageContainer** _retval)
|
|
|
|
{
|
|
|
|
return mInnerImage->GetImageContainer(aManager, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::Draw(gfxContext* aContext,
|
2014-08-22 20:12:38 +00:00
|
|
|
const nsIntSize& aSize,
|
|
|
|
const ImageRegion& aRegion,
|
2013-03-11 01:43:38 +00:00
|
|
|
uint32_t aWhichFrame,
|
2014-08-22 20:12:38 +00:00
|
|
|
GraphicsFilter aFilter,
|
|
|
|
const Maybe<SVGImageContext>& aSVGContext,
|
2013-03-11 01:43:38 +00:00
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
2014-08-22 20:12:38 +00:00
|
|
|
return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
|
|
|
|
aFilter, aSVGContext, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::RequestDecode()
|
|
|
|
{
|
|
|
|
return mInnerImage->RequestDecode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::StartDecoding()
|
|
|
|
{
|
|
|
|
return mInnerImage->StartDecoding();
|
|
|
|
}
|
|
|
|
|
2013-05-22 09:27:02 +00:00
|
|
|
bool
|
|
|
|
ImageWrapper::IsDecoded()
|
|
|
|
{
|
|
|
|
return mInnerImage->IsDecoded();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-07-28 21:27:40 +00:00
|
|
|
nsIntSize
|
|
|
|
ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame,
|
|
|
|
GraphicsFilter aFilter, uint32_t aFlags)
|
|
|
|
{
|
|
|
|
return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter, aFlags);
|
|
|
|
}
|
|
|
|
|
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
|