1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Helper functions that Direct3D 9Ex code a little easier to work with for
6 // the ui/surface code.
8 #ifndef UI_SURFACE_D3D9_UTILS_WIN_H_
9 #define UI_SURFACE_D3D9_UTILS_WIN_H_
13 #include "base/basictypes.h"
14 #include "ui/surface/surface_export.h"
17 class ScopedNativeLibrary
;
24 namespace ui_surface_d3d9_utils
{
26 // Visible for testing. Loads the Direct3D9 library. Returns true on success.
28 bool LoadD3D9(base::ScopedNativeLibrary
* storage
);
30 // Visible for testing. Creates a Direct3D9 device suitable for use with the
31 // accelerated surface code. Returns true on success.
33 bool CreateDevice(const base::ScopedNativeLibrary
& d3d_module
,
34 D3DDEVTYPE device_type
,
35 uint32 presentation_interval
,
36 IDirect3DDevice9Ex
** device
);
38 // Calls the Vista+ (WDDM1.0) variant of CreateTexture that semantically
39 // opens a texture allocated (possibly in another process) as shared. The
40 // shared texture is identified by its surface handle. The resulting texture
41 // is written into |opened_texture|.
43 // Returns true on success.
45 bool OpenSharedTexture(IDirect3DDevice9
* device
,
47 const gfx::Size
& size
,
48 IDirect3DTexture9
** opened_texture
);
50 // Create a one-off lockable surface of a specified size.
52 // Returns true on success.
54 bool CreateTemporaryLockableSurface(IDirect3DDevice9
* device
,
55 const gfx::Size
& size
,
56 IDirect3DSurface9
** surface
);
58 // Create a one-off renderable texture of a specified size. The texture object
59 // as well as the surface object for the texture's level 0 is returned (callers
60 // almost always need to use both).
62 // Returns true on success.
64 bool CreateTemporaryRenderTargetTexture(IDirect3DDevice9
* device
,
65 const gfx::Size
& size
,
66 IDirect3DTexture9
** texture
,
67 IDirect3DSurface9
** render_target
);
70 gfx::Size
GetSize(IDirect3DTexture9
* texture
);
73 gfx::Size
GetSize(IDirect3DSurface9
* surface
);
75 } // namespace ui_surface_d3d9_utils
77 #endif // UI_SURFACE_D3D9_UTILS_WIN_H_