| 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 "content/common/gpu/media/dxva_video_decode_accelerator_win.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
| 10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { | 1031 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { |
| 1032 TRACE_EVENT0("gpu", "DXVAVideoDecodeAccelerator_CreateD3DDevManager"); | 1032 TRACE_EVENT0("gpu", "DXVAVideoDecodeAccelerator_CreateD3DDevManager"); |
| 1033 | 1033 |
| 1034 HRESULT hr = E_FAIL; | 1034 HRESULT hr = E_FAIL; |
| 1035 | 1035 |
| 1036 hr = Direct3DCreate9Ex(D3D_SDK_VERSION, d3d9_.Receive()); | 1036 hr = Direct3DCreate9Ex(D3D_SDK_VERSION, d3d9_.Receive()); |
| 1037 RETURN_ON_HR_FAILURE(hr, "Direct3DCreate9Ex failed", false); | 1037 RETURN_ON_HR_FAILURE(hr, "Direct3DCreate9Ex failed", false); |
| 1038 | 1038 |
| 1039 hr = d3d9_->CheckDeviceFormatConversion( |
| 1040 D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, |
| 1041 static_cast<D3DFORMAT>(MAKEFOURCC('N', 'V', '1', '2')), |
| 1042 D3DFMT_X8R8G8B8); |
| 1043 RETURN_ON_HR_FAILURE(hr, |
| 1044 "D3D9 driver does not support H/W format conversion", false); |
| 1045 |
| 1039 base::win::ScopedComPtr<IDirect3DDevice9> angle_device = | 1046 base::win::ScopedComPtr<IDirect3DDevice9> angle_device = |
| 1040 QueryDeviceObjectFromANGLE<IDirect3DDevice9>(EGL_D3D9_DEVICE_ANGLE); | 1047 QueryDeviceObjectFromANGLE<IDirect3DDevice9>(EGL_D3D9_DEVICE_ANGLE); |
| 1041 if (angle_device.get()) | 1048 if (angle_device.get()) |
| 1042 using_angle_device_ = true; | 1049 using_angle_device_ = true; |
| 1043 | 1050 |
| 1044 if (using_angle_device_) { | 1051 if (using_angle_device_) { |
| 1045 hr = d3d9_device_ex_.QueryFrom(angle_device.get()); | 1052 hr = d3d9_device_ex_.QueryFrom(angle_device.get()); |
| 1046 RETURN_ON_HR_FAILURE(hr, | 1053 RETURN_ON_HR_FAILURE(hr, |
| 1047 "QueryInterface for IDirect3DDevice9Ex from angle device failed", | 1054 "QueryInterface for IDirect3DDevice9Ex from angle device failed", |
| 1048 false); | 1055 false); |
| 1049 } else { | 1056 } else { |
| 1050 D3DPRESENT_PARAMETERS present_params = {0}; | 1057 D3DPRESENT_PARAMETERS present_params = {0}; |
| 1051 present_params.BackBufferWidth = 1; | 1058 present_params.BackBufferWidth = 1; |
| 1052 present_params.BackBufferHeight = 1; | 1059 present_params.BackBufferHeight = 1; |
| 1053 present_params.BackBufferFormat = D3DFMT_UNKNOWN; | 1060 present_params.BackBufferFormat = D3DFMT_UNKNOWN; |
| 1054 present_params.BackBufferCount = 1; | 1061 present_params.BackBufferCount = 1; |
| 1055 present_params.SwapEffect = D3DSWAPEFFECT_DISCARD; | 1062 present_params.SwapEffect = D3DSWAPEFFECT_DISCARD; |
| 1056 present_params.hDeviceWindow = NULL; | 1063 present_params.hDeviceWindow = NULL; |
| 1057 present_params.Windowed = TRUE; | 1064 present_params.Windowed = TRUE; |
| 1058 present_params.Flags = D3DPRESENTFLAG_VIDEO; | 1065 present_params.Flags = D3DPRESENTFLAG_VIDEO; |
| 1059 present_params.FullScreen_RefreshRateInHz = 0; | 1066 present_params.FullScreen_RefreshRateInHz = 0; |
| 1060 present_params.PresentationInterval = 0; | 1067 present_params.PresentationInterval = 0; |
| 1061 | 1068 |
| 1062 hr = d3d9_->CreateDeviceEx(D3DADAPTER_DEFAULT, | 1069 hr = d3d9_->CreateDeviceEx(D3DADAPTER_DEFAULT, |
| 1063 D3DDEVTYPE_HAL, | 1070 D3DDEVTYPE_HAL, |
| 1064 NULL, | 1071 NULL, |
| 1065 D3DCREATE_FPU_PRESERVE | | 1072 D3DCREATE_FPU_PRESERVE | |
| 1066 D3DCREATE_HARDWARE_VERTEXPROCESSING | | 1073 D3DCREATE_MIXED_VERTEXPROCESSING | |
| 1067 D3DCREATE_DISABLE_PSGP_THREADING | | |
| 1068 D3DCREATE_MULTITHREADED, | 1074 D3DCREATE_MULTITHREADED, |
| 1069 &present_params, | 1075 &present_params, |
| 1070 NULL, | 1076 NULL, |
| 1071 d3d9_device_ex_.Receive()); | 1077 d3d9_device_ex_.Receive()); |
| 1072 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device", false); | 1078 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device", false); |
| 1073 } | 1079 } |
| 1074 | 1080 |
| 1075 hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token_, | 1081 hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token_, |
| 1076 device_manager_.Receive()); | 1082 device_manager_.Receive()); |
| 1077 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed", false); | 1083 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed", false); |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 DismissStaleBuffers(true); | 2975 DismissStaleBuffers(true); |
| 2970 Invalidate(); | 2976 Invalidate(); |
| 2971 Initialize(config_, client_); | 2977 Initialize(config_, client_); |
| 2972 decoder_thread_task_runner_->PostTask( | 2978 decoder_thread_task_runner_->PostTask( |
| 2973 FROM_HERE, | 2979 FROM_HERE, |
| 2974 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2980 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2975 base::Unretained(this))); | 2981 base::Unretained(this))); |
| 2976 } | 2982 } |
| 2977 | 2983 |
| 2978 } // namespace content | 2984 } // namespace content |
| OLD | NEW |