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 "FrozenImage.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-07-10 15:00:31 +00:00
|
|
|
|
|
|
|
using namespace gfx;
|
2016-06-30 17:24:27 +00:00
|
|
|
using layers::ImageContainer;
|
2014-07-10 15:00:31 +00:00
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
namespace image {
|
|
|
|
|
|
|
|
void FrozenImage::IncrementAnimationConsumers() {
|
|
|
|
// Do nothing. This will prevent animation from starting if there are no other
|
|
|
|
// instances of this image.
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrozenImage::DecrementAnimationConsumers() {
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::GetAnimated(bool* aAnimated) {
|
2013-03-12 20:42:09 +00:00
|
|
|
bool dummy;
|
|
|
|
nsresult rv = InnerImage()->GetAnimated(&dummy);
|
2013-03-11 01:43:38 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
*aAnimated = false;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
2013-03-11 01:43:38 +00:00
|
|
|
FrozenImage::GetFrame(uint32_t aWhichFrame, uint32_t aFlags) {
|
2013-12-13 08:34:24 +00:00
|
|
|
return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-19 20:34:09 +00:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
|
|
|
FrozenImage::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
|
|
|
|
uint32_t aFlags) {
|
|
|
|
return InnerImage()->GetFrameAtSize(aSize, FRAME_FIRST, aFlags);
|
|
|
|
}
|
|
|
|
|
2021-03-12 18:39:05 +00:00
|
|
|
bool FrozenImage::IsNonAnimated() const {
|
|
|
|
// We usually don't create frozen images for non-animated images, but it might
|
|
|
|
// happen if we don't have enough data at the time of the creation to
|
|
|
|
// determine whether the image is actually animated.
|
|
|
|
bool animated = false;
|
|
|
|
return NS_SUCCEEDED(InnerImage()->GetAnimated(&animated)) && !animated;
|
|
|
|
}
|
|
|
|
|
2015-05-13 07:23:44 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2021-09-05 22:36:45 +00:00
|
|
|
FrozenImage::IsImageContainerAvailable(WindowRenderer* aRenderer,
|
2015-05-13 07:23:44 +00:00
|
|
|
uint32_t aFlags) {
|
2021-03-12 18:39:05 +00:00
|
|
|
if (IsNonAnimated()) {
|
2021-09-05 22:36:45 +00:00
|
|
|
return InnerImage()->IsImageContainerAvailable(aRenderer, aFlags);
|
2021-03-12 18:39:05 +00:00
|
|
|
}
|
2015-05-13 07:23:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-27 11:47:36 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
|
|
|
FrozenImage::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) {
|
|
|
|
if (IsNonAnimated()) {
|
|
|
|
return InnerImage()->GetImageProvider(aRenderer, aSize, aSVGContext,
|
|
|
|
aRegion, aFlags, aProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX(seth): GetImageContainer does not currently support anything but the
|
|
|
|
// current frame. We work around this by always returning null, but if it ever
|
|
|
|
// turns out that FrozenImage is widely used on codepaths that can actually
|
2017-11-17 11:45:26 +00:00
|
|
|
// benefit from GetImageContainer, it would be a good idea to fix that method
|
|
|
|
// for performance reasons.
|
2018-09-13 23:48:21 +00:00
|
|
|
return ImgDrawResult::NOT_SUPPORTED;
|
2017-11-17 11:45:26 +00:00
|
|
|
}
|
|
|
|
|
2017-12-11 15:37:59 +00:00
|
|
|
NS_IMETHODIMP_(ImgDrawResult)
|
2013-03-11 01:43:38 +00:00
|
|
|
FrozenImage::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
2014-08-22 20:12:38 +00:00
|
|
|
const ImageRegion& aRegion,
|
2013-03-11 01:43:38 +00:00
|
|
|
uint32_t /* aWhichFrame - ignored */,
|
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 InnerImage()->Draw(aContext, aSize, aRegion, FRAME_FIRST,
|
2017-01-03 05:53:22 +00:00
|
|
|
aSamplingFilter, aSVGContext, aFlags, aOpacity);
|
2013-03-11 01:43:38 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 17:34:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) {
|
|
|
|
return InnerImage()->StartDecoding(aFlags, FRAME_FIRST);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FrozenImage::StartDecodingWithResult(uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return InnerImage()->StartDecodingWithResult(aFlags, FRAME_FIRST);
|
2022-05-20 09:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FrozenImage::HasDecodedPixels() {
|
|
|
|
return InnerImage()->HasDecodedPixels();
|
2019-05-21 17:34:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-20 21:04:45 +00:00
|
|
|
imgIContainer::DecodeResult FrozenImage::RequestDecodeWithResult(
|
|
|
|
uint32_t aFlags, uint32_t aWhichFrame) {
|
2019-05-21 17:34:14 +00:00
|
|
|
return InnerImage()->RequestDecodeWithResult(aFlags, FRAME_FIRST);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) {
|
|
|
|
return InnerImage()->RequestDecodeForSize(aSize, aFlags, FRAME_FIRST);
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
NS_IMETHODIMP_(void)
|
2014-07-10 15:00:31 +00:00
|
|
|
FrozenImage::RequestRefresh(const TimeStamp& aTime) {
|
2013-03-11 01:43:38 +00:00
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::GetAnimationMode(uint16_t* aAnimationMode) {
|
|
|
|
*aAnimationMode = kNormalAnimMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::SetAnimationMode(uint16_t aAnimationMode) {
|
|
|
|
// Do nothing.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FrozenImage::ResetAnimation() {
|
|
|
|
// Do nothing.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-25 22:58:20 +00:00
|
|
|
NS_IMETHODIMP_(float)
|
|
|
|
FrozenImage::GetFrameIndex(uint32_t aWhichFrame) {
|
|
|
|
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|