tor-browser

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

HelpersWin.h (1153B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef MOZILLA_GFX_HELPERSWIN_H_
      8 #define MOZILLA_GFX_HELPERSWIN_H_
      9 
     10 #include <dxgiformat.h>
     11 #include "2D.h"
     12 
     13 namespace mozilla {
     14 namespace gfx {
     15 
     16 static inline DXGI_FORMAT DXGIFormat(SurfaceFormat aFormat) {
     17  switch (aFormat) {
     18    case SurfaceFormat::B8G8R8A8:
     19      return DXGI_FORMAT_B8G8R8A8_UNORM;
     20    case SurfaceFormat::B8G8R8X8:
     21      return DXGI_FORMAT_B8G8R8A8_UNORM;
     22    case SurfaceFormat::A8:
     23      return DXGI_FORMAT_A8_UNORM;
     24    default:
     25      return DXGI_FORMAT_UNKNOWN;
     26  }
     27 }
     28 
     29 static inline SurfaceFormat ToPixelFormat(const DXGI_FORMAT& aFormat) {
     30  switch (aFormat) {
     31    case DXGI_FORMAT_A8_UNORM:
     32    case DXGI_FORMAT_R8_UNORM:
     33      return SurfaceFormat::A8;
     34    default:
     35      return SurfaceFormat::B8G8R8A8;
     36  }
     37 }
     38 
     39 }  // namespace gfx
     40 }  // namespace mozilla
     41 
     42 #endif /* MOZILLA_GFX_HELPERSWIN_H_ */