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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 use_rgb_ ? D3DFMT_X8R8G8B8 : D3DFMT_A8R8G8B8); | 316 use_rgb_ ? D3DFMT_X8R8G8B8 : D3DFMT_A8R8G8B8); |
317 RETURN_ON_HR_FAILURE(hr, "Device does not support format converision", false); | 317 RETURN_ON_HR_FAILURE(hr, "Device does not support format converision", false); |
318 | 318 |
319 // This function currently executes in the context of IPC handlers in the | 319 // This function currently executes in the context of IPC handlers in the |
320 // GPU process which ensures that there is always an OpenGL context. | 320 // GPU process which ensures that there is always an OpenGL context. |
321 GLint current_texture = 0; | 321 GLint current_texture = 0; |
322 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); | 322 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); |
323 | 323 |
324 glBindTexture(GL_TEXTURE_2D, picture_buffer_.texture_id()); | 324 glBindTexture(GL_TEXTURE_2D, picture_buffer_.texture_id()); |
325 | 325 |
326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
327 | 327 |
328 base::win::ScopedComPtr<IDirect3DSurface9> d3d_surface; | 328 base::win::ScopedComPtr<IDirect3DSurface9> d3d_surface; |
329 hr = decoding_texture_->GetSurfaceLevel(0, d3d_surface.Receive()); | 329 hr = decoding_texture_->GetSurfaceLevel(0, d3d_surface.Receive()); |
330 RETURN_ON_HR_FAILURE(hr, "Failed to get surface from texture", false); | 330 RETURN_ON_HR_FAILURE(hr, "Failed to get surface from texture", false); |
331 | 331 |
332 hr = decoder.device_->StretchRect( | 332 hr = decoder.device_->StretchRect( |
333 dest_surface, NULL, d3d_surface, NULL, D3DTEXF_NONE); | 333 dest_surface, NULL, d3d_surface, NULL, D3DTEXF_NONE); |
334 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", | 334 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", |
335 false); | 335 false); |
336 | 336 |
(...skipping 18 matching lines...) Expand all Loading... |
355 int iterations = 0; | 355 int iterations = 0; |
356 while ((decoder.query_->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) && | 356 while ((decoder.query_->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) && |
357 ++iterations < kMaxIterationsForD3DFlush) { | 357 ++iterations < kMaxIterationsForD3DFlush) { |
358 Sleep(1); // Poor-man's Yield(). | 358 Sleep(1); // Poor-man's Yield(). |
359 } | 359 } |
360 EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay(); | 360 EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay(); |
361 eglBindTexImage( | 361 eglBindTexImage( |
362 egl_display, | 362 egl_display, |
363 decoding_surface_, | 363 decoding_surface_, |
364 EGL_BACK_BUFFER); | 364 EGL_BACK_BUFFER); |
365 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 365 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
366 glBindTexture(GL_TEXTURE_2D, current_texture); | 366 glBindTexture(GL_TEXTURE_2D, current_texture); |
367 return true; | 367 return true; |
368 } | 368 } |
369 | 369 |
370 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 370 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
371 int32 buffer_id, IMFSample* sample) | 371 int32 buffer_id, IMFSample* sample) |
372 : input_buffer_id(buffer_id) { | 372 : input_buffer_id(buffer_id) { |
373 output_sample.Attach(sample); | 373 output_sample.Attach(sample); |
374 } | 374 } |
375 | 375 |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 int32 picture_buffer_id) { | 1218 int32 picture_buffer_id) { |
1219 OutputBuffers::iterator it = stale_output_picture_buffers_.find( | 1219 OutputBuffers::iterator it = stale_output_picture_buffers_.find( |
1220 picture_buffer_id); | 1220 picture_buffer_id); |
1221 DCHECK(it != stale_output_picture_buffers_.end()); | 1221 DCHECK(it != stale_output_picture_buffers_.end()); |
1222 DVLOG(1) << "Dismissing picture id: " << it->second->id(); | 1222 DVLOG(1) << "Dismissing picture id: " << it->second->id(); |
1223 client_->DismissPictureBuffer(it->second->id()); | 1223 client_->DismissPictureBuffer(it->second->id()); |
1224 stale_output_picture_buffers_.erase(it); | 1224 stale_output_picture_buffers_.erase(it); |
1225 } | 1225 } |
1226 | 1226 |
1227 } // namespace content | 1227 } // namespace content |
OLD | NEW |