tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PlaybackType.h (1527B)


      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 
      6 #ifndef mozilla_image_PlaybackType_h
      7 #define mozilla_image_PlaybackType_h
      8 
      9 #include "imgIContainer.h"
     10 
     11 namespace mozilla {
     12 namespace image {
     13 
     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.
     19 */
     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.
     24 };
     25 
     26 /**
     27 * Given an imgIContainer FRAME_* value, returns the corresponding PlaybackType
     28 * for use in surface cache lookups.
     29 */
     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;
     35 }
     36 
     37 }  // namespace image
     38 }  // namespace mozilla
     39 
     40 #endif  // mozilla_image_PlaybackType_h