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
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
using dom::Document;
|
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::ImageContainer;
|
|
|
|
using layers::LayerManager;
|
|
|
|
|
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() {
|
|
|
|
return mInnerImage->GetProgressTracker();
|
2013-03-11 05:43:38 +04:00
|
|
|
}
|
|
|
|
|
2017-07-28 13:10:04 +03:00
|
|
|
size_t ImageWrapper::SizeOfSourceWithComputedFallback(
|
|
|
|
SizeOfState& aState) const {
|
|
|
|
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 {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-03-16 11:06:06 +03:00
|
|
|
void ImageWrapper::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) {
|
|
|
|
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(); }
|
|
|
|
|
|
|
|
nsIURI* ImageWrapper::GetURI() const { 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);
|
|
|
|
}
|
|
|
|
|
2019-05-03 02:28:21 +03:00
|
|
|
Maybe<AspectRatio> ImageWrapper::GetIntrinsicRatio() {
|
|
|
|
return mInnerImage->GetIntrinsicRatio();
|
2013-03-11 05:43:38 +04:00
|
|
|
}
|
|
|
|
|
2020-04-01 00:16:39 +03:00
|
|
|
nsresult ImageWrapper::GetHotspotX(int32_t* aX) {
|
|
|
|
return Image::GetHotspotX(aX);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ImageWrapper::GetHotspotY(int32_t* aY) {
|
|
|
|
return Image::GetHotspotY(aY);
|
|
|
|
}
|
|
|
|
|
2013-08-25 11:19:42 +04:00
|
|
|
NS_IMETHODIMP_(Orientation)
|
|
|
|
ImageWrapper::GetOrientation() { return mInnerImage->GetOrientation(); }
|
|
|
|
|
2020-04-17 05:57:30 +03:00
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
ImageWrapper::HandledOrientation() { return mInnerImage->HandledOrientation(); }
|
|
|
|
|
2013-03-11 05:43:38 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetType(uint16_t* aType) { return mInnerImage->GetType(aType); }
|
|
|
|
|
2019-02-13 22:13:55 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetProducerId(uint32_t* aId) {
|
|
|
|
return mInnerImage->GetProducerId(aId);
|
|
|
|
}
|
|
|
|
|
2013-03-11 05:43:38 +04:00
|
|
|
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, uint32_t aFlags) {
|
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() { 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) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-09-14 02:48:21 +03:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
|
|
|
ImageWrapper::GetImageContainerAtSize(layers::LayerManager* aManager,
|
|
|
|
const gfx::IntSize& aSize,
|
2017-11-17 22:08:52 +03:00
|
|
|
const Maybe<SVGImageContext>& aSVGContext,
|
2018-09-14 02:48:21 +03:00
|
|
|
uint32_t aFlags,
|
|
|
|
layers::ImageContainer** aOutContainer) {
|
|
|
|
return mInnerImage->GetImageContainerAtSize(aManager, aSize, aSVGContext,
|
|
|
|
aFlags, aOutContainer);
|
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, const nsIntSize& aSize,
|
2014-08-23 00:12:38 +04:00
|
|
|
const ImageRegion& aRegion, 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, uint32_t aFlags,
|
2017-01-03 08:53:22 +03:00
|
|
|
float aOpacity) {
|
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
|
2019-05-21 20:34:14 +03:00
|
|
|
ImageWrapper::StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->StartDecoding(aFlags, aWhichFrame);
|
2013-03-11 05:43:38 +04:00
|
|
|
}
|
|
|
|
|
2019-05-21 20:34:14 +03:00
|
|
|
bool ImageWrapper::StartDecodingWithResult(uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->StartDecodingWithResult(aFlags, aWhichFrame);
|
2016-12-23 10:07:45 +03:00
|
|
|
}
|
|
|
|
|
2020-04-21 00:04:45 +03:00
|
|
|
imgIContainer::DecodeResult ImageWrapper::RequestDecodeWithResult(
|
|
|
|
uint32_t aFlags, uint32_t aWhichFrame) {
|
2019-05-21 20:34:14 +03:00
|
|
|
return mInnerImage->RequestDecodeWithResult(aFlags, aWhichFrame);
|
2018-11-08 20:45:50 +03:00
|
|
|
}
|
|
|
|
|
2015-01-19 01:02:13 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-21 20:34:14 +03:00
|
|
|
ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->RequestDecodeForSize(aSize, aFlags, aWhichFrame);
|
2015-01-19 01:02:13 +03:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
Bug 1656114 - Part 4: Accumulate page use counters in the parent process. r=emilio,nika
This changes the way we deal with page use counters so that we can
handle out of process iframes.
Currently, when a parent document is being destroyed, we poke into all
of the sub-documents to merge their use counters into the parent's page
use counters, which we then report via Telemetry. With Fission enabled,
the sub-documents may be out of process. We can't simply turn these
into async IPC calls, since the parent document will be destroyed
shortly, as might the content processes holding the sub-documents.
So instead, each document during its initialization identifies which
ancestor document it will contribute its page use counters to, and
stores its WindowContext id to identify that ancestor. A message is
sent to the parent process to notify it that page use counter data will
be sent at some later point. That later point is when the document
loses its window. It doesn't matter if the ancestor document has
already been destroyed at this point, since all we need is its
WindowContext id to uniquely identify it. Once the parent process has
received all of the use counters it expects to accumulate to a given
WindowContext Id, it reports them via Telemetry.
Reporting of document use counters remains unchanged and is done by each
document in their content process.
While we're here, we also:
* Limit use counters to be reported for a pre-defined set of document
URL schemes, rather than be based on the document principal.
* Add proper MOZ_LOG logging for use counters instead of printfs.
Differential Revision: https://phabricator.services.mozilla.com/D87188
2020-10-12 01:03:43 +03:00
|
|
|
void ImageWrapper::PropagateUseCounters(Document* aReferencingDocument) {
|
|
|
|
mInnerImage->PropagateUseCounters(aReferencingDocument);
|
2015-06-03 20:42:07 +03:00
|
|
|
}
|
|
|
|
|
2014-12-04 22:43:00 +03:00
|
|
|
nsIntSize ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest,
|
|
|
|
uint32_t aWhichFrame,
|
2016-05-25 19:01:18 +03:00
|
|
|
SamplingFilter aSamplingFilter,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
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
|