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.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
6 | 6 |
7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
8 #error This file should only be built on Windows. | 8 #error This file should only be built on Windows. |
9 #endif // !defined(OS_WIN) | 9 #endif // !defined(OS_WIN) |
10 | 10 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 hr = device_->StretchRect(dest_surface, | 384 hr = device_->StretchRect(dest_surface, |
385 NULL, | 385 NULL, |
386 d3d_surface, | 386 d3d_surface, |
387 NULL, | 387 NULL, |
388 D3DTEXF_NONE); | 388 D3DTEXF_NONE); |
389 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", | 389 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", |
390 false); | 390 false); |
391 // Ideally, this should be done immediately before the draw call that uses | 391 // Ideally, this should be done immediately before the draw call that uses |
392 // the texture. Flush it once here though. | 392 // the texture. Flush it once here though. |
393 hr = query_->Issue(D3DISSUE_END); | 393 hr = query_->Issue(D3DISSUE_END); |
| 394 RETURN_ON_HR_FAILURE(hr, "Failed to issue END", false); |
394 do { | 395 do { |
395 hr = query_->GetData(NULL, 0, D3DGETDATA_FLUSH); | 396 hr = query_->GetData(NULL, 0, D3DGETDATA_FLUSH); |
396 if (hr == S_FALSE) | 397 if (hr == S_FALSE) |
397 Sleep(0); | 398 Sleep(1); // Poor-man's Yield(). |
398 } while (hr == S_FALSE); | 399 } while (hr == S_FALSE); |
399 | 400 |
400 eglBindTexImage( | 401 eglBindTexImage( |
401 static_cast<EGLDisplay*>(eglGetDisplay(EGL_DEFAULT_DISPLAY)), | 402 static_cast<EGLDisplay*>(eglGetDisplay(EGL_DEFAULT_DISPLAY)), |
402 decoding_surface_, | 403 decoding_surface_, |
403 EGL_BACK_BUFFER); | 404 EGL_BACK_BUFFER); |
404 } else { | 405 } else { |
405 scoped_array<char> bits; | 406 scoped_array<char> bits; |
406 RETURN_ON_FAILURE(GetBitmapFromSurface(DXVAVideoDecodeAccelerator::device_, | 407 RETURN_ON_FAILURE(GetBitmapFromSurface(DXVAVideoDecodeAccelerator::device_, |
407 dest_surface, &bits), | 408 dest_surface, &bits), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 483 |
483 hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token_, | 484 hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token_, |
484 &device_manager_); | 485 &device_manager_); |
485 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed", false); | 486 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed", false); |
486 | 487 |
487 hr = device_manager_->ResetDevice(device_, dev_manager_reset_token_); | 488 hr = device_manager_->ResetDevice(device_, dev_manager_reset_token_); |
488 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); | 489 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); |
489 | 490 |
490 hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, &query_); | 491 hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, &query_); |
491 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false); | 492 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false); |
| 493 // Ensure query_ API works (to avoid an infinite loop later in |
| 494 // CopyOutputSampleDataToPictureBuffer). |
| 495 hr = query_->Issue(D3DISSUE_END); |
| 496 RETURN_ON_HR_FAILURE(hr, "Failed to issue END test query", false); |
492 | 497 |
493 return true; | 498 return true; |
494 } | 499 } |
495 | 500 |
496 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( | 501 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( |
497 media::VideoDecodeAccelerator::Client* client) | 502 media::VideoDecodeAccelerator::Client* client) |
498 : client_(client), | 503 : client_(client), |
499 egl_config_(NULL), | 504 egl_config_(NULL), |
500 state_(kUninitialized), | 505 state_(kUninitialized), |
501 pictures_requested_(false), | 506 pictures_requested_(false), |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 GL_TEXTURE_2D); | 1047 GL_TEXTURE_2D); |
1043 } | 1048 } |
1044 } | 1049 } |
1045 | 1050 |
1046 void DXVAVideoDecodeAccelerator::NotifyPictureReady( | 1051 void DXVAVideoDecodeAccelerator::NotifyPictureReady( |
1047 const media::Picture& picture) { | 1052 const media::Picture& picture) { |
1048 // This task could execute after the decoder has been torn down. | 1053 // This task could execute after the decoder has been torn down. |
1049 if (state_ != kUninitialized && client_) | 1054 if (state_ != kUninitialized && client_) |
1050 client_->PictureReady(picture); | 1055 client_->PictureReady(picture); |
1051 } | 1056 } |
OLD | NEW |