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 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 231 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
232 IPC_MESSAGE_HANDLER(GpuChannelMsg_Initialize, OnInitialize) | 232 IPC_MESSAGE_HANDLER(GpuChannelMsg_Initialize, OnInitialize) |
233 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 233 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
234 OnCreateOffscreenCommandBuffer) | 234 OnCreateOffscreenCommandBuffer) |
235 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 235 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
236 OnDestroyCommandBuffer) | 236 OnDestroyCommandBuffer) |
237 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenSurface, | 237 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenSurface, |
238 OnCreateOffscreenSurface) | 238 OnCreateOffscreenSurface) |
239 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroySurface, OnDestroySurface) | 239 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroySurface, OnDestroySurface) |
240 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, | 240 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, |
241 OnCreateVideoDecoder) | 241 OnCreateVideoDecoder) |
242 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, | 242 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, |
243 OnDestroyVideoDecoder) | 243 OnDestroyVideoDecoder) |
244 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateTransportTexture, | 244 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateTransportTexture, |
245 OnCreateTransportTexture) | 245 OnCreateTransportTexture) |
246 IPC_MESSAGE_HANDLER(GpuChannelMsg_AssignTexturesToVideoDecoder, | |
247 OnAssignTexturesToVideoDecoder) | |
248 IPC_MESSAGE_UNHANDLED(handled = false) | 246 IPC_MESSAGE_UNHANDLED(handled = false) |
249 IPC_END_MESSAGE_MAP() | 247 IPC_END_MESSAGE_MAP() |
250 DCHECK(handled) << msg.type(); | 248 DCHECK(handled) << msg.type(); |
251 return handled; | 249 return handled; |
252 } | 250 } |
253 | 251 |
254 int GpuChannel::GenerateRouteID() { | 252 int GpuChannel::GenerateRouteID() { |
255 static int last_id = 0; | 253 static int last_id = 0; |
256 return ++last_id; | 254 return ++last_id; |
257 } | 255 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 return; | 344 return; |
347 } | 345 } |
348 | 346 |
349 GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); | 347 GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); |
350 // TODO(vrk): Need to notify renderer that given route is invalid. | 348 // TODO(vrk): Need to notify renderer that given route is invalid. |
351 if (!stub) | 349 if (!stub) |
352 return; | 350 return; |
353 | 351 |
354 int32 decoder_id = GenerateRouteID(); | 352 int32 decoder_id = GenerateRouteID(); |
355 | 353 |
356 // TODO(fischman): this is a BUG. We hand off stub->scheduler()->decoder() | 354 // TODO(fischman): this is a BUG. We hand off stub to be baked into the |
357 // to be baked into the resulting GpuVideoDecodeAccelerator, but we don't own | 355 // resulting GpuVideoDecodeAccelerator, but we don't own that GVDA, and we |
358 // that GVDA, and we make no attempt to tear it down if/when | 356 // make no attempt to tear it down if/when stub is destroyed. GpuVideoService |
359 // stub->scheduler()->decoder() is destroyed. GpuVideoService should be | 357 // should be subsumed into this class and GpuVideoDecodeAccelerator should be |
360 // subsumed into this class and GpuVideoDecodeAccelerator should be owned by | 358 // owned by GpuCommandBufferStub. |
361 // the GpuCommandBufferStub that owns the commandbuffer GVDA is using. | |
362 bool ret = service->CreateVideoDecoder( | 359 bool ret = service->CreateVideoDecoder( |
363 this, &router_, decoder_host_id, decoder_id, stub->scheduler()->decoder(), | 360 this, &router_, decoder_host_id, decoder_id, stub, configs); |
364 configs); | |
365 DCHECK(ret) << "Failed to create a GpuVideoDecodeAccelerator"; | 361 DCHECK(ret) << "Failed to create a GpuVideoDecodeAccelerator"; |
366 } | 362 } |
367 | 363 |
368 void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { | 364 void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) { |
369 #if defined(ENABLE_GPU) | 365 #if defined(ENABLE_GPU) |
370 LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder"; | 366 LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder"; |
371 GpuVideoService* service = GpuVideoService::GetInstance(); | 367 GpuVideoService* service = GpuVideoService::GetInstance(); |
372 if (service == NULL) | 368 if (service == NULL) |
373 return; | 369 return; |
374 service->DestroyVideoDecoder(&router_, decoder_id); | 370 service->DestroyVideoDecoder(&router_, decoder_id); |
(...skipping 11 matching lines...) Expand all Loading... |
386 host_id, route_id)); | 382 host_id, route_id)); |
387 router_.AddRoute(route_id, transport.get()); | 383 router_.AddRoute(route_id, transport.get()); |
388 transport_textures_.AddWithID(transport.release(), route_id); | 384 transport_textures_.AddWithID(transport.release(), route_id); |
389 | 385 |
390 IPC::Message* msg = new GpuTransportTextureHostMsg_TransportTextureCreated( | 386 IPC::Message* msg = new GpuTransportTextureHostMsg_TransportTextureCreated( |
391 host_id, route_id); | 387 host_id, route_id); |
392 Send(msg); | 388 Send(msg); |
393 #endif | 389 #endif |
394 } | 390 } |
395 | 391 |
396 void GpuChannel::OnAssignTexturesToVideoDecoder( | |
397 int32 decoder_id, | |
398 const std::vector<int32>& buffer_ids, | |
399 const std::vector<uint32>& texture_ids, | |
400 const std::vector<gfx::Size>& sizes) { | |
401 GpuVideoService* service = GpuVideoService::GetInstance(); | |
402 service->AssignTexturesToDecoder(decoder_id, buffer_ids, texture_ids, sizes); | |
403 } | |
404 | |
405 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, | 392 bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop, |
406 base::WaitableEvent* shutdown_event) { | 393 base::WaitableEvent* shutdown_event) { |
407 // Check whether we're already initialized. | 394 // Check whether we're already initialized. |
408 if (channel_.get()) | 395 if (channel_.get()) |
409 return true; | 396 return true; |
410 | 397 |
411 // Map renderer ID to a (single) channel to that process. | 398 // Map renderer ID to a (single) channel to that process. |
412 std::string channel_name = GetChannelName(); | 399 std::string channel_name = GetChannelName(); |
413 channel_.reset(new IPC::SyncChannel( | 400 channel_.reset(new IPC::SyncChannel( |
414 channel_name, | 401 channel_name, |
(...skipping 12 matching lines...) Expand all Loading... |
427 | 414 |
428 #if defined(OS_POSIX) | 415 #if defined(OS_POSIX) |
429 int GpuChannel::GetRendererFileDescriptor() { | 416 int GpuChannel::GetRendererFileDescriptor() { |
430 int fd = -1; | 417 int fd = -1; |
431 if (channel_.get()) { | 418 if (channel_.get()) { |
432 fd = channel_->GetClientFileDescriptor(); | 419 fd = channel_->GetClientFileDescriptor(); |
433 } | 420 } |
434 return fd; | 421 return fd; |
435 } | 422 } |
436 #endif // defined(OS_POSIX) | 423 #endif // defined(OS_POSIX) |
OLD | NEW |