PlaybackType.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef mozilla_image_PlaybackType_h
  6. #define mozilla_image_PlaybackType_h
  7. #include "imgIContainer.h"
  8. namespace mozilla {
  9. namespace image {
  10. /**
  11. * PlaybackType identifies a surface cache entry as either a static surface or
  12. * an animation. Note that a specific cache entry is one or the other, but
  13. * images may be associated with both types of cache entries, since in some
  14. * circumstances we may want to treat an animated image as if it were static.
  15. */
  16. enum class PlaybackType : uint8_t
  17. {
  18. eStatic, // Calls to DrawableRef() will always return the same surface.
  19. eAnimated // An animation; calls to DrawableRef() may return different
  20. // surfaces at different times.
  21. };
  22. /**
  23. * Given an imgIContainer FRAME_* value, returns the corresponding PlaybackType
  24. * for use in surface cache lookups.
  25. */
  26. inline PlaybackType
  27. ToPlaybackType(uint32_t aWhichFrame)
  28. {
  29. MOZ_ASSERT(aWhichFrame == imgIContainer::FRAME_FIRST ||
  30. aWhichFrame == imgIContainer::FRAME_CURRENT);
  31. return aWhichFrame == imgIContainer::FRAME_CURRENT
  32. ? PlaybackType::eAnimated
  33. : PlaybackType::eStatic;
  34. }
  35. } // namespace image
  36. } // namespace mozilla
  37. #endif // mozilla_image_PlaybackType_h