michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ImageWrapper.h" michael@0: #include "mozilla/gfx/2D.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "Orientation.h" michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: michael@0: using mozilla::gfx::DataSourceSurface; michael@0: using mozilla::gfx::SourceSurface; michael@0: using mozilla::layers::LayerManager; michael@0: using mozilla::layers::ImageContainer; michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: // Inherited methods from Image. michael@0: michael@0: nsresult michael@0: ImageWrapper::Init(const char* aMimeType, uint32_t aFlags) michael@0: { michael@0: return mInnerImage->Init(aMimeType, aFlags); michael@0: } michael@0: michael@0: already_AddRefed michael@0: ImageWrapper::GetStatusTracker() michael@0: { michael@0: return mInnerImage->GetStatusTracker(); michael@0: } michael@0: michael@0: nsIntRect michael@0: ImageWrapper::FrameRect(uint32_t aWhichFrame) michael@0: { michael@0: return mInnerImage->FrameRect(aWhichFrame); michael@0: } michael@0: michael@0: uint32_t michael@0: ImageWrapper::SizeOfData() michael@0: { michael@0: return mInnerImage->SizeOfData(); michael@0: } michael@0: michael@0: size_t michael@0: ImageWrapper::HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const michael@0: { michael@0: return mInnerImage->HeapSizeOfSourceWithComputedFallback(aMallocSizeOf); michael@0: } michael@0: michael@0: size_t michael@0: ImageWrapper::HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const michael@0: { michael@0: return mInnerImage->HeapSizeOfDecodedWithComputedFallback(aMallocSizeOf); michael@0: } michael@0: michael@0: size_t michael@0: ImageWrapper::NonHeapSizeOfDecoded() const michael@0: { michael@0: return mInnerImage->NonHeapSizeOfDecoded(); michael@0: } michael@0: michael@0: size_t michael@0: ImageWrapper::OutOfProcessSizeOfDecoded() const michael@0: { michael@0: return mInnerImage->OutOfProcessSizeOfDecoded(); michael@0: } michael@0: michael@0: void michael@0: ImageWrapper::IncrementAnimationConsumers() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization " michael@0: "with DecrementAnimationConsumers"); michael@0: mInnerImage->IncrementAnimationConsumers(); michael@0: } michael@0: michael@0: void michael@0: ImageWrapper::DecrementAnimationConsumers() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization " michael@0: "with IncrementAnimationConsumers"); michael@0: mInnerImage->DecrementAnimationConsumers(); michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: uint32_t michael@0: ImageWrapper::GetAnimationConsumers() michael@0: { michael@0: return mInnerImage->GetAnimationConsumers(); michael@0: } michael@0: #endif michael@0: michael@0: nsresult michael@0: ImageWrapper::OnImageDataAvailable(nsIRequest* aRequest, michael@0: nsISupports* aContext, michael@0: nsIInputStream* aInStr, michael@0: uint64_t aSourceOffset, michael@0: uint32_t aCount) michael@0: { michael@0: return mInnerImage->OnImageDataAvailable(aRequest, aContext, aInStr, michael@0: aSourceOffset, aCount); michael@0: } michael@0: michael@0: nsresult michael@0: ImageWrapper::OnImageDataComplete(nsIRequest* aRequest, michael@0: nsISupports* aContext, michael@0: nsresult aStatus, michael@0: bool aLastPart) michael@0: { michael@0: return mInnerImage->OnImageDataComplete(aRequest, aContext, aStatus, aLastPart); michael@0: } michael@0: michael@0: nsresult michael@0: ImageWrapper::OnNewSourceData() michael@0: { michael@0: return mInnerImage->OnNewSourceData(); michael@0: } michael@0: michael@0: void michael@0: ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId) michael@0: { michael@0: mInnerImage->SetInnerWindowID(aInnerWindowId); michael@0: } michael@0: michael@0: uint64_t michael@0: ImageWrapper::InnerWindowID() const michael@0: { michael@0: return mInnerImage->InnerWindowID(); michael@0: } michael@0: michael@0: bool michael@0: ImageWrapper::HasError() michael@0: { michael@0: return mInnerImage->HasError(); michael@0: } michael@0: michael@0: void michael@0: ImageWrapper::SetHasError() michael@0: { michael@0: mInnerImage->SetHasError(); michael@0: } michael@0: michael@0: ImageURL* michael@0: ImageWrapper::GetURI() michael@0: { michael@0: return mInnerImage->GetURI(); michael@0: } michael@0: michael@0: // Methods inherited from XPCOM interfaces. michael@0: michael@0: NS_IMPL_ISUPPORTS(ImageWrapper, imgIContainer) michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetWidth(int32_t* aWidth) michael@0: { michael@0: return mInnerImage->GetWidth(aWidth); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetHeight(int32_t* aHeight) michael@0: { michael@0: return mInnerImage->GetHeight(aHeight); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetIntrinsicSize(nsSize* aSize) michael@0: { michael@0: return mInnerImage->GetIntrinsicSize(aSize); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetIntrinsicRatio(nsSize* aSize) michael@0: { michael@0: return mInnerImage->GetIntrinsicRatio(aSize); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(Orientation) michael@0: ImageWrapper::GetOrientation() michael@0: { michael@0: return mInnerImage->GetOrientation(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetType(uint16_t* aType) michael@0: { michael@0: return mInnerImage->GetType(aType); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(uint16_t) michael@0: ImageWrapper::GetType() michael@0: { michael@0: return mInnerImage->GetType(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetAnimated(bool* aAnimated) michael@0: { michael@0: return mInnerImage->GetAnimated(aAnimated); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(TemporaryRef) michael@0: ImageWrapper::GetFrame(uint32_t aWhichFrame, michael@0: uint32_t aFlags) michael@0: { michael@0: return mInnerImage->GetFrame(aWhichFrame, aFlags); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(bool) michael@0: ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame) michael@0: { michael@0: return mInnerImage->FrameIsOpaque(aWhichFrame); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetImageContainer(LayerManager* aManager, ImageContainer** _retval) michael@0: { michael@0: return mInnerImage->GetImageContainer(aManager, _retval); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::Draw(gfxContext* aContext, michael@0: GraphicsFilter aFilter, michael@0: const gfxMatrix& aUserSpaceToImageSpace, michael@0: const gfxRect& aFill, michael@0: const nsIntRect& aSubimage, michael@0: const nsIntSize& aViewportSize, michael@0: const SVGImageContext* aSVGContext, michael@0: uint32_t aWhichFrame, michael@0: uint32_t aFlags) michael@0: { michael@0: return mInnerImage->Draw(aContext, aFilter, aUserSpaceToImageSpace, aFill, michael@0: aSubimage, aViewportSize, aSVGContext, aWhichFrame, michael@0: aFlags); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::RequestDecode() michael@0: { michael@0: return mInnerImage->RequestDecode(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::StartDecoding() michael@0: { michael@0: return mInnerImage->StartDecoding(); michael@0: } michael@0: michael@0: bool michael@0: ImageWrapper::IsDecoded() michael@0: { michael@0: return mInnerImage->IsDecoded(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::LockImage() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread(), michael@0: "Main thread to encourage serialization with UnlockImage"); michael@0: return mInnerImage->LockImage(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::UnlockImage() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread(), michael@0: "Main thread to encourage serialization with LockImage"); michael@0: return mInnerImage->UnlockImage(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::RequestDiscard() michael@0: { michael@0: return mInnerImage->RequestDiscard(); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(void) michael@0: ImageWrapper::RequestRefresh(const mozilla::TimeStamp& aTime) michael@0: { michael@0: return mInnerImage->RequestRefresh(aTime); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::GetAnimationMode(uint16_t* aAnimationMode) michael@0: { michael@0: return mInnerImage->GetAnimationMode(aAnimationMode); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::SetAnimationMode(uint16_t aAnimationMode) michael@0: { michael@0: return mInnerImage->SetAnimationMode(aAnimationMode); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: ImageWrapper::ResetAnimation() michael@0: { michael@0: return mInnerImage->ResetAnimation(); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(float) michael@0: ImageWrapper::GetFrameIndex(uint32_t aWhichFrame) michael@0: { michael@0: return mInnerImage->GetFrameIndex(aWhichFrame); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(int32_t) michael@0: ImageWrapper::GetFirstFrameDelay() michael@0: { michael@0: return mInnerImage->GetFirstFrameDelay(); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(void) michael@0: ImageWrapper::SetAnimationStartTime(const mozilla::TimeStamp& aTime) michael@0: { michael@0: mInnerImage->SetAnimationStartTime(aTime); michael@0: } michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla