CompositorOptions.h (3766B)
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 #ifndef _include_mozilla_gfx_ipc_CompositorOptions_h_ 7 #define _include_mozilla_gfx_ipc_CompositorOptions_h_ 8 9 namespace IPC { 10 template <typename> 11 struct ParamTraits; 12 } // namespace IPC 13 14 namespace mozilla { 15 namespace layers { 16 17 /** 18 * This class holds options that are "per compositor" - that is, these options 19 * affect a particular CompositorBridgeParent and all the content that it 20 * renders. 21 * 22 * This class is intended to be created by a platform widget (but NOT 23 * PuppetWidget) and passed to the graphics code during initialization of the 24 * top level compositor associated with that widget. The options are immutable 25 * after creation. The CompositorBridgeParent holds the canonical version of 26 * the options, but they may be accessed by other parts of the code as needed, 27 * and are accessible to content processes over PCompositorBridge as well. 28 */ 29 class CompositorOptions { 30 public: 31 // This constructor needed for IPDL purposes, don't use it anywhere else. 32 CompositorOptions() = default; 33 34 CompositorOptions(bool aUseAPZ, bool aUseSoftwareWebRender) 35 : mUseAPZ(aUseAPZ), mUseSoftwareWebRender(aUseSoftwareWebRender) {} 36 37 bool UseAPZ() const { return mUseAPZ; } 38 bool UseSoftwareWebRender() const { return mUseSoftwareWebRender; } 39 bool AllowSoftwareWebRenderD3D11() const { 40 return mAllowSoftwareWebRenderD3D11; 41 } 42 bool AllowSoftwareWebRenderOGL() const { return mAllowSoftwareWebRenderOGL; } 43 bool InitiallyPaused() const { return mInitiallyPaused; } 44 bool NeedFastSnaphot() const { return mNeedFastSnaphot; } 45 bool AllowNativeCompositor() const { return mAllowNativeCompositor; } 46 47 void SetUseAPZ(bool aUseAPZ) { mUseAPZ = aUseAPZ; } 48 49 void SetAllowSoftwareWebRenderD3D11(bool aAllowSoftwareWebRenderD3D11) { 50 mAllowSoftwareWebRenderD3D11 = aAllowSoftwareWebRenderD3D11; 51 } 52 53 void SetAllowSoftwareWebRenderOGL(bool aAllowSoftwareWebRenderOGL) { 54 mAllowSoftwareWebRenderOGL = aAllowSoftwareWebRenderOGL; 55 } 56 57 void SetInitiallyPaused(bool aPauseAtStartup) { 58 mInitiallyPaused = aPauseAtStartup; 59 } 60 61 void SetNeedFastSnaphot(bool aNeedFastSnaphot) { 62 mNeedFastSnaphot = aNeedFastSnaphot; 63 } 64 65 void SetAllowNativeCompositor(bool aAllowNativeCompositor) { 66 mAllowNativeCompositor = aAllowNativeCompositor; 67 } 68 69 bool EqualsIgnoringApzEnablement(const CompositorOptions& aOther) const { 70 return mUseSoftwareWebRender == aOther.mUseSoftwareWebRender && 71 mAllowSoftwareWebRenderD3D11 == 72 aOther.mAllowSoftwareWebRenderD3D11 && 73 mAllowSoftwareWebRenderOGL == aOther.mAllowSoftwareWebRenderOGL && 74 mInitiallyPaused == aOther.mInitiallyPaused && 75 mNeedFastSnaphot == aOther.mNeedFastSnaphot && 76 mAllowNativeCompositor == aOther.mAllowNativeCompositor; 77 } 78 79 bool operator==(const CompositorOptions& aOther) const { 80 return mUseAPZ == aOther.mUseAPZ && EqualsIgnoringApzEnablement(aOther); 81 } 82 83 friend struct IPC::ParamTraits<CompositorOptions>; 84 85 private: 86 bool mUseAPZ = false; 87 bool mUseSoftwareWebRender = false; 88 bool mAllowSoftwareWebRenderD3D11 = false; 89 bool mAllowSoftwareWebRenderOGL = false; 90 bool mInitiallyPaused = false; 91 bool mNeedFastSnaphot = false; 92 bool mAllowNativeCompositor = true; 93 94 // Make sure to add new fields to the ParamTraits implementation 95 // in LayersMessageUtils.h 96 }; 97 98 } // namespace layers 99 } // namespace mozilla 100 101 #endif // _include_mozilla_gfx_ipc_CompositorOptions_h_