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

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

Issue 43283002: Enable GLX/EGL backend switching while run HW video decode with libva. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Refined based on Fischman's comments. Created 7 years, 1 month 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
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"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
82 82
83 static linked_ptr<TFPPicture> Create(
84 const base::Callback<bool(void)>& make_context_current,
85 const EGLDisplay egl_display,
86 Display* x_display,
87 int32 picture_buffer_id,
88 uint32 texture_id,
89 gfx::Size size);
83 int32 picture_buffer_id() { 90 int32 picture_buffer_id() {
84 return picture_buffer_id_; 91 return picture_buffer_id_;
85 } 92 }
86 93
87 uint32 texture_id() { 94 uint32 texture_id() {
88 return texture_id_; 95 return texture_id_;
89 } 96 }
90 97
91 gfx::Size size() { 98 gfx::Size size() {
92 return size_; 99 return size_;
93 } 100 }
94 101
95 int x_pixmap() { 102 int x_pixmap() {
96 return x_pixmap_; 103 return x_pixmap_;
97 } 104 }
98 105
99 // Bind texture to pixmap. Needs to be called every frame. 106 // Bind texture to pixmap. Needs to be called every frame.
100 bool Bind(); 107 bool Bind();
101 108
102 private: 109 private:
103 TFPPicture(const base::Callback<bool(void)>& make_context_current, 110 TFPPicture(const base::Callback<bool(void)>& make_context_current,
111 GLXFBConfig& fb_config,
112 Display* x_display,
113 int32 picture_buffer_id,
114 uint32 texture_id,
115 gfx::Size size);
116 TFPPicture(const base::Callback<bool(void)>& make_context_current,
117 EGLDisplay egl_display,
104 Display* x_display, 118 Display* x_display,
105 int32 picture_buffer_id, 119 int32 picture_buffer_id,
106 uint32 texture_id, 120 uint32 texture_id,
107 gfx::Size size); 121 gfx::Size size);
108 122
109 bool Initialize(const GLXFBConfig& fb_config); 123 bool Initialize(const GLXFBConfig& fb_config);
124 bool Initialize(const EGLDisplay egl_display);
110 125
111 base::Callback<bool(void)> make_context_current_; 126 base::Callback<bool(void)> make_context_current_;
112 127
113 Display* x_display_; 128 Display* x_display_;
114 129
115 // Output id for the client. 130 // Output id for the client.
116 int32 picture_buffer_id_; 131 int32 picture_buffer_id_;
117 uint32 texture_id_; 132 uint32 texture_id_;
118 133
119 gfx::Size size_; 134 gfx::Size size_;
120 135
121 // Pixmaps bound to this texture. 136 // Pixmaps bound to this texture.
122 Pixmap x_pixmap_; 137 Pixmap x_pixmap_;
138 EGLDisplay egl_display_;
139 EGLImageKHR egl_image_;
123 GLXPixmap glx_pixmap_; 140 GLXPixmap glx_pixmap_;
124 141
125 DISALLOW_COPY_AND_ASSIGN(TFPPicture); 142 DISALLOW_COPY_AND_ASSIGN(TFPPicture);
126 }; 143 };
144 VaapiVideoDecodeAccelerator::TFPPicture::TFPPicture(
145 const base::Callback<bool(void)>& make_context_current,
146 GLXFBConfig& fb_config,
147 Display* x_display,
148 int32 picture_buffer_id,
149 uint32 texture_id,
150 gfx::Size size)
151 : make_context_current_(make_context_current),
152 x_display_(x_display),
153 picture_buffer_id_(picture_buffer_id),
154 texture_id_(texture_id),
155 size_(size),
156 x_pixmap_(0),
157 egl_image_(0),
158 glx_pixmap_(0) {
159 DCHECK(!make_context_current_.is_null());
160 };
127 161
128 VaapiVideoDecodeAccelerator::TFPPicture::TFPPicture( 162 VaapiVideoDecodeAccelerator::TFPPicture::TFPPicture(
129 const base::Callback<bool(void)>& make_context_current, 163 const base::Callback<bool(void)>& make_context_current,
164 EGLDisplay egl_display,
130 Display* x_display, 165 Display* x_display,
131 int32 picture_buffer_id, 166 int32 picture_buffer_id,
132 uint32 texture_id, 167 uint32 texture_id,
133 gfx::Size size) 168 gfx::Size size)
134 : make_context_current_(make_context_current), 169 : make_context_current_(make_context_current),
135 x_display_(x_display), 170 x_display_(x_display),
136 picture_buffer_id_(picture_buffer_id), 171 picture_buffer_id_(picture_buffer_id),
137 texture_id_(texture_id), 172 texture_id_(texture_id),
138 size_(size), 173 size_(size),
139 x_pixmap_(0), 174 x_pixmap_(0),
175 egl_display_(egl_display),
176 egl_image_(0),
140 glx_pixmap_(0) { 177 glx_pixmap_(0) {
141 DCHECK(!make_context_current_.is_null()); 178 DCHECK(!make_context_current_.is_null());
142 }; 179 };
143 180
144 linked_ptr<VaapiVideoDecodeAccelerator::TFPPicture> 181 linked_ptr<VaapiVideoDecodeAccelerator::TFPPicture>
145 VaapiVideoDecodeAccelerator::TFPPicture::Create( 182 VaapiVideoDecodeAccelerator::TFPPicture::Create(
146 const base::Callback<bool(void)>& make_context_current, 183 const base::Callback<bool(void)>& make_context_current,
147 const GLXFBConfig& fb_config, 184 const GLXFBConfig& fb_config,
148 Display* x_display, 185 Display* x_display,
149 int32 picture_buffer_id, 186 int32 picture_buffer_id,
150 uint32 texture_id, 187 uint32 texture_id,
151 gfx::Size size) { 188 gfx::Size size) {
152 189
153 linked_ptr<TFPPicture> tfp_picture( 190 linked_ptr<TFPPicture> tfp_picture(
154 new TFPPicture(make_context_current, x_display, picture_buffer_id, 191 new TFPPicture(make_context_current, fb_config, x_display,
155 texture_id, size)); 192 picture_buffer_id, texture_id, size));
156 193
157 if (!tfp_picture->Initialize(fb_config)) 194 if (!tfp_picture->Initialize(fb_config))
158 tfp_picture.reset(); 195 tfp_picture.reset();
159 196
160 return tfp_picture; 197 return tfp_picture;
161 } 198 }
162 199
200 linked_ptr<VaapiVideoDecodeAccelerator::TFPPicture>
201 VaapiVideoDecodeAccelerator::TFPPicture::Create(
202 const base::Callback<bool(void)>& make_context_current,
203 const EGLDisplay egl_display,
204 Display* x_display,
205 int32 picture_buffer_id,
206 uint32 texture_id,
207 gfx::Size size) {
208
209 linked_ptr<TFPPicture> tfp_picture(
210 new TFPPicture(make_context_current, egl_display, x_display,
211 picture_buffer_id, texture_id, size));
212
213 if (!tfp_picture->Initialize(egl_display))
214 tfp_picture.reset();
215
216 return tfp_picture;
217 }
163 bool VaapiVideoDecodeAccelerator::TFPPicture::Initialize( 218 bool VaapiVideoDecodeAccelerator::TFPPicture::Initialize(
164 const GLXFBConfig& fb_config) { 219 const GLXFBConfig& fb_config) {
165 // Check for NULL prevents unittests from crashing on nonexistent ChildThread. 220 // Check for NULL prevents unittests from crashing on nonexistent ChildThread.
166 DCHECK(ChildThread::current() == NULL || 221 DCHECK(ChildThread::current() == NULL ||
167 ChildThread::current()->message_loop() == base::MessageLoop::current()); 222 ChildThread::current()->message_loop() == base::MessageLoop::current());
168 223
169 if (!make_context_current_.Run()) 224 if (!make_context_current_.Run())
170 return false; 225 return false;
171 226
172 XWindowAttributes win_attr; 227 XWindowAttributes win_attr;
(...skipping 16 matching lines...) Expand all
189 glx_pixmap_ = glXCreatePixmap(x_display_, fb_config, x_pixmap_, pixmap_attr); 244 glx_pixmap_ = glXCreatePixmap(x_display_, fb_config, x_pixmap_, pixmap_attr);
190 if (!glx_pixmap_) { 245 if (!glx_pixmap_) {
191 // x_pixmap_ will be freed in the destructor. 246 // x_pixmap_ will be freed in the destructor.
192 DVLOG(1) << "Failed creating a GLX Pixmap for TFP"; 247 DVLOG(1) << "Failed creating a GLX Pixmap for TFP";
193 return false; 248 return false;
194 } 249 }
195 250
196 return true; 251 return true;
197 } 252 }
198 253
254 bool VaapiVideoDecodeAccelerator::TFPPicture::Initialize(
255 EGLDisplay egl_display) {
256 // Check for NULL prevents unittests from crashing on nonexistent ChildThread.
257 DCHECK(ChildThread::current() == NULL ||
258 ChildThread::current()->message_loop() == base::MessageLoop::current());
259
260 if (!make_context_current_.Run())
261 return false;
262
263 XWindowAttributes win_attr;
264 int screen = DefaultScreen(x_display_);
265 XGetWindowAttributes(x_display_, RootWindow(x_display_, screen), &win_attr);
266 //TODO(posciak): pass the depth required by libva, not the RootWindow's depth
267 x_pixmap_ = XCreatePixmap(x_display_, RootWindow(x_display_, screen),
268 size_.width(), size_.height(), win_attr.depth);
269 if (!x_pixmap_) {
270 DVLOG(1) << "Failed creating an X Pixmap for TFP";
271 return false;
272 }
273
274 egl_display_ = egl_display;
275 EGLint image_attrs[] = { EGL_IMAGE_PRESERVED_KHR, 1 , EGL_NONE };
276
277 egl_image_ = eglCreateImageKHR(egl_display_,
278 EGL_NO_CONTEXT,
279 EGL_NATIVE_PIXMAP_KHR,
280 (EGLClientBuffer)x_pixmap_,
281 image_attrs);
282 if (!egl_image_) {
283 DVLOG(1) << "Failed creating a EGLImage from Pixmap for KHR";
284 return false;
285 }
286
287 return true;
288 }
199 VaapiVideoDecodeAccelerator::TFPPicture::~TFPPicture() { 289 VaapiVideoDecodeAccelerator::TFPPicture::~TFPPicture() {
200 // Check for NULL prevents unittests from crashing on nonexistent ChildThread. 290 // Check for NULL prevents unittests from crashing on nonexistent ChildThread.
201 DCHECK(ChildThread::current() == NULL || 291 DCHECK(ChildThread::current() == NULL ||
202 ChildThread::current()->message_loop() == base::MessageLoop::current()); 292 ChildThread::current()->message_loop() == base::MessageLoop::current());
203 293
204 // Unbind surface from texture and deallocate resources. 294 // Unbind surface from texture and deallocate resources.
205 if (glx_pixmap_ && make_context_current_.Run()) { 295 if (glx_pixmap_ && make_context_current_.Run()) {
206 glXReleaseTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT); 296 glXReleaseTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT);
207 glXDestroyPixmap(x_display_, glx_pixmap_); 297 glXDestroyPixmap(x_display_, glx_pixmap_);
208 } 298 }
209 299
300 if (egl_image_ && make_context_current_.Run()) {
301 eglDestroyImageKHR(egl_display_, egl_image_);
302 }
303
210 if (x_pixmap_) 304 if (x_pixmap_)
211 XFreePixmap(x_display_, x_pixmap_); 305 XFreePixmap(x_display_, x_pixmap_);
212 XSync(x_display_, False); // Needed to work around buggy vdpau-driver. 306 XSync(x_display_, False); // Needed to work around buggy vdpau-driver.
213 } 307 }
214 308
215 bool VaapiVideoDecodeAccelerator::TFPPicture::Bind() { 309 bool VaapiVideoDecodeAccelerator::TFPPicture::Bind() {
216 DCHECK(x_pixmap_); 310 DCHECK(x_pixmap_);
217 DCHECK(glx_pixmap_); 311
218 // Check for NULL prevents unittests from crashing on nonexistent ChildThread. 312 // Check for NULL prevents unittests from crashing on nonexistent ChildThread.
219 DCHECK(ChildThread::current() == NULL || 313 DCHECK(ChildThread::current() == NULL ||
220 ChildThread::current()->message_loop() == base::MessageLoop::current()); 314 ChildThread::current()->message_loop() == base::MessageLoop::current());
221 315
222 if (!make_context_current_.Run()) 316 if (!make_context_current_.Run())
223 return false; 317 return false;
224 318
225 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_); 319 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_);
226 glXBindTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); 320 if(glx_pixmap_) {
227 321 glXBindTexImageEXT(x_display_, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL);
322 } else if(egl_image_) {
323 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
324 } else {
325 return false;
326 }
228 return true; 327 return true;
229 } 328 }
230 329
231 VaapiVideoDecodeAccelerator::TFPPicture* 330 VaapiVideoDecodeAccelerator::TFPPicture*
232 VaapiVideoDecodeAccelerator::TFPPictureById(int32 picture_buffer_id) { 331 VaapiVideoDecodeAccelerator::TFPPictureById(int32 picture_buffer_id) {
233 TFPPictures::iterator it = tfp_pictures_.find(picture_buffer_id); 332 TFPPictures::iterator it = tfp_pictures_.find(picture_buffer_id);
234 if (it == tfp_pictures_.end()) { 333 if (it == tfp_pictures_.end()) {
235 DVLOG(1) << "Picture id " << picture_buffer_id << " does not exist"; 334 DVLOG(1) << "Picture id " << picture_buffer_id << " does not exist";
236 return NULL; 335 return NULL;
237 } 336 }
238 337
239 return it->second.get(); 338 return it->second.get();
240 } 339 }
241 340
242 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( 341 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
243 Display* x_display, GLXContext glx_context, 342 Display* x_display, GLXContext glx_context,
244 Client* client, 343 Client* client,
245 const base::Callback<bool(void)>& make_context_current) 344 const base::Callback<bool(void)>& make_context_current)
246 : x_display_(x_display), 345 : x_display_(x_display),
346 egl_context_(0),
247 glx_context_(glx_context), 347 glx_context_(glx_context),
248 make_context_current_(make_context_current), 348 make_context_current_(make_context_current),
249 state_(kUninitialized), 349 state_(kUninitialized),
250 input_ready_(&lock_), 350 input_ready_(&lock_),
251 surfaces_available_(&lock_), 351 surfaces_available_(&lock_),
252 message_loop_(base::MessageLoop::current()), 352 message_loop_(base::MessageLoop::current()),
253 weak_this_(base::AsWeakPtr(this)), 353 weak_this_(base::AsWeakPtr(this)),
254 client_ptr_factory_(client), 354 client_ptr_factory_(client),
255 client_(client_ptr_factory_.GetWeakPtr()), 355 client_(client_ptr_factory_.GetWeakPtr()),
256 decoder_thread_("VaapiDecoderThread"), 356 decoder_thread_("VaapiDecoderThread"),
257 num_frames_at_client_(0), 357 num_frames_at_client_(0),
258 num_stream_bufs_at_decoder_(0), 358 num_stream_bufs_at_decoder_(0),
259 finish_flush_pending_(false), 359 finish_flush_pending_(false),
260 awaiting_va_surfaces_recycle_(false), 360 awaiting_va_surfaces_recycle_(false),
261 requested_num_pics_(0) { 361 requested_num_pics_(0) {
262 DCHECK(client); 362 DCHECK(client);
263 } 363 }
264 364
365 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
366 EGLDisplay egl_display, EGLContext egl_context,
367 Client* client,
368 const base::Callback<bool(void)>& make_context_current)
369 : x_display_(0),
370 egl_display_(egl_display),
371 egl_context_(egl_context),
372 glx_context_(0),
373 make_context_current_(make_context_current),
374 state_(kUninitialized),
375 input_ready_(&lock_),
376 surfaces_available_(&lock_),
377 message_loop_(base::MessageLoop::current()),
378 weak_this_(base::AsWeakPtr(this)),
379 client_ptr_factory_(client),
380 client_(client_ptr_factory_.GetWeakPtr()),
381 decoder_thread_("VaapiDecoderThread"),
382 num_frames_at_client_(0),
383 num_stream_bufs_at_decoder_(0),
384 finish_flush_pending_(false),
385 awaiting_va_surfaces_recycle_(false),
386 requested_num_pics_(0) {
387 DCHECK(client);
388 }
265 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { 389 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() {
266 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 390 DCHECK_EQ(message_loop_, base::MessageLoop::current());
267 } 391 }
268 392
269 class ScopedPtrXFree { 393 class ScopedPtrXFree {
270 public: 394 public:
271 void operator()(void* x) const { 395 void operator()(void* x) const {
272 ::XFree(x); 396 ::XFree(x);
273 } 397 }
274 }; 398 };
275 399
276 bool VaapiVideoDecodeAccelerator::InitializeFBConfig() { 400 bool VaapiVideoDecodeAccelerator::InitializeFBConfig() {
277 const int fbconfig_attr[] = { 401 if(glx_context_) {
278 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, 402 const int fbconfig_attr[] = {
279 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, 403 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
280 GLX_BIND_TO_TEXTURE_RGB_EXT, GL_TRUE, 404 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
281 GLX_Y_INVERTED_EXT, GL_TRUE, 405 GLX_BIND_TO_TEXTURE_RGB_EXT, GL_TRUE,
282 GL_NONE, 406 GLX_Y_INVERTED_EXT, GL_TRUE,
283 }; 407 GL_NONE,
408 };
284 409
285 int num_fbconfigs; 410 int num_fbconfigs;
286 scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> glx_fb_configs( 411 scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> glx_fb_configs(
287 glXChooseFBConfig(x_display_, DefaultScreen(x_display_), fbconfig_attr, 412 glXChooseFBConfig(x_display_, DefaultScreen(x_display_), fbconfig_attr,
288 &num_fbconfigs)); 413 &num_fbconfigs));
289 if (!glx_fb_configs) 414 if (!glx_fb_configs)
415 return false;
416 if (!num_fbconfigs)
417 return false;
418
419 fb_config_ = glx_fb_configs.get()[0];
420 } else if(egl_context_) {
421 x_display_ = base::MessagePumpForUI::GetDefaultXDisplay();
422 } else {
290 return false; 423 return false;
291 if (!num_fbconfigs) 424 }
292 return false;
293 425
294 fb_config_ = glx_fb_configs.get()[0];
295 return true; 426 return true;
296 } 427 }
297 428
298 bool VaapiVideoDecodeAccelerator::Initialize( 429 bool VaapiVideoDecodeAccelerator::Initialize(
299 media::VideoCodecProfile profile) { 430 media::VideoCodecProfile profile) {
300 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 431 DCHECK_EQ(message_loop_, base::MessageLoop::current());
301 432
302 base::AutoLock auto_lock(lock_); 433 base::AutoLock auto_lock(lock_);
303 DCHECK_EQ(state_, kUninitialized); 434 DCHECK_EQ(state_, kUninitialized);
304 DVLOG(2) << "Initializing VAVDA, profile: " << profile; 435 DVLOG(2) << "Initializing VAVDA, profile: " << profile;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 vaapi_wrapper_->CreateSurfaces(requested_pic_size_, 840 vaapi_wrapper_->CreateSurfaces(requested_pic_size_,
710 buffers.size(), 841 buffers.size(),
711 &va_surface_ids), 842 &va_surface_ids),
712 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); 843 "Failed creating VA Surfaces", PLATFORM_FAILURE, );
713 DCHECK_EQ(va_surface_ids.size(), buffers.size()); 844 DCHECK_EQ(va_surface_ids.size(), buffers.size());
714 845
715 for (size_t i = 0; i < buffers.size(); ++i) { 846 for (size_t i = 0; i < buffers.size(); ++i) {
716 DVLOG(2) << "Assigning picture id: " << buffers[i].id() 847 DVLOG(2) << "Assigning picture id: " << buffers[i].id()
717 << " to texture id: " << buffers[i].texture_id() 848 << " to texture id: " << buffers[i].texture_id()
718 << " VASurfaceID: " << va_surface_ids[i]; 849 << " VASurfaceID: " << va_surface_ids[i];
850 if(glx_context_) {
851 linked_ptr<TFPPicture> tfp_picture(
852 TFPPicture::Create(make_context_current_, fb_config_, x_display_,
853 buffers[i].id(), buffers[i].texture_id(),
854 requested_pic_size_));
719 855
720 linked_ptr<TFPPicture> tfp_picture( 856 RETURN_AND_NOTIFY_ON_FAILURE(
721 TFPPicture::Create(make_context_current_, fb_config_, x_display_, 857 tfp_picture.get(), "Failed assigning picture buffer to a texture.",
722 buffers[i].id(), buffers[i].texture_id(), 858 PLATFORM_FAILURE, );
723 requested_pic_size_));
724 859
725 RETURN_AND_NOTIFY_ON_FAILURE( 860 bool inserted = tfp_pictures_.insert(std::make_pair(
726 tfp_picture.get(), "Failed assigning picture buffer to a texture.", 861 buffers[i].id(), tfp_picture)).second;
727 PLATFORM_FAILURE, ); 862 DCHECK(inserted);
863 } else if(egl_context_) {
864 linked_ptr<TFPPicture> tfp_picture(
865 TFPPicture::Create(make_context_current_, egl_display_, x_display_,
866 buffers[i].id(), buffers[i].texture_id(),
867 requested_pic_size_));
728 868
729 bool inserted = tfp_pictures_.insert(std::make_pair( 869 RETURN_AND_NOTIFY_ON_FAILURE(
730 buffers[i].id(), tfp_picture)).second; 870 tfp_picture.get(), "Failed assigning picture buffer to a texture.",
731 DCHECK(inserted); 871 PLATFORM_FAILURE, );
872
873 bool inserted = tfp_pictures_.insert(std::make_pair(
874 buffers[i].id(), tfp_picture)).second;
875 DCHECK(inserted);
876 }
732 877
733 output_buffers_.push(buffers[i].id()); 878 output_buffers_.push(buffers[i].id());
734 available_va_surfaces_.push_back(va_surface_ids[i]); 879 available_va_surfaces_.push_back(va_surface_ids[i]);
735 surfaces_available_.Signal(); 880 surfaces_available_.Signal();
736 } 881 }
737 882
738 state_ = kDecoding; 883 state_ = kDecoding;
739 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 884 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
740 &VaapiVideoDecodeAccelerator::DecodeTask, base::Unretained(this))); 885 &VaapiVideoDecodeAccelerator::DecodeTask, base::Unretained(this)));
741 } 886 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 state_ = kUninitialized; 1070 state_ = kUninitialized;
926 } 1071 }
927 1072
928 void VaapiVideoDecodeAccelerator::Destroy() { 1073 void VaapiVideoDecodeAccelerator::Destroy() {
929 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 1074 DCHECK_EQ(message_loop_, base::MessageLoop::current());
930 Cleanup(); 1075 Cleanup();
931 delete this; 1076 delete this;
932 } 1077 }
933 1078
934 } // namespace content 1079 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698