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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 bool VaapiDrmPicture::Initialize() { | 43 bool VaapiDrmPicture::Initialize() { |
44 // We want to create a VASurface and an EGLImage out of the same | 44 // We want to create a VASurface and an EGLImage out of the same |
45 // memory buffer, so we can output decoded pictures to it using | 45 // memory buffer, so we can output decoded pictures to it using |
46 // VAAPI and also use it to paint with GL. | 46 // VAAPI and also use it to paint with GL. |
47 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); | 47 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); |
48 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); | 48 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); |
49 | 49 |
50 // Create a buffer from Ozone. | 50 // Create a buffer from Ozone. |
51 pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size(), | 51 pixmap_ = factory->CreateNativePixmap( |
52 ui::SurfaceFactoryOzone::RGBA_8888, | 52 gfx::kNullAcceleratedWidget, size(), ui::SurfaceFactoryOzone::BGRA_8888, |
53 ui::SurfaceFactoryOzone::SCANOUT); | 53 ui::SurfaceFactoryOzone::SCANOUT, nullptr); |
54 if (!pixmap_) { | 54 if (!pixmap_) { |
55 LOG(ERROR) << "Failed creating an Ozone NativePixmap"; | 55 LOG(ERROR) << "Failed creating an Ozone NativePixmap"; |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 // Get the dmabuf of the created buffer. | 59 // Get the dmabuf of the created buffer. |
60 int dmabuf_fd = pixmap_->GetDmaBufFd(); | 60 int dmabuf_fd = pixmap_->GetDmaBufFd(); |
61 if (dmabuf_fd < 0) { | 61 if (dmabuf_fd < 0) { |
62 LOG(ERROR) << "Failed to get dmabuf from an Ozone NativePixmap"; | 62 LOG(ERROR) << "Failed to get dmabuf from an Ozone NativePixmap"; |
63 return false; | 63 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; | 98 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 if (!make_context_current_.Run()) | 102 if (!make_context_current_.Run()) |
103 return false; | 103 return false; |
104 | 104 |
105 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, | 105 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, |
106 texture_id()); | 106 texture_id()); |
107 gl_image_ = ui::GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmap( | 107 gl_image_ = ui::GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmap( |
108 pixmap_, size(), gfx::GpuMemoryBuffer::BGRA_8888, GL_RGBA); | 108 pixmap_, size(), gfx::GpuMemoryBuffer::BGRA_8888, GL_BGRA_EXT); |
109 if (!gl_image_) { | 109 if (!gl_image_) { |
110 LOG(ERROR) << "Failed to create GLImage"; | 110 LOG(ERROR) << "Failed to create GLImage"; |
111 return false; | 111 return false; |
112 } | 112 } |
113 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { | 113 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { |
114 LOG(ERROR) << "Failed to bind texture to GLImage"; | 114 LOG(ERROR) << "Failed to bind texture to GLImage"; |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 bool VaapiDrmPicture::DownloadFromSurface( | 121 bool VaapiDrmPicture::DownloadFromSurface( |
122 const scoped_refptr<VASurface>& va_surface) { | 122 const scoped_refptr<VASurface>& va_surface) { |
123 return vaapi_wrapper_->BlitSurface(va_surface->id(), va_surface->size(), | 123 return vaapi_wrapper_->BlitSurface(va_surface->id(), va_surface->size(), |
124 va_surface_->id(), va_surface_->size()); | 124 va_surface_->id(), va_surface_->size()); |
125 } | 125 } |
126 | 126 |
127 scoped_refptr<gfx::GLImage> VaapiDrmPicture::GetImageToBind() { | 127 scoped_refptr<gfx::GLImage> VaapiDrmPicture::GetImageToBind() { |
128 return gl_image_; | 128 return gl_image_; |
129 } | 129 } |
130 | 130 |
131 bool VaapiDrmPicture::AllowOverlay() const { | 131 bool VaapiDrmPicture::AllowOverlay() const { |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 } // namespace | 135 } // namespace |
OLD | NEW |