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