gecko/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
2012-07-12 05:51:58 -07:00

115 lines
2.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* 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 <d3d10_1.h>
#include <dxgi.h>
#include "mozilla/layers/PLayers.h"
#include "ShadowLayers.h"
namespace mozilla {
namespace layers {
// Platform-specific shadow-layers interfaces. See ShadowLayers.h.
// D3D10 doesn't need all these yet.
bool
ShadowLayerForwarder::PlatformAllocBuffer(const gfxIntSize&,
gfxASurface::gfxContentType,
uint32_t,
SurfaceDescriptor*)
{
return false;
}
/*static*/ already_AddRefed<gfxASurface>
ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode,
const SurfaceDescriptor&)
{
return nsnull;
}
/*static*/ bool
ShadowLayerForwarder::PlatformCloseDescriptor(const SurfaceDescriptor&)
{
return false;
}
/*static*/ bool
ShadowLayerForwarder::PlatformGetDescriptorSurfaceContentType(
const SurfaceDescriptor&,
OpenMode,
gfxContentType*,
gfxASurface**)
{
return false;
}
/*static*/ bool
ShadowLayerForwarder::PlatformGetDescriptorSurfaceSize(
const SurfaceDescriptor&,
OpenMode,
gfxIntSize*,
gfxASurface**)
{
return false;
}
bool
ShadowLayerForwarder::PlatformDestroySharedSurface(SurfaceDescriptor*)
{
return false;
}
/*static*/ void
ShadowLayerForwarder::PlatformSyncBeforeUpdate()
{
}
bool
ShadowLayerManager::PlatformDestroySharedSurface(SurfaceDescriptor*)
{
return false;
}
/*static*/ void
ShadowLayerManager::PlatformSyncBeforeReplyUpdate()
{
}
bool
GetDescriptor(ID3D10Texture2D* aTexture, SurfaceDescriptorD3D10* aDescr)
{
NS_ABORT_IF_FALSE(aTexture && aDescr, "Params must be nonnull");
HRESULT hr;
IDXGIResource* dr = nsnull;
hr = aTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&dr);
if (!SUCCEEDED(hr) || !dr)
return false;
hr = dr->GetSharedHandle(reinterpret_cast<HANDLE*>(&aDescr->handle()));
return !!SUCCEEDED(hr);
}
already_AddRefed<ID3D10Texture2D>
OpenForeign(ID3D10Device* aDevice, const SurfaceDescriptorD3D10& aDescr)
{
HRESULT hr;
ID3D10Texture2D* tex = nsnull;
hr = aDevice->OpenSharedResource(reinterpret_cast<HANDLE>(aDescr.handle()),
__uuidof(ID3D10Texture2D),
(void**)&tex);
if (!SUCCEEDED(hr) || !tex)
return nsnull;
// XXX FIXME TODO do we need this???
return nsRefPtr<ID3D10Texture2D>(tex).forget();
}
} // namespace layers
} // namespace mozilla