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"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-25 07:19:42 +00:00
|
|
|
#include "Orientation.h"
|
2021-05-05 09:41:23 +00:00
|
|
|
#include "mozilla/image/Resolution.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
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
using dom::Document;
|
2016-06-30 17:24:27 +00:00
|
|
|
using gfx::IntSize;
|
2016-05-25 16:01:18 +00:00
|
|
|
using gfx::SamplingFilter;
|
2014-07-10 15:00:31 +00:00
|
|
|
using gfx::SourceSurface;
|
|
|
|
using layers::ImageContainer;
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
namespace image {
|
|
|
|
|
|
|
|
// Inherited methods from Image.
|
|
|
|
|
2014-11-15 04:10:47 +00:00
|
|
|
already_AddRefed<ProgressTracker> ImageWrapper::GetProgressTracker() {
|
|
|
|
return mInnerImage->GetProgressTracker();
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2017-07-28 10:10:04 +00:00
|
|
|
size_t ImageWrapper::SizeOfSourceWithComputedFallback(
|
|
|
|
SizeOfState& aState) const {
|
|
|
|
return mInnerImage->SizeOfSourceWithComputedFallback(aState);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 18:46:17 +00:00
|
|
|
void ImageWrapper::CollectSizeOfSurfaces(
|
|
|
|
nsTArray<SurfaceMemoryCounter>& aCounters,
|
|
|
|
MallocSizeOf aMallocSizeOf) const {
|
|
|
|
mInnerImage->CollectSizeOfSurfaces(aCounters, aMallocSizeOf);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
|
|
|
uint32_t aCount) {
|
2021-11-24 11:25:41 +00:00
|
|
|
return mInnerImage->OnImageDataAvailable(aRequest, aInStr, aSourceOffset,
|
|
|
|
aCount);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ImageWrapper::OnImageDataComplete(nsIRequest* aRequest,
|
|
|
|
nsresult aStatus, bool aLastPart) {
|
2021-11-24 11:25:41 +00:00
|
|
|
return mInnerImage->OnImageDataComplete(aRequest, aStatus, aLastPart);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2017-03-16 08:06:06 +00:00
|
|
|
void ImageWrapper::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) {
|
|
|
|
return mInnerImage->OnSurfaceDiscarded(aSurfaceKey);
|
2014-11-28 03:55:57 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00: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 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);
|
|
|
|
}
|
|
|
|
|
2022-07-06 14:53:06 +00:00
|
|
|
void ImageWrapper::MediaFeatureValuesChangedAllDocuments(
|
|
|
|
const mozilla::MediaFeatureChange& aChange) {}
|
|
|
|
|
|
|
|
nsresult ImageWrapper::GetNativeSizes(nsTArray<IntSize>& aNativeSizes) {
|
2017-03-22 13:05:36 +00:00
|
|
|
return mInnerImage->GetNativeSizes(aNativeSizes);
|
|
|
|
}
|
|
|
|
|
2022-07-06 14:53:06 +00:00
|
|
|
size_t ImageWrapper::GetNativeSizesLength() {
|
2017-09-05 11:58:44 +00:00
|
|
|
return mInnerImage->GetNativeSizesLength();
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetIntrinsicSize(nsSize* aSize) {
|
|
|
|
return mInnerImage->GetIntrinsicSize(aSize);
|
|
|
|
}
|
|
|
|
|
2024-10-04 07:59:28 +00:00
|
|
|
AspectRatio ImageWrapper::GetIntrinsicRatio() {
|
2019-05-02 23:28:21 +00:00
|
|
|
return mInnerImage->GetIntrinsicRatio();
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 21:16:39 +00:00
|
|
|
nsresult ImageWrapper::GetHotspotX(int32_t* aX) {
|
|
|
|
return Image::GetHotspotX(aX);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ImageWrapper::GetHotspotY(int32_t* aY) {
|
|
|
|
return Image::GetHotspotY(aY);
|
|
|
|
}
|
|
|
|
|
2013-08-25 07:19:42 +00:00
|
|
|
NS_IMETHODIMP_(Orientation)
|
|
|
|
ImageWrapper::GetOrientation() { return mInnerImage->GetOrientation(); }
|
|
|
|
|
2021-05-05 09:41:23 +00:00
|
|
|
NS_IMETHODIMP_(Resolution)
|
|
|
|
ImageWrapper::GetResolution() { return mInnerImage->GetResolution(); }
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetType(uint16_t* aType) { return mInnerImage->GetType(aType); }
|
|
|
|
|
2021-11-27 11:47:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetProviderId(uint32_t* aId) {
|
|
|
|
return mInnerImage->GetProviderId(aId);
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ImageWrapper::GetAnimated(bool* aAnimated) {
|
|
|
|
return mInnerImage->GetAnimated(aAnimated);
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::GetFrame(uint32_t aWhichFrame, uint32_t aFlags) {
|
2013-12-13 08:34:24 +00:00
|
|
|
return mInnerImage->GetFrame(aWhichFrame, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-19 20:34:09 +00: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 01:43:38 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2016-08-23 02:15:38 +00:00
|
|
|
ImageWrapper::WillDrawOpaqueNow() { return mInnerImage->WillDrawOpaqueNow(); }
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2015-05-13 07:23:44 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2021-09-05 22:36:45 +00:00
|
|
|
ImageWrapper::IsImageContainerAvailable(WindowRenderer* aRenderer,
|
2015-05-13 07:23:44 +00:00
|
|
|
uint32_t aFlags) {
|
2021-09-05 22:36:45 +00:00
|
|
|
return mInnerImage->IsImageContainerAvailable(aRenderer, aFlags);
|
2015-05-13 07:23:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-27 11:47:36 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
|
|
|
ImageWrapper::GetImageProvider(WindowRenderer* aRenderer,
|
|
|
|
const gfx::IntSize& aSize,
|
2022-07-14 16:03:25 +00:00
|
|
|
const SVGImageContext& aSVGContext,
|
2021-11-27 11:47:36 +00:00
|
|
|
const Maybe<ImageIntRegion>& aRegion,
|
|
|
|
uint32_t aFlags,
|
|
|
|
WebRenderImageProvider** aProvider) {
|
|
|
|
return mInnerImage->GetImageProvider(aRenderer, aSize, aSVGContext, aRegion,
|
|
|
|
aFlags, aProvider);
|
|
|
|
}
|
|
|
|
|
2017-12-11 15:37:59 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
2013-03-11 01:43:38 +00:00
|
|
|
ImageWrapper::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
2014-08-22 20:12:38 +00:00
|
|
|
const ImageRegion& aRegion, uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter aSamplingFilter,
|
2022-07-14 16:03:25 +00:00
|
|
|
const SVGImageContext& aSVGContext, uint32_t aFlags,
|
2017-01-03 05:53:22 +00:00
|
|
|
float aOpacity) {
|
2014-08-22 20:12:38 +00:00
|
|
|
return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
|
2017-01-03 05:53:22 +00:00
|
|
|
aSamplingFilter, aSVGContext, aFlags, aOpacity);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-21 17:34:14 +00:00
|
|
|
ImageWrapper::StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->StartDecoding(aFlags, aWhichFrame);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 17:34:14 +00:00
|
|
|
bool ImageWrapper::StartDecodingWithResult(uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->StartDecodingWithResult(aFlags, aWhichFrame);
|
2016-12-23 07:07:45 +00:00
|
|
|
}
|
|
|
|
|
2022-05-20 09:02:32 +00:00
|
|
|
bool ImageWrapper::HasDecodedPixels() {
|
|
|
|
return InnerImage()->HasDecodedPixels();
|
|
|
|
}
|
|
|
|
|
2020-04-20 21:04:45 +00:00
|
|
|
imgIContainer::DecodeResult ImageWrapper::RequestDecodeWithResult(
|
|
|
|
uint32_t aFlags, uint32_t aWhichFrame) {
|
2019-05-21 17:34:14 +00:00
|
|
|
return mInnerImage->RequestDecodeWithResult(aFlags, aWhichFrame);
|
2018-11-08 17:45:50 +00:00
|
|
|
}
|
|
|
|
|
2015-01-18 22:02:13 +00:00
|
|
|
NS_IMETHODIMP
|
2019-05-21 17:34:14 +00:00
|
|
|
ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return mInnerImage->RequestDecodeForSize(aSize, aFlags, aWhichFrame);
|
2015-01-18 22:02:13 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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-11 22:03:43 +00:00
|
|
|
void ImageWrapper::PropagateUseCounters(Document* aReferencingDocument) {
|
|
|
|
mInnerImage->PropagateUseCounters(aReferencingDocument);
|
2015-06-03 17:42:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-04 19:43:00 +00:00
|
|
|
nsIntSize ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest,
|
|
|
|
uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter aSamplingFilter,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame,
|
|
|
|
aSamplingFilter, aFlags);
|
2014-07-28 21:27:40 +00:00
|
|
|
}
|
|
|
|
|
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
|