Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: content/renderer/media/renderer_gpu_video_decoder_factories.cc

Issue 10392141: Plumb texture target to VideoDecodeAccelerator::Client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/renderer/media/renderer_gpu_video_decoder_factories.h" 5 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/gpu/client/gpu_channel_host.h" 10 #include "content/common/gpu/client/gpu_channel_host.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 profile, client); 68 profile, client);
69 } else { 69 } else {
70 *vda = NULL; 70 *vda = NULL;
71 } 71 }
72 waiter->Signal(); 72 waiter->Signal();
73 } 73 }
74 74
75 bool RendererGpuVideoDecoderFactories::CreateTextures( 75 bool RendererGpuVideoDecoderFactories::CreateTextures(
76 int32 count, const gfx::Size& size, 76 int32 count, const gfx::Size& size,
77 std::vector<uint32>* texture_ids, 77 std::vector<uint32>* texture_ids,
78 uint32* texture_target) { 78 uint32 texture_target) {
79 DCHECK_NE(MessageLoop::current(), message_loop_); 79 DCHECK_NE(MessageLoop::current(), message_loop_);
80 bool success = false; 80 bool success = false;
81 base::WaitableEvent waiter(false, false); 81 base::WaitableEvent waiter(false, false);
82 message_loop_->PostTask(FROM_HERE, base::Bind( 82 message_loop_->PostTask(FROM_HERE, base::Bind(
83 &RendererGpuVideoDecoderFactories::AsyncCreateTextures, this, 83 &RendererGpuVideoDecoderFactories::AsyncCreateTextures, this,
84 count, size, texture_ids, texture_target, &success, &waiter)); 84 count, size, texture_ids, texture_target, &success, &waiter));
85 waiter.Wait(); 85 waiter.Wait();
86 return success; 86 return success;
87 } 87 }
88 88
89 void RendererGpuVideoDecoderFactories::AsyncCreateTextures( 89 void RendererGpuVideoDecoderFactories::AsyncCreateTextures(
90 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids, 90 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids,
91 uint32* texture_target, bool* success, base::WaitableEvent* waiter) { 91 uint32 texture_target, bool* success, base::WaitableEvent* waiter) {
92 DCHECK_EQ(MessageLoop::current(), message_loop_); 92 DCHECK_EQ(MessageLoop::current(), message_loop_);
93 DCHECK(texture_target);
93 if (!context_) { 94 if (!context_) {
94 *success = false; 95 *success = false;
95 waiter->Signal(); 96 waiter->Signal();
96 return; 97 return;
97 } 98 }
98 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); 99 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
99 texture_ids->resize(count); 100 texture_ids->resize(count);
100 gles2->GenTextures(count, &texture_ids->at(0)); 101 gles2->GenTextures(count, &texture_ids->at(0));
101 *texture_target = GL_TEXTURE_2D;
102 for (int i = 0; i < count; ++i) { 102 for (int i = 0; i < count; ++i) {
103 gles2->ActiveTexture(GL_TEXTURE0); 103 gles2->ActiveTexture(GL_TEXTURE0);
104 uint32 texture_id = texture_ids->at(i); 104 uint32 texture_id = texture_ids->at(i);
105 gles2->BindTexture(*texture_target, texture_id); 105 gles2->BindTexture(texture_target, texture_id);
106 gles2->TexParameteri(*texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 106 gles2->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
107 gles2->TexParameteri(*texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 107 gles2->TexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
108 gles2->TexParameterf(*texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 108 gles2->TexParameterf(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
109 gles2->TexParameterf(*texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 109 gles2->TexParameterf(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
110 gles2->TexImage2D(*texture_target, 0, GL_RGBA, size.width(), size.height(), 110 gles2->TexImage2D(texture_target, 0, GL_RGBA, size.width(), size.height(),
111 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 111 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
112 } 112 }
113 // We need a glFlush here to guarantee the decoder (in the GPU process) can 113 // We need a glFlush here to guarantee the decoder (in the GPU process) can
114 // use the texture ids we return here. Since textures are expected to be 114 // use the texture ids we return here. Since textures are expected to be
115 // reused, this should not be unacceptably expensive. 115 // reused, this should not be unacceptably expensive.
116 gles2->Flush(); 116 gles2->Flush();
117 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); 117 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
118 *success = true; 118 *success = true;
119 waiter->Signal(); 119 waiter->Signal();
120 } 120 }
(...skipping 24 matching lines...) Expand all
145 waiter.Wait(); 145 waiter.Wait();
146 return shm; 146 return shm;
147 } 147 }
148 148
149 void RendererGpuVideoDecoderFactories::AsyncCreateSharedMemory( 149 void RendererGpuVideoDecoderFactories::AsyncCreateSharedMemory(
150 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter) { 150 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter) {
151 DCHECK_EQ(MessageLoop::current(), ChildThread::current()->message_loop()); 151 DCHECK_EQ(MessageLoop::current(), ChildThread::current()->message_loop());
152 *shm = ChildThread::current()->AllocateSharedMemory(size); 152 *shm = ChildThread::current()->AllocateSharedMemory(size);
153 waiter->Signal(); 153 waiter->Signal();
154 } 154 }
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_gpu_video_decoder_factories.h ('k') | media/filters/gpu_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698