Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: media/mf/d3d_util.cc

Issue 3156046: Changed mft_h264_decoder's API to match with video_decode_engine.h. Also chan... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #include "media/mf/d3d_util.h"
6
7 #include <d3d9.h>
8 #include <dxva2api.h>
9
10 #include "base/scoped_comptr_win.h"
11
12 namespace media {
13
14 IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window,
15 IDirect3D9** direct3d,
16 IDirect3DDevice9** device) {
17 ScopedComPtr<IDirect3DDeviceManager9> dev_manager;
18 ScopedComPtr<IDirect3D9> d3d;
19 d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));
20 if (d3d == NULL) {
21 LOG(ERROR) << "Failed to create D3D9";
22 return NULL;
23 }
24 D3DPRESENT_PARAMETERS present_params = {0};
25
26 // Once we know the dimensions, we need to reset using
27 // AdjustD3DDeviceBackBufferDimensions().
28 present_params.BackBufferWidth = 0;
29 present_params.BackBufferHeight = 0;
30 present_params.BackBufferFormat = D3DFMT_UNKNOWN;
31 present_params.BackBufferCount = 1;
32 present_params.SwapEffect = D3DSWAPEFFECT_DISCARD;
33 present_params.hDeviceWindow = video_window;
34 present_params.Windowed = TRUE;
35 present_params.Flags = D3DPRESENTFLAG_VIDEO;
36 present_params.FullScreen_RefreshRateInHz = 0;
37 present_params.PresentationInterval = 0;
38
39 ScopedComPtr<IDirect3DDevice9> temp_device;
40
41 // D3DCREATE_HARDWARE_VERTEXPROCESSING specifies hardware vertex processing.
42 // (Is it even needed for just video decoding?)
43 HRESULT hr = d3d->CreateDevice(D3DADAPTER_DEFAULT,
44 D3DDEVTYPE_HAL,
45 NULL,
46 D3DCREATE_HARDWARE_VERTEXPROCESSING,
47 &present_params,
48 temp_device.Receive());
49 if (FAILED(hr)) {
50 LOG(ERROR) << "Failed to create D3D Device";
51 return NULL;
52 }
53 UINT dev_manager_reset_token = 0;
54 hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token,
55 dev_manager.Receive());
56 if (FAILED(hr)) {
57 LOG(ERROR) << "Couldn't create D3D Device manager";
58 return NULL;
59 }
60 hr = dev_manager->ResetDevice(temp_device.get(), dev_manager_reset_token);
61 if (FAILED(hr)) {
62 LOG(ERROR) << "Failed to set device to device manager";
63 return NULL;
64 }
65 *direct3d = d3d.Detach();
66 *device = temp_device.Detach();
67 return dev_manager.Detach();
68 }
69
70 bool AdjustD3DDeviceBackBufferDimensions(IDirect3DDevice9* device,
71 HWND video_window,
72 int width,
73 int height) {
74 D3DPRESENT_PARAMETERS present_params = {0};
75 present_params.BackBufferWidth = width;
76 present_params.BackBufferHeight = height;
77 present_params.BackBufferFormat = D3DFMT_UNKNOWN;
78 present_params.BackBufferCount = 1;
79 present_params.SwapEffect = D3DSWAPEFFECT_DISCARD;
80 present_params.hDeviceWindow = video_window;
81 present_params.Windowed = TRUE;
82 present_params.Flags = D3DPRESENTFLAG_VIDEO;
83 present_params.FullScreen_RefreshRateInHz = 0;
84 present_params.PresentationInterval = 0;
85
86 return SUCCEEDED(device->Reset(&present_params)) ? true : false;
87 }
88
89 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698