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" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 }; | 155 }; |
156 | 156 |
157 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 157 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
158 int32_t host_route_id, | 158 int32_t host_route_id, |
159 gpu::GpuCommandBufferStub* stub, | 159 gpu::GpuCommandBufferStub* stub, |
160 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 160 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
161 const AndroidOverlayMojoFactoryCB& overlay_factory_cb) | 161 const AndroidOverlayMojoFactoryCB& overlay_factory_cb) |
162 : host_route_id_(host_route_id), | 162 : host_route_id_(host_route_id), |
163 stub_(stub), | 163 stub_(stub), |
164 texture_target_(0), | 164 texture_target_(0), |
| 165 pixel_format_(PIXEL_FORMAT_UNKNOWN), |
165 textures_per_buffer_(0), | 166 textures_per_buffer_(0), |
166 filter_removed_(base::WaitableEvent::ResetPolicy::MANUAL, | 167 filter_removed_(base::WaitableEvent::ResetPolicy::MANUAL, |
167 base::WaitableEvent::InitialState::NOT_SIGNALED), | 168 base::WaitableEvent::InitialState::NOT_SIGNALED), |
168 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 169 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
169 io_task_runner_(io_task_runner), | 170 io_task_runner_(io_task_runner), |
170 overlay_factory_cb_(overlay_factory_cb), | 171 overlay_factory_cb_(overlay_factory_cb), |
171 weak_factory_for_io_(this) { | 172 weak_factory_for_io_(this) { |
172 DCHECK(stub_); | 173 DCHECK(stub_); |
173 stub_->AddDestructionObserver(this); | 174 stub_->AddDestructionObserver(this); |
174 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); | 175 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 if (!Send(new AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers( | 239 if (!Send(new AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers( |
239 host_route_id_, requested_num_of_buffers, format, textures_per_buffer, | 240 host_route_id_, requested_num_of_buffers, format, textures_per_buffer, |
240 dimensions, texture_target))) { | 241 dimensions, texture_target))) { |
241 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers) " | 242 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers) " |
242 << "failed"; | 243 << "failed"; |
243 } | 244 } |
244 texture_dimensions_ = dimensions; | 245 texture_dimensions_ = dimensions; |
245 textures_per_buffer_ = textures_per_buffer; | 246 textures_per_buffer_ = textures_per_buffer; |
246 texture_target_ = texture_target; | 247 texture_target_ = texture_target; |
| 248 pixel_format_ = format; |
247 } | 249 } |
248 | 250 |
249 void GpuVideoDecodeAccelerator::DismissPictureBuffer( | 251 void GpuVideoDecodeAccelerator::DismissPictureBuffer( |
250 int32_t picture_buffer_id) { | 252 int32_t picture_buffer_id) { |
251 // Notify client that picture buffer is now unused. | 253 // Notify client that picture buffer is now unused. |
252 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( | 254 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( |
253 host_route_id_, picture_buffer_id))) { | 255 host_route_id_, picture_buffer_id))) { |
254 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " | 256 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " |
255 << "failed"; | 257 << "failed"; |
256 } | 258 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format, | 476 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format, |
475 width, height, 1, 0, format, | 477 width, height, 1, 0, format, |
476 GL_UNSIGNED_BYTE, gfx::Rect()); | 478 GL_UNSIGNED_BYTE, gfx::Rect()); |
477 } | 479 } |
478 } | 480 } |
479 service_ids.push_back(texture_ref->service_id()); | 481 service_ids.push_back(texture_ref->service_id()); |
480 current_textures.push_back(texture_ref); | 482 current_textures.push_back(texture_ref); |
481 } | 483 } |
482 textures.push_back(current_textures); | 484 textures.push_back(current_textures); |
483 buffers.push_back(PictureBuffer(buffer_ids[i], texture_dimensions_, | 485 buffers.push_back(PictureBuffer(buffer_ids[i], texture_dimensions_, |
484 buffer_texture_ids, service_ids)); | 486 buffer_texture_ids, service_ids, |
| 487 texture_target_, pixel_format_)); |
485 } | 488 } |
486 { | 489 { |
487 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); | 490 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); |
488 for (uint32_t i = 0; i < buffer_ids.size(); ++i) | 491 for (uint32_t i = 0; i < buffer_ids.size(); ++i) |
489 uncleared_textures_[buffer_ids[i]] = textures[i]; | 492 uncleared_textures_[buffer_ids[i]] = textures[i]; |
490 } | 493 } |
491 video_decode_accelerator_->AssignPictureBuffers(buffers); | 494 video_decode_accelerator_->AssignPictureBuffers(buffers); |
492 } | 495 } |
493 | 496 |
494 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( | 497 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 for (auto texture_ref : it->second) { | 538 for (auto texture_ref : it->second) { |
536 GLenum target = texture_ref->texture()->target(); | 539 GLenum target = texture_ref->texture()->target(); |
537 gpu::gles2::TextureManager* texture_manager = | 540 gpu::gles2::TextureManager* texture_manager = |
538 stub_->decoder()->GetContextGroup()->texture_manager(); | 541 stub_->decoder()->GetContextGroup()->texture_manager(); |
539 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 542 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
540 } | 543 } |
541 uncleared_textures_.erase(it); | 544 uncleared_textures_.erase(it); |
542 } | 545 } |
543 | 546 |
544 } // namespace media | 547 } // namespace media |
OLD | NEW |