gfx/layers/d3d9/Nv3DVUtils.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     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 #include "mozilla/DebugOnly.h"
     8 #include "nsIServiceManager.h"
     9 #include "nsIConsoleService.h"
    10 #include <initguid.h>
    11 #include "Nv3DVUtils.h"
    13 DEFINE_GUID(CLSID_NV3DVStreaming, 
    14 0xf7747266, 0x777d, 0x4f61, 0xa1, 0x75, 0xdd, 0x5a, 0xdf, 0x1e, 0x37, 0xdf);
    16 DEFINE_GUID(IID_INV3DVStreaming, 
    17 0xf98f9bb2, 0xb914, 0x4d44, 0x98, 0xfa, 0x6e, 0x37, 0x85, 0x16, 0x98, 0x55);
    19 namespace mozilla {
    20 namespace layers {
    22 /**
    23  * Constructor and Destructor
    24  */
    25 Nv3DVUtils::Nv3DVUtils()
    26   : m3DVStreaming (nullptr)
    27 {
    28 }
    30 Nv3DVUtils::~Nv3DVUtils()
    31 {
    32   UnInitialize();
    33 }
    36 // Silence spurious warnings!
    37 #if defined(WARNING) || defined WARN_IF_FALSE
    38 #error We shouldn't be redefining these!
    39 #endif
    40 // Uncomment these to enable spurious warnings.
    41 //#define WARNING(str) NS_WARNING(str)
    42 //#define WARN_IF_FALSE(b, str) NS_WARN_IF_FALSE(b, str)
    43 #define WARNING(str)
    44 #define WARN_IF_FALSE(b, str)
    46 /**
    47  * Initializes the Nv3DVUtils object.
    48  */
    49 void
    50 Nv3DVUtils::Initialize()
    51 {
    52   /*
    53    * Detect if 3D Streaming object is already loaded. Do nothing in that case.
    54    */
    55   if (m3DVStreaming) {
    56     WARNING("Nv3DVStreaming COM object already instantiated.\n");
    57     return;
    58   }
    60   /*
    61    * Create the COM object. If we fail at any stage, just return
    62    */
    63   HRESULT hr = CoCreateInstance(CLSID_NV3DVStreaming, nullptr, CLSCTX_INPROC_SERVER, IID_INV3DVStreaming, (void**)(getter_AddRefs(m3DVStreaming)));
    64   if (FAILED(hr) || !m3DVStreaming) {
    65     WARNING("Nv3DVStreaming CoCreateInstance failed (disabled).");
    66     return;
    67   }
    69   /*
    70    * Initialize the object. Note that m3DVStreaming cannot be nullptr at this point.
    71    */
    72   bool bRetVal = m3DVStreaming->Nv3DVInitialize();
    74   if (!bRetVal) {
    75     WARNING("Nv3DVStreaming Nv3DVInitialize failed!");
    76     return;
    77   }
    78 }
    80 /**
    81  * Release resources used by the COM Object, and then release 
    82  * the COM Object (nsRefPtr gets released by setting to nullptr) 
    83  *
    84  */
    85 void
    86 Nv3DVUtils::UnInitialize()
    87 {
    88   if (m3DVStreaming) {
    89     m3DVStreaming->Nv3DVRelease();
    90   }
    91 }
    93 /**
    94  * Sets the device info, along with any other initialization that is needed after device creation
    95  * Pass the D3D9 device pointer is an IUnknown input argument.
    96  */
    97 void 
    98 Nv3DVUtils::SetDeviceInfo(IUnknown *devUnknown)
    99 {
   100   if (!devUnknown) {
   101     WARNING("D3D Device Pointer (IUnknown) is nullptr.\n");
   102     return;
   103   }
   105   if (!m3DVStreaming) {
   106       return;
   107   }
   109   bool rv = m3DVStreaming->Nv3DVSetDevice(devUnknown);
   110   if (!rv) {
   111       WARNING("Nv3DVStreaming Nv3DVControl failed!");
   112       return;
   113   }
   115   rv = m3DVStreaming->Nv3DVControl(NV_STEREO_MODE_RIGHT_LEFT, true, FIREFOX_3DV_APP_HANDLE);
   116   WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
   117 }
   119 /*
   120  * Send Stereo Control Information. Used mainly to re-route
   121  * calls from ImageLayerD3D9 to the 3DV COM object
   122  */
   123 void 
   124 Nv3DVUtils::SendNv3DVControl(Nv_Stereo_Mode eStereoMode, bool bEnableStereo, DWORD dw3DVAppHandle)
   125 {
   126   if (!m3DVStreaming)
   127       return;
   129   DebugOnly<bool> rv = m3DVStreaming->Nv3DVControl(eStereoMode, bEnableStereo, dw3DVAppHandle);
   130   WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
   131 }
   133 /*
   134  * Send Stereo Metadata. Used mainly to re-route calls
   135  * from ImageLayerD3D9 to the 3DV COM object
   136  */
   137 void
   138 Nv3DVUtils::SendNv3DVMetaData(unsigned int dwWidth, unsigned int dwHeight, HANDLE hSrcLuma, HANDLE hDst)
   139 {
   140   if (!m3DVStreaming)
   141       return;
   143   DebugOnly<bool> rv = m3DVStreaming->Nv3DVMetaData((DWORD)dwWidth, (DWORD)dwHeight, hSrcLuma, hDst);
   144   WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVMetaData failed!");
   145 }
   147 } /* namespace layers */
   148 } /* namespace mozilla */

mercurial