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 #include "content/common/gpu/media/gpu_video_service.h" | 5 #include "content/common/gpu/media/gpu_video_service.h" |
6 | 6 |
7 #include "content/common/gpu/gpu_channel.h" | 7 #include "content/common/gpu/gpu_channel.h" |
8 #include "content/common/gpu/gpu_messages.h" | 8 #include "content/common/gpu/gpu_messages.h" |
9 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 9 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Create GpuVideoDecodeAccelerator and add to map. | 64 // Create GpuVideoDecodeAccelerator and add to map. |
65 scoped_refptr<GpuVideoDecodeAccelerator> decoder = | 65 scoped_refptr<GpuVideoDecodeAccelerator> decoder = |
66 new GpuVideoDecodeAccelerator(channel, decoder_host_id); | 66 new GpuVideoDecodeAccelerator(channel, decoder_host_id); |
67 | 67 |
68 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 68 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
69 OmxVideoDecodeAccelerator* omx_decoder = | 69 OmxVideoDecodeAccelerator* omx_decoder = |
70 new OmxVideoDecodeAccelerator(decoder, MessageLoop::current()); | 70 new OmxVideoDecodeAccelerator(decoder, MessageLoop::current()); |
71 omx_decoder->SetEglState(gfx::GLSurfaceEGL::GetDisplay(), | 71 omx_decoder->SetEglState(gfx::GLSurfaceEGL::GetDisplay(), |
72 command_decoder->GetGLContext()->GetHandle()); | 72 command_decoder->GetGLContext()->GetHandle()); |
73 decoder->set_video_decode_accelerator(omx_decoder); | 73 decoder->set_video_decode_accelerator(omx_decoder); |
74 | |
75 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 74 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
76 | 75 |
77 bool result = decoder_map_.insert(std::make_pair( | 76 bool result = decoder_map_.insert(std::make_pair( |
78 decoder_id, VideoDecoderInfo(decoder, command_decoder))).second; | 77 decoder_id, VideoDecoderInfo(decoder, command_decoder))).second; |
79 | 78 |
80 // Decoder ID is a unique ID determined by GpuVideoServiceHost. | 79 // Decoder ID is a unique ID determined by GpuVideoServiceHost. |
81 // We should always be adding entries here. | 80 // We should always be adding entries here. |
82 DCHECK(result); | 81 DCHECK(result); |
83 | 82 |
84 router->AddRoute(decoder_id, decoder); | 83 router->AddRoute(decoder_id, decoder); |
(...skipping 11 matching lines...) Expand all Loading... |
96 int32 decoder_id) { | 95 int32 decoder_id) { |
97 router->RemoveRoute(decoder_id); | 96 router->RemoveRoute(decoder_id); |
98 decoder_map_.erase(decoder_id); | 97 decoder_map_.erase(decoder_id); |
99 } | 98 } |
100 | 99 |
101 void GpuVideoService::AssignTexturesToDecoder( | 100 void GpuVideoService::AssignTexturesToDecoder( |
102 int32 decoder_id, | 101 int32 decoder_id, |
103 const std::vector<int32>& buffer_ids, | 102 const std::vector<int32>& buffer_ids, |
104 const std::vector<uint32>& texture_ids, | 103 const std::vector<uint32>& texture_ids, |
105 const std::vector<gfx::Size>& sizes) { | 104 const std::vector<gfx::Size>& sizes) { |
| 105 DecoderMap::iterator it = decoder_map_.find(decoder_id); |
| 106 DCHECK(it != decoder_map_.end()); |
| 107 DCHECK_EQ(it->first, decoder_id); |
| 108 GpuVideoDecodeAccelerator* video_decoder = it->second.video_decoder; |
| 109 gpu::gles2::GLES2Decoder* command_decoder = it->second.command_decoder; |
| 110 |
106 std::vector<media::GLESBuffer> buffers; | 111 std::vector<media::GLESBuffer> buffers; |
107 for (uint32 i = 0; i < buffer_ids.size(); ++i) { | 112 for (uint32 i = 0; i < buffer_ids.size(); ++i) { |
108 uint32 service_texture_id; | 113 uint32 service_texture_id; |
109 bool result = TranslateTextureForDecoder( | 114 if (!command_decoder->GetServiceTextureId( |
110 decoder_id, texture_ids[i], &service_texture_id); | 115 texture_ids[i], &service_texture_id)) { |
111 // TODO(vrk): Send an error for invalid GLES buffers. | 116 // TODO(vrk): Send an error for invalid GLES buffers. |
112 if (!result) | 117 LOG(DFATAL) << "Failed to translate texture!"; |
113 return; | 118 return; |
114 buffers.push_back( | 119 } |
115 media::GLESBuffer(buffer_ids[i], sizes[i], service_texture_id)); | 120 buffers.push_back(media::GLESBuffer( |
| 121 buffer_ids[i], sizes[i], service_texture_id)); |
116 } | 122 } |
117 | 123 video_decoder->AssignGLESBuffers(buffers); |
118 DecoderMap::iterator it = decoder_map_.find(decoder_id); | |
119 DCHECK(it != decoder_map_.end()); | |
120 it->second.video_decoder->AssignGLESBuffers(buffers); | |
121 } | 124 } |
122 | |
123 bool GpuVideoService::TranslateTextureForDecoder( | |
124 int32 decoder_id, uint32 client_texture_id, uint32* service_texture_id) { | |
125 DecoderMap::iterator it = decoder_map_.find(decoder_id); | |
126 if (it == decoder_map_.end()) | |
127 return false; | |
128 it->second.command_decoder->MakeCurrent(); | |
129 return it->second.command_decoder->GetServiceTextureId( | |
130 client_texture_id, service_texture_id); | |
131 } | |
OLD | NEW |