OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/surface/d3d9_utils_win.h" | 5 #include "ui/surface/d3d9_utils_win.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/scoped_native_library.h" | 8 #include "base/scoped_native_library.h" |
9 #include "base/win/scoped_comptr.h" | 9 #include "base/win/scoped_comptr.h" |
10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/size.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 const wchar_t kD3D9ModuleName[] = L"d3d9.dll"; | 14 const wchar_t kD3D9ModuleName[] = L"d3d9.dll"; |
15 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex"; | 15 const char kCreate3D9DeviceExName[] = "Direct3DCreate9Ex"; |
16 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version, | 16 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT sdk_version, |
17 IDirect3D9Ex **d3d); | 17 IDirect3D9Ex **d3d); |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace ui_surface_d3d9_utils { | 20 namespace ui_surface_d3d9_utils { |
21 | 21 |
22 bool LoadD3D9(base::ScopedNativeLibrary* storage) { | 22 bool LoadD3D9(base::ScopedNativeLibrary* storage) { |
23 storage->Reset(base::LoadNativeLibrary(FilePath(kD3D9ModuleName), NULL)); | 23 storage->Reset( |
| 24 base::LoadNativeLibrary(base::FilePath(kD3D9ModuleName), NULL)); |
24 return storage->is_valid(); | 25 return storage->is_valid(); |
25 } | 26 } |
26 | 27 |
27 bool CreateDevice(const base::ScopedNativeLibrary& d3d_module, | 28 bool CreateDevice(const base::ScopedNativeLibrary& d3d_module, |
28 D3DDEVTYPE device_type, | 29 D3DDEVTYPE device_type, |
29 uint32 presentation_interval, | 30 uint32 presentation_interval, |
30 IDirect3DDevice9Ex** device) { | 31 IDirect3DDevice9Ex** device) { |
31 | 32 |
32 Direct3DCreate9ExFunc create_func = reinterpret_cast<Direct3DCreate9ExFunc>( | 33 Direct3DCreate9ExFunc create_func = reinterpret_cast<Direct3DCreate9ExFunc>( |
33 d3d_module.GetFunctionPointer(kCreate3D9DeviceExName)); | 34 d3d_module.GetFunctionPointer(kCreate3D9DeviceExName)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 127 |
127 gfx::Size GetSize(IDirect3DTexture9* texture) { | 128 gfx::Size GetSize(IDirect3DTexture9* texture) { |
128 D3DSURFACE_DESC surface_description; | 129 D3DSURFACE_DESC surface_description; |
129 HRESULT hr = texture->GetLevelDesc(0, &surface_description); | 130 HRESULT hr = texture->GetLevelDesc(0, &surface_description); |
130 if (FAILED(hr)) | 131 if (FAILED(hr)) |
131 return gfx::Size(0, 0); | 132 return gfx::Size(0, 0); |
132 return gfx::Size(surface_description.Width, surface_description.Height); | 133 return gfx::Size(surface_description.Width, surface_description.Height); |
133 } | 134 } |
134 | 135 |
135 } // namespace ui_surface_d3d9_utils | 136 } // namespace ui_surface_d3d9_utils |
OLD | NEW |