OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "content/common/child_process.h" | 15 #include "content/common/child_process.h" |
16 #include "content/common/content_client.h" | 16 #include "content/common/content_client.h" |
17 #include "content/common/content_switches.h" | 17 #include "content/common/content_switches.h" |
18 #include "content/common/gpu/gpu_channel_manager.h" | 18 #include "content/common/gpu/gpu_channel_manager.h" |
19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
20 #include "content/common/gpu/media/gpu_video_service.h" | |
21 #include "content/common/gpu/transport_texture.h" | 20 #include "content/common/gpu/transport_texture.h" |
22 #include "ui/gfx/gl/gl_context.h" | 21 #include "ui/gfx/gl/gl_context.h" |
23 #include "ui/gfx/gl/gl_surface.h" | 22 #include "ui/gfx/gl/gl_surface.h" |
24 | 23 |
25 #if defined(OS_POSIX) | 24 #if defined(OS_POSIX) |
26 #include "ipc/ipc_channel_posix.h" | 25 #include "ipc/ipc_channel_posix.h" |
27 #endif | 26 #endif |
28 | 27 |
29 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, | 28 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, |
30 GpuWatchdog* watchdog, | 29 GpuWatchdog* watchdog, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 if (router_.ResolveRoute(route_id)) { | 330 if (router_.ResolveRoute(route_id)) { |
332 router_.RemoveRoute(route_id); | 331 router_.RemoveRoute(route_id); |
333 surfaces_.Remove(route_id); | 332 surfaces_.Remove(route_id); |
334 } | 333 } |
335 #endif | 334 #endif |
336 } | 335 } |
337 | 336 |
338 void GpuChannel::OnCreateVideoDecoder(int32 decoder_host_id, | 337 void GpuChannel::OnCreateVideoDecoder(int32 decoder_host_id, |
339 uint32 command_buffer_route_id, | 338 uint32 command_buffer_route_id, |
340 const std::vector<uint32>& configs) { | 339 const std::vector<uint32>& configs) { |
341 GpuVideoService* service = GpuVideoService::GetInstance(); | |
342 if (service == NULL) { | |
343 // TODO(hclam): Need to send a failure message. | |
344 return; | |
345 } | |
346 | |
347 GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); | 340 GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); |
348 // TODO(vrk): Need to notify renderer that given route is invalid. | 341 // TODO(vrk): Need to notify renderer that given route is invalid. |
349 if (!stub) | 342 if (!stub) |
350 return; | 343 return; |
351 | 344 |
352 int32 decoder_id = GenerateRouteID(); | 345 int32 decoder_id = GenerateRouteID(); |
353 | 346 |
354 // TODO(fischman): this is a BUG. We hand off stub to be baked into the | 347 // Create GpuVideoDecodeAccelerator and add to map. |
355 // resulting GpuVideoDecodeAccelerator, but we don't own that GVDA, and we | 348 scoped_ptr<GpuVideoDecodeAccelerator> decoder( |
356 // make no attempt to tear it down if/when stub is destroyed. GpuVideoService | 349 new GpuVideoDecodeAccelerator(this, decoder_host_id, decoder_id, stub)); |
357 // should be subsumed into this class and GpuVideoDecodeAccelerator should be | 350 router_.AddRoute(decoder_id, decoder.get()); |
358 // owned by GpuCommandBufferStub. | 351 stub->set_video_decoder(decoder.release()); |
359 bool ret = service->CreateVideoDecoder( | 352 bool result = stubs_by_video_decoder_id_.insert(std::make_pair( |
apatrick_chromium
2011/06/30 21:11:16
Rather than maintaining a map of video decoder id
vrk (LEFT CHROMIUM)
2011/07/01 18:12:14
D'oh.
Emphatic yes to everything! These suggestio
| |
360 this, &router_, decoder_host_id, decoder_id, stub, configs); | 353 decoder_id, stub)).second; |
361 DCHECK(ret) << "Failed to create a GpuVideoDecodeAccelerator"; | 354 DCHECK(result); |
355 | |
356 // Tell client that creation is complete. | |
357 Send(new AcceleratedVideoDecoderHostMsg_CreateDone( | |
358 decoder_host_id, decoder_id)); | |
362 } | 359 } |
363 | 360 |
364 void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { | 361 void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { |
365 #if defined(ENABLE_GPU) | 362 #if defined(ENABLE_GPU) |
366 LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder"; | 363 LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder"; |
367 GpuVideoService* service = GpuVideoService::GetInstance(); | 364 router_.RemoveRoute(decoder_id); |
368 if (service == NULL) | 365 std::map<int32, GpuCommandBufferStub*>::iterator it = |
366 stubs_by_video_decoder_id_.find(decoder_id); | |
367 DCHECK(it != stubs_by_video_decoder_id_.end()); | |
368 GpuCommandBufferStub* stub = it->second; | |
369 // TODO(fischman/vrk): Throw error. | |
370 if (!stub) | |
369 return; | 371 return; |
370 service->DestroyVideoDecoder(&router_, decoder_id); | 372 stubs_by_video_decoder_id_.erase(decoder_id); |
373 stub->DestroyVideoDecoder(); | |
371 #endif | 374 #endif |
372 } | 375 } |
373 | 376 |
374 void GpuChannel::OnCreateTransportTexture(int32 context_route_id, | 377 void GpuChannel::OnCreateTransportTexture(int32 context_route_id, |
375 int32 host_id) { | 378 int32 host_id) { |
376 #if defined(ENABLE_GPU) | 379 #if defined(ENABLE_GPU) |
377 GpuCommandBufferStub* stub = stubs_.Lookup(context_route_id); | 380 GpuCommandBufferStub* stub = stubs_.Lookup(context_route_id); |
378 int32 route_id = GenerateRouteID(); | 381 int32 route_id = GenerateRouteID(); |
379 | 382 |
380 scoped_ptr<TransportTexture> transport( | 383 scoped_ptr<TransportTexture> transport( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 417 |
415 #if defined(OS_POSIX) | 418 #if defined(OS_POSIX) |
416 int GpuChannel::GetRendererFileDescriptor() { | 419 int GpuChannel::GetRendererFileDescriptor() { |
417 int fd = -1; | 420 int fd = -1; |
418 if (channel_.get()) { | 421 if (channel_.get()) { |
419 fd = channel_->GetClientFileDescriptor(); | 422 fd = channel_->GetClientFileDescriptor(); |
420 } | 423 } |
421 return fd; | 424 return fd; |
422 } | 425 } |
423 #endif // defined(OS_POSIX) | 426 #endif // defined(OS_POSIX) |
OLD | NEW |