1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/src/FrozenImage.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "FrozenImage.h" 1.10 + 1.11 +using namespace mozilla::gfx; 1.12 + 1.13 +namespace mozilla { 1.14 +namespace image { 1.15 + 1.16 +NS_IMPL_ISUPPORTS(FrozenImage, imgIContainer) 1.17 + 1.18 +nsIntRect 1.19 +FrozenImage::FrameRect(uint32_t /* aWhichFrame - ignored */) 1.20 +{ 1.21 + return InnerImage()->FrameRect(FRAME_FIRST); 1.22 +} 1.23 + 1.24 +void 1.25 +FrozenImage::IncrementAnimationConsumers() 1.26 +{ 1.27 + // Do nothing. This will prevent animation from starting if there are no other 1.28 + // instances of this image. 1.29 +} 1.30 + 1.31 +void 1.32 +FrozenImage::DecrementAnimationConsumers() 1.33 +{ 1.34 + // Do nothing. 1.35 +} 1.36 + 1.37 +NS_IMETHODIMP 1.38 +FrozenImage::GetAnimated(bool* aAnimated) 1.39 +{ 1.40 + bool dummy; 1.41 + nsresult rv = InnerImage()->GetAnimated(&dummy); 1.42 + if (NS_SUCCEEDED(rv)) { 1.43 + *aAnimated = false; 1.44 + } 1.45 + return rv; 1.46 +} 1.47 + 1.48 +NS_IMETHODIMP_(TemporaryRef<SourceSurface>) 1.49 +FrozenImage::GetFrame(uint32_t aWhichFrame, 1.50 + uint32_t aFlags) 1.51 +{ 1.52 + return InnerImage()->GetFrame(FRAME_FIRST, aFlags); 1.53 +} 1.54 + 1.55 +NS_IMETHODIMP_(bool) 1.56 +FrozenImage::FrameIsOpaque(uint32_t aWhichFrame) 1.57 +{ 1.58 + return InnerImage()->FrameIsOpaque(FRAME_FIRST); 1.59 +} 1.60 + 1.61 +NS_IMETHODIMP 1.62 +FrozenImage::GetImageContainer(layers::LayerManager* aManager, 1.63 + layers::ImageContainer** _retval) 1.64 +{ 1.65 + // XXX(seth): GetImageContainer does not currently support anything but the 1.66 + // current frame. We work around this by always returning null, but if it ever 1.67 + // turns out that FrozenImage is widely used on codepaths that can actually 1.68 + // benefit from GetImageContainer, it would be a good idea to fix that method 1.69 + // for performance reasons. 1.70 + 1.71 + *_retval = nullptr; 1.72 + return NS_OK; 1.73 +} 1.74 + 1.75 +NS_IMETHODIMP 1.76 +FrozenImage::Draw(gfxContext* aContext, 1.77 + GraphicsFilter aFilter, 1.78 + const gfxMatrix& aUserSpaceToImageSpace, 1.79 + const gfxRect& aFill, 1.80 + const nsIntRect& aSubimage, 1.81 + const nsIntSize& aViewportSize, 1.82 + const SVGImageContext* aSVGContext, 1.83 + uint32_t /* aWhichFrame - ignored */, 1.84 + uint32_t aFlags) 1.85 +{ 1.86 + return InnerImage()->Draw(aContext, aFilter, aUserSpaceToImageSpace, 1.87 + aFill, aSubimage, aViewportSize, aSVGContext, 1.88 + FRAME_FIRST, aFlags); 1.89 +} 1.90 + 1.91 +NS_IMETHODIMP_(void) 1.92 +FrozenImage::RequestRefresh(const mozilla::TimeStamp& aTime) 1.93 +{ 1.94 + // Do nothing. 1.95 +} 1.96 + 1.97 +NS_IMETHODIMP 1.98 +FrozenImage::GetAnimationMode(uint16_t* aAnimationMode) 1.99 +{ 1.100 + *aAnimationMode = kNormalAnimMode; 1.101 + return NS_OK; 1.102 +} 1.103 + 1.104 +NS_IMETHODIMP 1.105 +FrozenImage::SetAnimationMode(uint16_t aAnimationMode) 1.106 +{ 1.107 + // Do nothing. 1.108 + return NS_OK; 1.109 +} 1.110 + 1.111 +NS_IMETHODIMP 1.112 +FrozenImage::ResetAnimation() 1.113 +{ 1.114 + // Do nothing. 1.115 + return NS_OK; 1.116 +} 1.117 + 1.118 +NS_IMETHODIMP_(float) 1.119 +FrozenImage::GetFrameIndex(uint32_t aWhichFrame) 1.120 +{ 1.121 + MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument"); 1.122 + return 0; 1.123 +} 1.124 + 1.125 +} // namespace image 1.126 +} // namespace mozilla