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

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

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove picture destruction sequence Created 6 years 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
(Empty)
1 // Copyright 2014 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/common/gpu/media/va_surface.h"
6 #include "content/common/gpu/media/vaapi_tfp_picture.h"
7 #include "content/common/gpu/media/vaapi_wrapper.h"
8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context_glx.h"
10 #include "ui/gl/gl_image_glx.h"
11 #include "ui/gl/scoped_binders.h"
12
13 namespace content {
14
15 VaapiTFPPicture::VaapiTFPPicture(
16 base::WeakPtr<VaapiWrapper> vaapi_wrapper,
17 gfx::GLContextGLX* glx_context,
18 const base::Callback<bool(void)> make_context_current,
19 int32 picture_buffer_id,
20 uint32 texture_id,
21 const gfx::Size& size)
22 : VaapiPicture(picture_buffer_id, texture_id, size),
23 vaapi_wrapper_(vaapi_wrapper),
24 glx_context_(glx_context),
25 make_context_current_(make_context_current),
26 x_display_(glx_context_->display()),
27 x_pixmap_(0) {
28 }
29
30 VaapiTFPPicture::~VaapiTFPPicture() {
31 // At this point |vaapi_wrapper_| shouldn't be available anymore.
32 DCHECK(!vaapi_wrapper_.get());
33
34 if (glx_image_.get() && make_context_current_.Run()) {
35 glx_image_->ReleaseTexImage(GL_TEXTURE_2D);
36 glx_image_->Destroy(true);
37 DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR));
Pawel Osciak 2014/12/08 10:55:15 Is this required to compile? You didn't have it pr
llandwerlin-old 2014/12/08 16:42:06 Yes, I was testing on non-Debug build.
38 }
39
40 if (x_pixmap_)
41 XFreePixmap(x_display_, x_pixmap_);
42 }
43
44 bool VaapiTFPPicture::Initialize() {
45 if (!make_context_current_.Run())
46 return false;
47
48 XWindowAttributes win_attr;
49 int screen = DefaultScreen(x_display_);
50 XGetWindowAttributes(x_display_, RootWindow(x_display_, screen), &win_attr);
51 // TODO(posciak): pass the depth required by libva, not the RootWindow's
52 // depth
53 x_pixmap_ = XCreatePixmap(x_display_,
54 RootWindow(x_display_, screen),
55 size().width(),
56 size().height(),
57 win_attr.depth);
58 if (!x_pixmap_) {
59 LOG(ERROR) << "Failed creating an X Pixmap for TFP";
60 return false;
61 }
62
63 glx_image_ = new gfx::GLImageGLX(size(), GL_RGB);
64 if (!glx_image_->Initialize(x_pixmap_)) {
65 // x_pixmap_ will be freed in the destructor.
66 LOG(ERROR) << "Failed creating a GLX Pixmap for TFP";
67 return false;
68 }
69
70 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id());
71 if (!glx_image_->BindTexImage(GL_TEXTURE_2D)) {
72 LOG(ERROR) << "Failed to bind texture to glx image";
73 return false;
74 }
75
76 return true;
77 }
78
79 bool VaapiTFPPicture::DownloadFromSurface(
80 const scoped_refptr<VASurface>& va_surface) {
81 if (!vaapi_wrapper_.get()) {
82 LOG(ERROR) << "VaapiWrapper not available";
83 return false;
84 }
85
86 return vaapi_wrapper_->PutSurfaceIntoPixmap(
87 va_surface->id(), x_pixmap_, va_surface->size());
88 }
89
90 // static
91 uint32 VaapiPicture::GetGLTextureTarget() {
92 return GL_TEXTURE_2D;
93 }
94
95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698