Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/renderer_gpu_video_decoder_factories.h" | |
| 6 | |
| 7 #include "content/common/child_thread.h" | |
| 8 #include "content/renderer/gpu/command_buffer_proxy.h" | |
| 9 #include "content/renderer/gpu/gpu_channel_host.h" | |
| 10 #include "content/renderer/gpu/renderer_gl_context.h" | |
| 11 #include "gpu/command_buffer/client/gles2_implementation.h" | |
| 12 | |
| 13 RendererGpuVideoDecoderFactories::~RendererGpuVideoDecoderFactories() {} | |
| 14 RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories( | |
| 15 GpuChannelHost* gpu_channel_host, base::WeakPtr<RendererGLContext> context) | |
| 16 : gpu_channel_host_(gpu_channel_host), context_(context) { | |
|
piman
2011/12/13 02:17:24
nit: one initializer per line.
Ami GONE FROM CHROMIUM
2011/12/13 02:21:01
Done.
| |
| 17 } | |
| 18 | |
| 19 media::VideoDecodeAccelerator* | |
| 20 RendererGpuVideoDecoderFactories::CreateVideoDecodeAccelerator( | |
| 21 media::VideoDecodeAccelerator::Profile profile, | |
| 22 media::VideoDecodeAccelerator::Client* client) { | |
| 23 if (!context_) | |
| 24 return NULL; | |
| 25 return gpu_channel_host_->CreateVideoDecoder( | |
| 26 context_->GetCommandBufferProxy()->route_id(), profile, client); | |
| 27 } | |
| 28 | |
| 29 bool RendererGpuVideoDecoderFactories::CreateTextures( | |
| 30 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids) { | |
| 31 if (!context_) | |
| 32 return false; | |
| 33 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); | |
| 34 texture_ids->resize(count); | |
| 35 gles2->GenTextures(count, &texture_ids->at(0)); | |
| 36 for (int i = 0; i < count; ++i) { | |
| 37 gles2->ActiveTexture(GL_TEXTURE0); | |
| 38 uint32 texture_id = texture_ids->at(i); | |
| 39 gles2->BindTexture(GL_TEXTURE_2D, texture_id); | |
| 40 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 41 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 42 gles2->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 43 gles2->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 44 gles2->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), | |
| 45 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | |
| 46 } | |
| 47 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 48 return true; | |
| 49 } | |
| 50 | |
| 51 bool RendererGpuVideoDecoderFactories::DeleteTexture(uint32 texture_id) { | |
| 52 if (!context_) | |
| 53 return false; | |
| 54 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); | |
| 55 gles2->DeleteTextures(1, &texture_id); | |
| 56 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 57 return true; | |
| 58 } | |
| 59 | |
| 60 base::SharedMemory* RendererGpuVideoDecoderFactories::CreateSharedMemory( | |
| 61 size_t size) { | |
| 62 return ChildThread::current()->AllocateSharedMemory(size); | |
| 63 } | |
| OLD | NEW |