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 "media/gpu/ipc/service/gpu_video_decode_accelerator.h" | 5 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
19 #include "gpu/command_buffer/service/gpu_preferences.h" | 19 #include "gpu/command_buffer/service/gpu_preferences.h" |
20 #include "gpu/ipc/service/gpu_channel.h" | 20 #include "gpu/ipc/service/gpu_channel.h" |
21 #include "gpu/ipc/service/gpu_channel_manager.h" | 21 #include "gpu/ipc/service/gpu_channel_manager.h" |
22 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
23 #include "ipc/ipc_message_utils.h" | 23 #include "ipc/ipc_message_utils.h" |
24 #include "ipc/message_filter.h" | 24 #include "ipc/message_filter.h" |
25 #include "media/base/limits.h" | 25 #include "media/base/limits.h" |
26 #include "media/gpu/gpu_video_accelerator_util.h" | 26 #include "media/gpu/gpu_video_accelerator_util.h" |
27 #include "media/gpu/gpu_video_decode_accelerator_factory_impl.h" | 27 #include "media/gpu/gpu_video_decode_accelerator_factory.h" |
28 #include "media/gpu/ipc/common/media_messages.h" | 28 #include "media/gpu/ipc/common/media_messages.h" |
29 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
30 #include "ui/gl/gl_context.h" | 30 #include "ui/gl/gl_context.h" |
31 #include "ui/gl/gl_image.h" | 31 #include "ui/gl/gl_image.h" |
32 | 32 |
33 namespace media { | 33 namespace media { |
34 | 34 |
35 namespace { | 35 namespace { |
36 static gl::GLContext* GetGLContext( | 36 static gl::GLContext* GetGLContext( |
37 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) { | 37 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 180 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
181 // This class can only be self-deleted from OnWillDestroyStub(), which means | 181 // This class can only be self-deleted from OnWillDestroyStub(), which means |
182 // the VDA has already been destroyed in there. | 182 // the VDA has already been destroyed in there. |
183 DCHECK(!video_decode_accelerator_); | 183 DCHECK(!video_decode_accelerator_); |
184 } | 184 } |
185 | 185 |
186 // static | 186 // static |
187 gpu::VideoDecodeAcceleratorCapabilities | 187 gpu::VideoDecodeAcceleratorCapabilities |
188 GpuVideoDecodeAccelerator::GetCapabilities( | 188 GpuVideoDecodeAccelerator::GetCapabilities( |
189 const gpu::GpuPreferences& gpu_preferences) { | 189 const gpu::GpuPreferences& gpu_preferences) { |
190 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( | 190 return GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities( |
191 gpu_preferences); | 191 gpu_preferences); |
192 } | 192 } |
193 | 193 |
194 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 194 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
195 if (!video_decode_accelerator_) | 195 if (!video_decode_accelerator_) |
196 return false; | 196 return false; |
197 | 197 |
198 bool handled = true; | 198 bool handled = true; |
199 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 199 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
200 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 200 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return false; | 338 return false; |
339 } | 339 } |
340 | 340 |
341 #if !defined(OS_WIN) | 341 #if !defined(OS_WIN) |
342 // Ensure we will be able to get a GL context at all before initializing | 342 // Ensure we will be able to get a GL context at all before initializing |
343 // non-Windows VDAs. | 343 // non-Windows VDAs. |
344 if (!make_context_current_cb_.Run()) | 344 if (!make_context_current_cb_.Run()) |
345 return false; | 345 return false; |
346 #endif | 346 #endif |
347 | 347 |
348 std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = | 348 std::unique_ptr<GpuVideoDecodeAcceleratorFactory> vda_factory = |
349 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( | 349 GpuVideoDecodeAcceleratorFactory::CreateWithGLES2Decoder( |
350 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, | 350 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
351 get_gles2_decoder_cb_); | 351 get_gles2_decoder_cb_); |
352 | 352 |
353 if (!vda_factory) { | 353 if (!vda_factory) { |
354 LOG(ERROR) << "Failed creating the VDA factory"; | 354 LOG(ERROR) << "Failed creating the VDA factory"; |
355 return false; | 355 return false; |
356 } | 356 } |
357 | 357 |
358 const gpu::GpuDriverBugWorkarounds& gpu_workarounds = | 358 const gpu::GpuDriverBugWorkarounds& gpu_workarounds = |
359 stub_->channel()->gpu_channel_manager()->gpu_driver_bug_workarounds(); | 359 stub_->channel()->gpu_channel_manager()->gpu_driver_bug_workarounds(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 GLenum target = texture_ref->texture()->target(); | 514 GLenum target = texture_ref->texture()->target(); |
515 gpu::gles2::TextureManager* texture_manager = | 515 gpu::gles2::TextureManager* texture_manager = |
516 stub_->decoder()->GetContextGroup()->texture_manager(); | 516 stub_->decoder()->GetContextGroup()->texture_manager(); |
517 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 517 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
518 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 518 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
519 } | 519 } |
520 uncleared_textures_.erase(it); | 520 uncleared_textures_.erase(it); |
521 } | 521 } |
522 | 522 |
523 } // namespace media | 523 } // namespace media |
OLD | NEW |