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

Side by Side Diff: content/common/gpu/media/vaapi_video_decode_accelerator.cc

Issue 198073003: Remove some content_child dependency from content_common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ffd442cb fix for bots barfing on clang style checks Created 6 years, 9 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
« no previous file with comments | « content/common/gpu/gpu_channel_manager.cc ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/debug/trace_event.h" 6 #include "base/debug/trace_event.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "content/child/child_thread.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "content/common/gpu/gpu_channel.h" 13 #include "content/common/gpu/gpu_channel.h"
14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
15 #include "media/base/bind_to_current_loop.h" 15 #include "media/base/bind_to_current_loop.h"
16 #include "media/video/picture.h" 16 #include "media/video/picture.h"
17 #include "ui/gl/gl_bindings.h" 17 #include "ui/gl/gl_bindings.h"
18 #include "ui/gl/scoped_binders.h" 18 #include "ui/gl/scoped_binders.h"
19 19
20 static void ReportToUMA( 20 static void ReportToUMA(
21 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { 21 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) {
22 UMA_HISTOGRAM_ENUMERATION( 22 UMA_HISTOGRAM_ENUMERATION(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 } 62 }
63 63
64 // TFPPicture allocates X Pixmaps and binds them to textures passed 64 // TFPPicture allocates X Pixmaps and binds them to textures passed
65 // in PictureBuffers from clients to them. TFPPictures are created as 65 // in PictureBuffers from clients to them. TFPPictures are created as
66 // a consequence of receiving a set of PictureBuffers from clients and released 66 // a consequence of receiving a set of PictureBuffers from clients and released
67 // at the end of decode (or when a new set of PictureBuffers is required). 67 // at the end of decode (or when a new set of PictureBuffers is required).
68 // 68 //
69 // TFPPictures are used for output, contents of VASurfaces passed from decoder 69 // TFPPictures are used for output, contents of VASurfaces passed from decoder
70 // are put into the associated pixmap memory and sent to client. 70 // are put into the associated pixmap memory and sent to client.
71 class VaapiVideoDecodeAccelerator::TFPPicture { 71 class VaapiVideoDecodeAccelerator::TFPPicture : public base::NonThreadSafe {
72 public: 72 public:
73 ~TFPPicture(); 73 ~TFPPicture();
74 74
75 static linked_ptr<TFPPicture> Create( 75 static linked_ptr<TFPPicture> Create(
76 const base::Callback<bool(void)>& make_context_current, 76 const base::Callback<bool(void)>& make_context_current,
77 const GLXFBConfig& fb_config, 77 const GLXFBConfig& fb_config,
78 Display* x_display, 78 Display* x_display,
79 int32 picture_buffer_id, 79 int32 picture_buffer_id,
80 uint32 texture_id, 80 uint32 texture_id,
81 gfx::Size size); 81 gfx::Size size);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 texture_id, size)); 151 texture_id, size));
152 152
153 if (!tfp_picture->Initialize(fb_config)) 153 if (!tfp_picture->Initialize(fb_config))
154 tfp_picture.reset(); 154 tfp_picture.reset();
155 155
156 return tfp_picture; 156 return tfp_picture;
157 } 157 }
158 158
159 bool VaapiVideoDecodeAccelerator::TFPPicture::Initialize( 159 bool VaapiVideoDecodeAccelerator::TFPPicture::Initialize(
160 const GLXFBConfig& fb_config) { 160 const GLXFBConfig& fb_config) {
161 // Check for NULL prevents unittests from crashing on nonexistent ChildThread. 161 DCHECK(CalledOnValidThread());
162 DCHECK(ChildThread::current() == NULL ||
163 ChildThread::current()->message_loop() == base::MessageLoop::current());
164
165 if (!make_context_current_.Run()) 162 if (!make_context_current_.Run())
166 return false; 163 return false;
167 164
168 XWindowAttributes win_attr; 165 XWindowAttributes win_attr;
169 int screen = DefaultScreen(x_display_); 166 int screen = DefaultScreen(x_display_);
170 XGetWindowAttributes(x_display_, RootWindow(x_display_, screen), &win_attr); 167 XGetWindowAttributes(x_display_, RootWindow(x_display_, screen), &win_attr);
171 //TODO(posciak): pass the depth required by libva, not the RootWindow's depth 168 //TODO(posciak): pass the depth required by libva, not the RootWindow's depth
172 x_pixmap_ = XCreatePixmap(x_display_, RootWindow(x_display_, screen), 169 x_pixmap_ = XCreatePixmap(x_display_, RootWindow(x_display_, screen),
173 size_.width(), size_.height(), win_attr.depth); 170 size_.width(), size_.height(), win_attr.depth);
174 if (!x_pixmap_) { 171 if (!x_pixmap_) {
(...skipping 11 matching lines...) Expand all
186 if (!glx_pixmap_) { 183 if (!glx_pixmap_) {
187 // x_pixmap_ will be freed in the destructor. 184 // x_pixmap_ will be freed in the destructor.
188 DVLOG(1) << "Failed creating a GLX Pixmap for TFP"; 185 DVLOG(1) << "Failed creating a GLX Pixmap for TFP";
189 return false; 186 return false;
190 } 187 }
191 188
192 return true; 189 return true;
193 } 190 }
194 191
195 VaapiVideoDecodeAccelerator::TFPPicture::~TFPPicture() { 192 VaapiVideoDecodeAccelerator::TFPPicture::~TFPPicture() {
196 // Check for NULL prevents unittests from crashing on nonexistent ChildThread. 193 DCHECK(CalledOnValidThread());
197 DCHECK(ChildThread::current() == NULL ||
198 ChildThread::current()->message_loop() == base::MessageLoop::current());
199
200 // Unbind surface from texture and deallocate resources. 194 // Unbind surface from texture and deallocate resources.
201 if (glx_pixmap_ && make_context_current_.Run()) { 195 if (glx_pixmap_ && make_context_current_.Run()) {
202 glXReleaseTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT); 196 glXReleaseTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT);
203 glXDestroyPixmap(x_display_, glx_pixmap_); 197 glXDestroyPixmap(x_display_, glx_pixmap_);
204 } 198 }
205 199
206 if (x_pixmap_) 200 if (x_pixmap_)
207 XFreePixmap(x_display_, x_pixmap_); 201 XFreePixmap(x_display_, x_pixmap_);
208 XSync(x_display_, False); // Needed to work around buggy vdpau-driver. 202 XSync(x_display_, False); // Needed to work around buggy vdpau-driver.
209 } 203 }
210 204
211 bool VaapiVideoDecodeAccelerator::TFPPicture::Bind() { 205 bool VaapiVideoDecodeAccelerator::TFPPicture::Bind() {
206 DCHECK(CalledOnValidThread());
212 DCHECK(x_pixmap_); 207 DCHECK(x_pixmap_);
213 DCHECK(glx_pixmap_); 208 DCHECK(glx_pixmap_);
214 // Check for NULL prevents unittests from crashing on nonexistent ChildThread.
215 DCHECK(ChildThread::current() == NULL ||
216 ChildThread::current()->message_loop() == base::MessageLoop::current());
217
218 if (!make_context_current_.Run()) 209 if (!make_context_current_.Run())
219 return false; 210 return false;
220 211
221 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_); 212 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_);
222 glXBindTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); 213 glXBindTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL);
223 214
224 return true; 215 return true;
225 } 216 }
226 217
227 VaapiVideoDecodeAccelerator::TFPPicture* 218 VaapiVideoDecodeAccelerator::TFPPicture*
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 state_ = kUninitialized; 911 state_ = kUninitialized;
921 } 912 }
922 913
923 void VaapiVideoDecodeAccelerator::Destroy() { 914 void VaapiVideoDecodeAccelerator::Destroy() {
924 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 915 DCHECK_EQ(message_loop_, base::MessageLoop::current());
925 Cleanup(); 916 Cleanup();
926 delete this; 917 delete this;
927 } 918 }
928 919
929 } // namespace content 920 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.cc ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698