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

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

Issue 16256018: Update content/ to use WeakPtr<T>::get() instead of implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix incorrectly modified code Created 7 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 <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // thread, and only as the result of a PostTask from the render thread 42 // thread, and only as the result of a PostTask from the render thread
43 // which can only happen after this function returns, so our PostTask will 43 // which can only happen after this function returns, so our PostTask will
44 // run first. 44 // run first.
45 context)); 45 context));
46 compositor_loop_async_waiter_.Wait(); 46 compositor_loop_async_waiter_.Wait();
47 } 47 }
48 48
49 void RendererGpuVideoDecoderFactories::AsyncGetContext( 49 void RendererGpuVideoDecoderFactories::AsyncGetContext(
50 WebGraphicsContext3DCommandBufferImpl* context) { 50 WebGraphicsContext3DCommandBufferImpl* context) {
51 context_ = context->AsWeakPtr(); 51 context_ = context->AsWeakPtr();
52 if (context_) { 52 if (context_.get()) {
53 if (context_->makeContextCurrent()) { 53 if (context_->makeContextCurrent()) {
54 // Called once per media player, but is a no-op after the first one in 54 // Called once per media player, but is a no-op after the first one in
55 // each renderer. 55 // each renderer.
56 context_->insertEventMarkerEXT("GpuVDAContext3D"); 56 context_->insertEventMarkerEXT("GpuVDAContext3D");
57 } 57 }
58 } 58 }
59 compositor_loop_async_waiter_.Signal(); 59 compositor_loop_async_waiter_.Signal();
60 } 60 }
61 61
62 media::VideoDecodeAccelerator* 62 media::VideoDecodeAccelerator*
(...skipping 19 matching lines...) Expand all
82 return NULL; 82 return NULL;
83 } 83 }
84 return vda_.release(); 84 return vda_.release();
85 } 85 }
86 86
87 void RendererGpuVideoDecoderFactories::AsyncCreateVideoDecodeAccelerator( 87 void RendererGpuVideoDecoderFactories::AsyncCreateVideoDecodeAccelerator(
88 media::VideoCodecProfile profile, 88 media::VideoCodecProfile profile,
89 media::VideoDecodeAccelerator::Client* client) { 89 media::VideoDecodeAccelerator::Client* client) {
90 DCHECK(message_loop_->BelongsToCurrentThread()); 90 DCHECK(message_loop_->BelongsToCurrentThread());
91 91
92 if (context_ && context_->GetCommandBufferProxy()) { 92 if (context_.get() && context_->GetCommandBufferProxy()) {
93 vda_ = gpu_channel_host_->CreateVideoDecoder( 93 vda_ = gpu_channel_host_->CreateVideoDecoder(
94 context_->GetCommandBufferProxy()->GetRouteID(), 94 context_->GetCommandBufferProxy()->GetRouteID(), profile, client);
95 profile, client);
96 } 95 }
97 compositor_loop_async_waiter_.Signal(); 96 compositor_loop_async_waiter_.Signal();
98 } 97 }
99 98
100 bool RendererGpuVideoDecoderFactories::CreateTextures( 99 bool RendererGpuVideoDecoderFactories::CreateTextures(
101 int32 count, const gfx::Size& size, 100 int32 count, const gfx::Size& size,
102 std::vector<uint32>* texture_ids, 101 std::vector<uint32>* texture_ids,
103 uint32 texture_target) { 102 uint32 texture_target) {
104 DCHECK(!message_loop_->BelongsToCurrentThread()); 103 DCHECK(!message_loop_->BelongsToCurrentThread());
105 message_loop_->PostTask(FROM_HERE, base::Bind( 104 message_loop_->PostTask(FROM_HERE, base::Bind(
106 &RendererGpuVideoDecoderFactories::AsyncCreateTextures, this, 105 &RendererGpuVideoDecoderFactories::AsyncCreateTextures, this,
107 count, size, texture_target)); 106 count, size, texture_target));
108 107
109 base::WaitableEvent* objects[] = {&aborted_waiter_, 108 base::WaitableEvent* objects[] = {&aborted_waiter_,
110 &compositor_loop_async_waiter_}; 109 &compositor_loop_async_waiter_};
111 if (base::WaitableEvent::WaitMany(objects, arraysize(objects)) == 0) 110 if (base::WaitableEvent::WaitMany(objects, arraysize(objects)) == 0)
112 return false; 111 return false;
113 texture_ids->swap(created_textures_); 112 texture_ids->swap(created_textures_);
114 return true; 113 return true;
115 } 114 }
116 115
117 void RendererGpuVideoDecoderFactories::AsyncCreateTextures( 116 void RendererGpuVideoDecoderFactories::AsyncCreateTextures(
118 int32 count, const gfx::Size& size, uint32 texture_target) { 117 int32 count, const gfx::Size& size, uint32 texture_target) {
119 DCHECK(message_loop_->BelongsToCurrentThread()); 118 DCHECK(message_loop_->BelongsToCurrentThread());
120 DCHECK(texture_target); 119 DCHECK(texture_target);
121 120
122 if (!context_) { 121 if (!context_.get()) {
123 compositor_loop_async_waiter_.Signal(); 122 compositor_loop_async_waiter_.Signal();
124 return; 123 return;
125 } 124 }
126 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); 125 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
127 created_textures_.resize(count); 126 created_textures_.resize(count);
128 gles2->GenTextures(count, &created_textures_[0]); 127 gles2->GenTextures(count, &created_textures_[0]);
129 for (int i = 0; i < count; ++i) { 128 for (int i = 0; i < count; ++i) {
130 gles2->ActiveTexture(GL_TEXTURE0); 129 gles2->ActiveTexture(GL_TEXTURE0);
131 uint32 texture_id = created_textures_[i]; 130 uint32 texture_id = created_textures_[i];
132 gles2->BindTexture(texture_target, texture_id); 131 gles2->BindTexture(texture_target, texture_id);
(...skipping 15 matching lines...) Expand all
148 } 147 }
149 148
150 void RendererGpuVideoDecoderFactories::DeleteTexture(uint32 texture_id) { 149 void RendererGpuVideoDecoderFactories::DeleteTexture(uint32 texture_id) {
151 DCHECK(!message_loop_->BelongsToCurrentThread()); 150 DCHECK(!message_loop_->BelongsToCurrentThread());
152 message_loop_->PostTask(FROM_HERE, base::Bind( 151 message_loop_->PostTask(FROM_HERE, base::Bind(
153 &RendererGpuVideoDecoderFactories::AsyncDeleteTexture, this, texture_id)); 152 &RendererGpuVideoDecoderFactories::AsyncDeleteTexture, this, texture_id));
154 } 153 }
155 154
156 void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) { 155 void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) {
157 DCHECK(message_loop_->BelongsToCurrentThread()); 156 DCHECK(message_loop_->BelongsToCurrentThread());
158 if (!context_) 157 if (!context_.get())
159 return; 158 return;
160 159
161 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); 160 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
162 gles2->DeleteTextures(1, &texture_id); 161 gles2->DeleteTextures(1, &texture_id);
163 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); 162 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
164 } 163 }
165 164
166 void RendererGpuVideoDecoderFactories::ReadPixels( 165 void RendererGpuVideoDecoderFactories::ReadPixels(
167 uint32 texture_id, uint32 texture_target, const gfx::Size& size, 166 uint32 texture_id, uint32 texture_target, const gfx::Size& size,
168 const SkBitmap& pixels) { 167 const SkBitmap& pixels) {
(...skipping 13 matching lines...) Expand all
182 return; 181 return;
183 } else { 182 } else {
184 AsyncReadPixels(texture_id, texture_target, size); 183 AsyncReadPixels(texture_id, texture_target, size);
185 } 184 }
186 read_pixels_bitmap_.setPixelRef(NULL); 185 read_pixels_bitmap_.setPixelRef(NULL);
187 } 186 }
188 187
189 void RendererGpuVideoDecoderFactories::AsyncReadPixels( 188 void RendererGpuVideoDecoderFactories::AsyncReadPixels(
190 uint32 texture_id, uint32 texture_target, const gfx::Size& size) { 189 uint32 texture_id, uint32 texture_target, const gfx::Size& size) {
191 DCHECK(message_loop_->BelongsToCurrentThread()); 190 DCHECK(message_loop_->BelongsToCurrentThread());
192 if (!context_) { 191 if (!context_.get()) {
193 compositor_loop_async_waiter_.Signal(); 192 compositor_loop_async_waiter_.Signal();
194 return; 193 return;
195 } 194 }
196 195
197 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); 196 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
198 197
199 GLuint tmp_texture; 198 GLuint tmp_texture;
200 gles2->GenTextures(1, &tmp_texture); 199 gles2->GenTextures(1, &tmp_texture);
201 gles2->BindTexture(texture_target, tmp_texture); 200 gles2->BindTexture(texture_target, tmp_texture);
202 gles2->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 201 gles2->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return aborted_waiter_.IsSignaled(); 256 return aborted_waiter_.IsSignaled();
258 } 257 }
259 258
260 void RendererGpuVideoDecoderFactories::AsyncDestroyVideoDecodeAccelerator() { 259 void RendererGpuVideoDecoderFactories::AsyncDestroyVideoDecodeAccelerator() {
261 // OK to release because Destroy() will delete the VDA instance. 260 // OK to release because Destroy() will delete the VDA instance.
262 if (vda_) 261 if (vda_)
263 vda_.release()->Destroy(); 262 vda_.release()->Destroy();
264 } 263 }
265 264
266 } // namespace content 265 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dispatcher.cc ('k') | content/renderer/pepper/pepper_broker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698