tor-browser

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

gfxPlatformMac.h (3271B)


      1 /* -*- Mode: C++; tab-width: 20; 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 GFX_PLATFORM_MAC_H
      7 #define GFX_PLATFORM_MAC_H
      8 
      9 #include "nsTArrayForwardDeclare.h"
     10 #include "gfxPlatform.h"
     11 #include "mozilla/LookAndFeel.h"
     12 
     13 namespace mozilla {
     14 namespace gfx {
     15 class DrawTarget;
     16 class VsyncSource;
     17 }  // namespace gfx
     18 }  // namespace mozilla
     19 
     20 class gfxPlatformMac : public gfxPlatform {
     21 public:
     22  gfxPlatformMac();
     23  virtual ~gfxPlatformMac();
     24 
     25  // Call early in startup to register the macOS supplemental language fonts
     26  // so that they're usable by the browser. This is intended to be called as
     27  // early as possible, before most services etc are initialized; it starts
     28  // a separate thread to register the fonts, because this is quite slow.
     29  static void RegisterSupplementalFonts();
     30 
     31  // Call from the main thread at the point where we need to start using the
     32  // font list; this will wait (if necessary) for the registration thread to
     33  // finish.
     34  static void WaitForFontRegistration();
     35 
     36  static gfxPlatformMac* GetPlatform() {
     37    return (gfxPlatformMac*)gfxPlatform::GetPlatform();
     38  }
     39 
     40  already_AddRefed<gfxASurface> CreateOffscreenSurface(
     41      const IntSize& aSize, gfxImageFormat aFormat) override;
     42 
     43  bool CreatePlatformFontList() override;
     44 
     45  void ReadSystemFontList(mozilla::dom::SystemFontList* aFontList) override;
     46 
     47  void GetCommonFallbackFonts(uint32_t aCh, Script aRunScript,
     48                              FontPresentation aPresentation,
     49                              nsTArray<const char*>& aFontList) override;
     50 
     51  // lookup the system font for a particular system font type and set
     52  // the name and style characteristics
     53  static void LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
     54                               nsACString& aSystemFontName,
     55                               gfxFontStyle& aFontStyle);
     56 
     57  bool SupportsApzWheelInput() const override { return true; }
     58 
     59  bool RespectsFontStyleSmoothing() const override {
     60    // gfxMacFont respects the font smoothing hint.
     61    return true;
     62  }
     63 
     64  bool RequiresAcceleratedGLContextForCompositorOGL() const override {
     65    // On OS X in a VM, unaccelerated CompositorOGL shows black flashes, so we
     66    // require accelerated GL for CompositorOGL but allow unaccelerated GL for
     67    // BasicCompositor.
     68    return true;
     69  }
     70 
     71  already_AddRefed<mozilla::gfx::VsyncSource> CreateGlobalHardwareVsyncSource()
     72      override;
     73 
     74  // lower threshold on font anti-aliasing
     75  uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; }
     76 
     77  static bool CheckVariationFontSupport();
     78 
     79 protected:
     80  bool AccelerateLayersByDefault() override;
     81 
     82  BackendPrefsData GetBackendPrefs() const override;
     83 
     84 private:
     85  nsTArray<uint8_t> GetPlatformCMSOutputProfileData() override;
     86 
     87  // read in the pref value for the lower threshold on font anti-aliasing
     88  static uint32_t ReadAntiAliasingThreshold();
     89 
     90  static void FontRegistrationCallback(void* aUnused);
     91 
     92  uint32_t mFontAntiAliasingThreshold;
     93 
     94  static PRThread* sFontRegistrationThread;
     95 };
     96 
     97 #endif /* GFX_PLATFORM_MAC_H */