FrozenImage.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "FrozenImage.h"
  6. namespace mozilla {
  7. using namespace gfx;
  8. using layers::ImageContainer;
  9. using layers::LayerManager;
  10. namespace image {
  11. NS_IMPL_ISUPPORTS_INHERITED0(FrozenImage, ImageWrapper)
  12. void
  13. FrozenImage::IncrementAnimationConsumers()
  14. {
  15. // Do nothing. This will prevent animation from starting if there are no other
  16. // instances of this image.
  17. }
  18. void
  19. FrozenImage::DecrementAnimationConsumers()
  20. {
  21. // Do nothing.
  22. }
  23. NS_IMETHODIMP
  24. FrozenImage::GetAnimated(bool* aAnimated)
  25. {
  26. bool dummy;
  27. nsresult rv = InnerImage()->GetAnimated(&dummy);
  28. if (NS_SUCCEEDED(rv)) {
  29. *aAnimated = false;
  30. }
  31. return rv;
  32. }
  33. NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
  34. FrozenImage::GetFrame(uint32_t aWhichFrame,
  35. uint32_t aFlags)
  36. {
  37. return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
  38. }
  39. NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
  40. FrozenImage::GetFrameAtSize(const IntSize& aSize,
  41. uint32_t aWhichFrame,
  42. uint32_t aFlags)
  43. {
  44. return InnerImage()->GetFrameAtSize(aSize, FRAME_FIRST, aFlags);
  45. }
  46. NS_IMETHODIMP_(bool)
  47. FrozenImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags)
  48. {
  49. return false;
  50. }
  51. NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
  52. FrozenImage::GetImageContainer(layers::LayerManager* aManager, uint32_t aFlags)
  53. {
  54. // XXX(seth): GetImageContainer does not currently support anything but the
  55. // current frame. We work around this by always returning null, but if it ever
  56. // turns out that FrozenImage is widely used on codepaths that can actually
  57. // benefit from GetImageContainer, it would be a good idea to fix that method
  58. // for performance reasons.
  59. return nullptr;
  60. }
  61. NS_IMETHODIMP_(DrawResult)
  62. FrozenImage::Draw(gfxContext* aContext,
  63. const nsIntSize& aSize,
  64. const ImageRegion& aRegion,
  65. uint32_t /* aWhichFrame - ignored */,
  66. SamplingFilter aSamplingFilter,
  67. const Maybe<SVGImageContext>& aSVGContext,
  68. uint32_t aFlags)
  69. {
  70. return InnerImage()->Draw(aContext, aSize, aRegion, FRAME_FIRST,
  71. aSamplingFilter, aSVGContext, aFlags);
  72. }
  73. NS_IMETHODIMP_(void)
  74. FrozenImage::RequestRefresh(const TimeStamp& aTime)
  75. {
  76. // Do nothing.
  77. }
  78. NS_IMETHODIMP
  79. FrozenImage::GetAnimationMode(uint16_t* aAnimationMode)
  80. {
  81. *aAnimationMode = kNormalAnimMode;
  82. return NS_OK;
  83. }
  84. NS_IMETHODIMP
  85. FrozenImage::SetAnimationMode(uint16_t aAnimationMode)
  86. {
  87. // Do nothing.
  88. return NS_OK;
  89. }
  90. NS_IMETHODIMP
  91. FrozenImage::ResetAnimation()
  92. {
  93. // Do nothing.
  94. return NS_OK;
  95. }
  96. NS_IMETHODIMP_(float)
  97. FrozenImage::GetFrameIndex(uint32_t aWhichFrame)
  98. {
  99. MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
  100. return 0;
  101. }
  102. } // namespace image
  103. } // namespace mozilla