forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IPC helpers to marshal DXGI_ADAPTER_DESC. (bug 1225283 part 1, r=…
…mattwoodrow)
- Loading branch information
David Anderson
committed
Nov 18, 2015
1 parent
e6134f4
commit 0634af5
Showing
6 changed files
with
138 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
/* vim: set ts=8 sts=4 et sw=4 tw=80: */ | ||
/* 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/. */ | ||
#include "D3DMessageUtils.h" | ||
#if defined(XP_WIN) | ||
# include "gfxWindowsPlatform.h" | ||
#endif | ||
|
||
bool | ||
DxgiAdapterDesc::operator ==(const DxgiAdapterDesc& aOther) const | ||
{ | ||
return memcmp(&aOther, this, sizeof(*this)) == 0; | ||
} | ||
|
||
#if defined(XP_WIN) | ||
static_assert(sizeof(DxgiAdapterDesc) == sizeof(DXGI_ADAPTER_DESC), | ||
"DXGI_ADAPTER_DESC doe snot match DxgiAdapterDesc"); | ||
|
||
const DxgiAdapterDesc& | ||
DxgiAdapterDesc::From(const DXGI_ADAPTER_DESC& aDesc) | ||
{ | ||
return reinterpret_cast<const DxgiAdapterDesc&>(aDesc); | ||
} | ||
#endif | ||
|
||
namespace IPC { | ||
|
||
void | ||
ParamTraits<DxgiAdapterDesc>::Write(Message* aMsg, const paramType& aParam) | ||
{ | ||
#if defined(XP_WIN) | ||
aMsg->WriteBytes(aParam.Description, sizeof(aParam.Description)); | ||
WriteParam(aMsg, aParam.VendorId); | ||
WriteParam(aMsg, aParam.DeviceId); | ||
WriteParam(aMsg, aParam.SubSysId); | ||
WriteParam(aMsg, aParam.Revision); | ||
WriteParam(aMsg, aParam.DedicatedVideoMemory); | ||
WriteParam(aMsg, aParam.DedicatedSystemMemory); | ||
WriteParam(aMsg, aParam.SharedSystemMemory); | ||
WriteParam(aMsg, aParam.AdapterLuid.LowPart); | ||
WriteParam(aMsg, aParam.AdapterLuid.HighPart); | ||
#else | ||
MOZ_ASSERT_UNREACHABLE("DxgiAdapterDesc is Windows-only"); | ||
#endif | ||
} | ||
|
||
bool | ||
ParamTraits<DxgiAdapterDesc>::Read(const Message* aMsg, void** aIter, paramType* aResult) | ||
{ | ||
#if defined(XP_WIN) | ||
const char* description = nullptr; | ||
if (!aMsg->ReadBytes(aIter, &description, sizeof(aResult->Description))) { | ||
return false; | ||
} | ||
memcpy(aResult->Description, description, sizeof(aResult->Description)); | ||
|
||
if (ReadParam(aMsg, aIter, &aResult->VendorId) && | ||
ReadParam(aMsg, aIter, &aResult->DeviceId) && | ||
ReadParam(aMsg, aIter, &aResult->SubSysId) && | ||
ReadParam(aMsg, aIter, &aResult->Revision) && | ||
ReadParam(aMsg, aIter, &aResult->DedicatedVideoMemory) && | ||
ReadParam(aMsg, aIter, &aResult->DedicatedSystemMemory) && | ||
ReadParam(aMsg, aIter, &aResult->SharedSystemMemory) && | ||
ReadParam(aMsg, aIter, &aResult->AdapterLuid.LowPart) && | ||
ReadParam(aMsg, aIter, &aResult->AdapterLuid.HighPart)) | ||
{ | ||
return true; | ||
} | ||
#else | ||
MOZ_ASSERT_UNREACHABLE("DxgiAdapterDesc is Windows-only"); | ||
#endif | ||
return false; | ||
} | ||
|
||
} // namespace IPC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
/* vim: set ts=8 sts=4 et sw=4 tw=80: */ | ||
/* 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/. */ | ||
#ifndef _include_gfx_ipc_D3DMessageUtils_h__ | ||
#define _include_gfx_ipc_D3DMessageUtils_h__ | ||
|
||
#include "chrome/common/ipc_message_utils.h" | ||
#include "ipc/IPCMessageUtils.h" | ||
|
||
// Can't include dxgi.h, since it leaks random identifiers and #defines, and | ||
// IPDL causes this file to be #included all over. | ||
typedef struct DXGI_ADAPTER_DESC DXGI_ADAPTER_DESC; | ||
|
||
struct DxgiAdapterDesc | ||
{ | ||
#if defined(XP_WIN) | ||
WCHAR Description[128]; | ||
UINT VendorId; | ||
UINT DeviceId; | ||
UINT SubSysId; | ||
UINT Revision; | ||
SIZE_T DedicatedVideoMemory; | ||
SIZE_T DedicatedSystemMemory; | ||
SIZE_T SharedSystemMemory; | ||
LUID AdapterLuid; | ||
|
||
static const DxgiAdapterDesc& From(const DXGI_ADAPTER_DESC& aDesc); | ||
#endif | ||
|
||
bool operator ==(const DxgiAdapterDesc& aOther) const; | ||
}; | ||
|
||
namespace IPC { | ||
|
||
template <> | ||
struct ParamTraits<DxgiAdapterDesc> | ||
{ | ||
typedef DxgiAdapterDesc paramType; | ||
static void Write(Message* aMsg, const paramType& aParam); | ||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult); | ||
}; | ||
|
||
} // namespace IPC | ||
|
||
#endif // _include_gfx_ipc_D3DMessageUtils_h__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters