2010-08-26 13:44:53 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-26 13:44:53 -07:00
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2010-08-26 13:44:53 -07:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include <initguid.h>
|
|
|
|
#include "Nv3DVUtils.h"
|
|
|
|
|
|
|
|
DEFINE_GUID(CLSID_NV3DVStreaming,
|
|
|
|
0xf7747266, 0x777d, 0x4f61, 0xa1, 0x75, 0xdd, 0x5a, 0xdf, 0x1e, 0x37, 0xdf);
|
|
|
|
|
|
|
|
DEFINE_GUID(IID_INV3DVStreaming,
|
|
|
|
0xf98f9bb2, 0xb914, 0x4d44, 0x98, 0xfa, 0x6e, 0x37, 0x85, 0x16, 0x98, 0x55);
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor and Destructor
|
|
|
|
*/
|
|
|
|
Nv3DVUtils::Nv3DVUtils()
|
2013-07-20 01:48:55 -07:00
|
|
|
: m3DVStreaming (nullptr)
|
2010-08-26 13:44:53 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Nv3DVUtils::~Nv3DVUtils()
|
|
|
|
{
|
|
|
|
UnInitialize();
|
|
|
|
}
|
|
|
|
|
2012-11-22 18:21:20 -08:00
|
|
|
|
|
|
|
// Silence spurious warnings!
|
|
|
|
#if defined(WARNING) || defined WARN_IF_FALSE
|
|
|
|
#error We shouldn't be redefining these!
|
|
|
|
#endif
|
|
|
|
// Uncomment these to enable spurious warnings.
|
|
|
|
//#define WARNING(str) NS_WARNING(str)
|
|
|
|
//#define WARN_IF_FALSE(b, str) NS_WARN_IF_FALSE(b, str)
|
|
|
|
#define WARNING(str)
|
|
|
|
#define WARN_IF_FALSE(b, str)
|
|
|
|
|
2010-08-26 13:44:53 -07:00
|
|
|
/**
|
|
|
|
* Initializes the Nv3DVUtils object.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Nv3DVUtils::Initialize()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Detect if 3D Streaming object is already loaded. Do nothing in that case.
|
|
|
|
*/
|
|
|
|
if (m3DVStreaming) {
|
2012-11-22 18:21:20 -08:00
|
|
|
WARNING("Nv3DVStreaming COM object already instantiated.\n");
|
2010-08-26 13:44:53 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the COM object. If we fail at any stage, just return
|
|
|
|
*/
|
2013-07-20 01:48:55 -07:00
|
|
|
HRESULT hr = CoCreateInstance(CLSID_NV3DVStreaming, nullptr, CLSCTX_INPROC_SERVER, IID_INV3DVStreaming, (void**)(getter_AddRefs(m3DVStreaming)));
|
2010-08-26 13:44:53 -07:00
|
|
|
if (FAILED(hr) || !m3DVStreaming) {
|
2012-11-22 18:21:20 -08:00
|
|
|
WARNING("Nv3DVStreaming CoCreateInstance failed (disabled).");
|
2010-08-26 13:44:53 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-07-20 01:48:55 -07:00
|
|
|
* Initialize the object. Note that m3DVStreaming cannot be nullptr at this point.
|
2010-08-26 13:44:53 -07:00
|
|
|
*/
|
|
|
|
bool bRetVal = m3DVStreaming->Nv3DVInitialize();
|
|
|
|
|
|
|
|
if (!bRetVal) {
|
2012-11-22 18:21:20 -08:00
|
|
|
WARNING("Nv3DVStreaming Nv3DVInitialize failed!");
|
2010-08-26 13:44:53 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release resources used by the COM Object, and then release
|
2013-07-20 01:48:55 -07:00
|
|
|
* the COM Object (nsRefPtr gets released by setting to nullptr)
|
2010-08-26 13:44:53 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Nv3DVUtils::UnInitialize()
|
|
|
|
{
|
|
|
|
if (m3DVStreaming) {
|
|
|
|
m3DVStreaming->Nv3DVRelease();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the device info, along with any other initialization that is needed after device creation
|
|
|
|
* Pass the D3D9 device pointer is an IUnknown input argument.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Nv3DVUtils::SetDeviceInfo(IUnknown *devUnknown)
|
|
|
|
{
|
|
|
|
if (!devUnknown) {
|
2013-07-20 01:48:55 -07:00
|
|
|
WARNING("D3D Device Pointer (IUnknown) is nullptr.\n");
|
2010-08-26 13:44:53 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-16 20:33:04 -08:00
|
|
|
if (!m3DVStreaming) {
|
2010-08-26 13:44:53 -07:00
|
|
|
return;
|
2010-11-16 20:33:04 -08:00
|
|
|
}
|
2010-08-26 13:44:53 -07:00
|
|
|
|
2012-05-23 16:00:26 -07:00
|
|
|
bool rv = m3DVStreaming->Nv3DVSetDevice(devUnknown);
|
|
|
|
if (!rv) {
|
2012-11-22 18:21:20 -08:00
|
|
|
WARNING("Nv3DVStreaming Nv3DVControl failed!");
|
2010-11-16 20:33:04 -08:00
|
|
|
return;
|
2011-02-28 20:00:35 -08:00
|
|
|
}
|
2010-08-26 13:44:53 -07:00
|
|
|
|
2010-11-02 16:43:29 -07:00
|
|
|
rv = m3DVStreaming->Nv3DVControl(NV_STEREO_MODE_RIGHT_LEFT, true, FIREFOX_3DV_APP_HANDLE);
|
2012-11-22 18:21:20 -08:00
|
|
|
WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
|
2010-08-26 13:44:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-30 17:42:26 -07:00
|
|
|
* Send Stereo Control Information. Used mainly to re-route
|
2010-08-26 13:44:53 -07:00
|
|
|
* calls from ImageLayerD3D9 to the 3DV COM object
|
|
|
|
*/
|
|
|
|
void
|
2010-11-02 16:43:29 -07:00
|
|
|
Nv3DVUtils::SendNv3DVControl(Nv_Stereo_Mode eStereoMode, bool bEnableStereo, DWORD dw3DVAppHandle)
|
2010-08-26 13:44:53 -07:00
|
|
|
{
|
2010-11-16 20:33:04 -08:00
|
|
|
if (!m3DVStreaming)
|
|
|
|
return;
|
2010-08-26 13:44:53 -07:00
|
|
|
|
2011-11-23 15:01:39 -08:00
|
|
|
DebugOnly<bool> rv = m3DVStreaming->Nv3DVControl(eStereoMode, bEnableStereo, dw3DVAppHandle);
|
2012-11-22 18:21:20 -08:00
|
|
|
WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
|
2010-08-26 13:44:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-30 17:42:26 -07:00
|
|
|
* Send Stereo Metadata. Used mainly to re-route calls
|
2010-08-26 13:44:53 -07:00
|
|
|
* from ImageLayerD3D9 to the 3DV COM object
|
|
|
|
*/
|
2012-07-30 17:42:26 -07:00
|
|
|
void
|
2010-08-26 13:44:53 -07:00
|
|
|
Nv3DVUtils::SendNv3DVMetaData(unsigned int dwWidth, unsigned int dwHeight, HANDLE hSrcLuma, HANDLE hDst)
|
|
|
|
{
|
2010-11-16 20:33:04 -08:00
|
|
|
if (!m3DVStreaming)
|
|
|
|
return;
|
2010-08-26 13:44:53 -07:00
|
|
|
|
2011-11-23 15:01:39 -08:00
|
|
|
DebugOnly<bool> rv = m3DVStreaming->Nv3DVMetaData((DWORD)dwWidth, (DWORD)dwHeight, hSrcLuma, hDst);
|
2012-11-22 18:21:20 -08:00
|
|
|
WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVMetaData failed!");
|
2010-08-26 13:44:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace layers */
|
|
|
|
} /* namespace mozilla */
|