|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=8 et : |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #include <d3d10_1.h> |
|
9 #include <dxgi.h> |
|
10 |
|
11 #include "mozilla/gfx/Point.h" |
|
12 #include "mozilla/layers/LayerManagerComposite.h" |
|
13 #include "mozilla/layers/PLayerTransaction.h" |
|
14 #include "ShadowLayers.h" |
|
15 |
|
16 using namespace mozilla::gl; |
|
17 |
|
18 namespace mozilla { |
|
19 namespace layers { |
|
20 |
|
21 |
|
22 /*static*/ void |
|
23 ShadowLayerForwarder::PlatformSyncBeforeUpdate() |
|
24 { |
|
25 } |
|
26 |
|
27 /*static*/ bool |
|
28 LayerManagerComposite::SupportsDirectTexturing() |
|
29 { |
|
30 return true; |
|
31 } |
|
32 |
|
33 /*static*/ void |
|
34 LayerManagerComposite::PlatformSyncBeforeReplyUpdate() |
|
35 { |
|
36 } |
|
37 |
|
38 bool |
|
39 GetDescriptor(ID3D10Texture2D* aTexture, SurfaceDescriptorD3D10* aDescr) |
|
40 { |
|
41 NS_ABORT_IF_FALSE(aTexture && aDescr, "Params must be nonnull"); |
|
42 |
|
43 HRESULT hr; |
|
44 IDXGIResource* dr = nullptr; |
|
45 hr = aTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&dr); |
|
46 if (!SUCCEEDED(hr) || !dr) |
|
47 return false; |
|
48 |
|
49 hr = dr->GetSharedHandle(reinterpret_cast<HANDLE*>(&aDescr->handle())); |
|
50 return !!SUCCEEDED(hr); |
|
51 } |
|
52 |
|
53 already_AddRefed<ID3D10Texture2D> |
|
54 OpenForeign(ID3D10Device* aDevice, const SurfaceDescriptorD3D10& aDescr) |
|
55 { |
|
56 HRESULT hr; |
|
57 ID3D10Texture2D* tex = nullptr; |
|
58 hr = aDevice->OpenSharedResource(reinterpret_cast<HANDLE>(aDescr.handle()), |
|
59 __uuidof(ID3D10Texture2D), |
|
60 (void**)&tex); |
|
61 if (!SUCCEEDED(hr) || !tex) |
|
62 return nullptr; |
|
63 |
|
64 return nsRefPtr<ID3D10Texture2D>(tex).forget(); |
|
65 } |
|
66 |
|
67 } // namespace layers |
|
68 } // namespace mozilla |