OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/file_descriptor_posix.h" | 5 #include "base/file_descriptor_posix.h" |
6 #include "content/common/gpu/media/va_surface.h" | 6 #include "content/common/gpu/media/va_surface.h" |
7 #include "content/common/gpu/media/vaapi_drm_picture.h" | 7 #include "content/common/gpu/media/vaapi_drm_picture.h" |
8 #include "content/common/gpu/media/vaapi_wrapper.h" | 8 #include "content/common/gpu/media/vaapi_wrapper.h" |
9 #include "third_party/libva/va/drm/va_drm.h" | 9 #include "third_party/libva/va/drm/va_drm.h" |
10 #include "third_party/libva/va/va.h" | 10 #include "third_party/libva/va/va.h" |
11 #include "third_party/libva/va/va_drmcommon.h" | 11 #include "third_party/libva/va/va_drmcommon.h" |
12 #include "ui/gfx/gpu_memory_buffer.h" | 12 #include "ui/gfx/gpu_memory_buffer.h" |
13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
14 #include "ui/gl/gl_image_linux_dma_buffer.h" | 14 #include "ui/gl/gl_image_linux_dma_buffer.h" |
15 #include "ui/gl/scoped_binders.h" | 15 #include "ui/gl/scoped_binders.h" |
| 16 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" |
16 #include "ui/ozone/public/native_pixmap.h" | 17 #include "ui/ozone/public/native_pixmap.h" |
17 #include "ui/ozone/public/ozone_platform.h" | 18 #include "ui/ozone/public/ozone_platform.h" |
18 #include "ui/ozone/public/surface_factory_ozone.h" | 19 #include "ui/ozone/public/surface_factory_ozone.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 VaapiDrmPicture::VaapiDrmPicture( | 23 VaapiDrmPicture::VaapiDrmPicture( |
23 VaapiWrapper* vaapi_wrapper, | 24 VaapiWrapper* vaapi_wrapper, |
24 const base::Callback<bool(void)>& make_context_current, | 25 const base::Callback<bool(void)>& make_context_current, |
25 int32 picture_buffer_id, | 26 int32 picture_buffer_id, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 va_surface_ = vaapi_wrapper_->CreateUnownedSurface(VA_RT_FORMAT_RGB32, size(), | 95 va_surface_ = vaapi_wrapper_->CreateUnownedSurface(VA_RT_FORMAT_RGB32, size(), |
95 va_attribs); | 96 va_attribs); |
96 if (!va_surface_) { | 97 if (!va_surface_) { |
97 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; | 98 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
98 return false; | 99 return false; |
99 } | 100 } |
100 | 101 |
101 if (!make_context_current_.Run()) | 102 if (!make_context_current_.Run()) |
102 return false; | 103 return false; |
103 | 104 |
104 // Create an EGLImage out of the same buffer. | 105 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, |
105 gl_image_ = new gfx::GLImageLinuxDMABuffer(size(), GL_RGBA); | 106 texture_id()); |
106 if (!gl_image_->Initialize(base::FileDescriptor(dmabuf_fd, false), | 107 gl_image_ = ui::GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmap( |
107 gfx::GpuMemoryBuffer::BGRA_8888, dmabuf_pitch)) { | 108 pixmap_, size(), gfx::GpuMemoryBuffer::RGBA_8888, GL_RGBA); |
108 LOG(ERROR) << "Failed to create a GLImageLinuxDMABuffer for a NativePixmap"; | 109 if (!gl_image_) { |
| 110 LOG(ERROR) << "Failed to create GLImage"; |
109 return false; | 111 return false; |
110 } | 112 } |
111 | |
112 // Bind the EGLImage to the given GL texture. | |
113 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, | |
114 texture_id()); | |
115 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { | 113 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { |
116 LOG(ERROR) << "Failed to bind texture to GLImage"; | 114 LOG(ERROR) << "Failed to bind texture to GLImage"; |
117 return false; | 115 return false; |
118 } | 116 } |
119 | 117 |
120 return true; | 118 return true; |
121 } | 119 } |
122 | 120 |
123 bool VaapiDrmPicture::DownloadFromSurface( | 121 bool VaapiDrmPicture::DownloadFromSurface( |
124 const scoped_refptr<VASurface>& va_surface) { | 122 const scoped_refptr<VASurface>& va_surface) { |
125 return vaapi_wrapper_->BlitSurface(va_surface->id(), va_surface->size(), | 123 return vaapi_wrapper_->BlitSurface(va_surface->id(), va_surface->size(), |
126 va_surface_->id(), va_surface_->size()); | 124 va_surface_->id(), va_surface_->size()); |
127 } | 125 } |
128 | 126 |
| 127 scoped_refptr<gfx::GLImage> VaapiDrmPicture::GetImageToBind() { |
| 128 return gl_image_; |
| 129 } |
| 130 |
| 131 bool VaapiDrmPicture::AllowOverlay() const { |
| 132 return true; |
| 133 } |
| 134 |
129 } // namespace | 135 } // namespace |
OLD | NEW |