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