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

Side by Side Diff: media/gpu/vaapi_drm_picture.cc

Issue 2678343011: chromeos: decode video into NV12 format instead of RGBA in vaapi decoder (Closed)
Patch Set: decide scanout in runtime Created 3 years, 5 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
OLDNEW
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 "media/gpu/vaapi_drm_picture.h" 5 #include "media/gpu/vaapi_drm_picture.h"
6 6
7 #include "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
8 #include "media/gpu/va_surface.h" 9 #include "media/gpu/va_surface.h"
9 #include "media/gpu/vaapi_wrapper.h" 10 #include "media/gpu/vaapi_wrapper.h"
10 #include "third_party/libva/va/drm/va_drm.h" 11 #include "third_party/libva/va/drm/va_drm.h"
11 #include "third_party/libva/va/va.h" 12 #include "third_party/libva/va/va.h"
12 #include "ui/gfx/gpu_memory_buffer.h" 13 #include "ui/gfx/gpu_memory_buffer.h"
13 #include "ui/gfx/native_pixmap.h" 14 #include "ui/gfx/native_pixmap.h"
14 #include "ui/gl/gl_bindings.h" 15 #include "ui/gl/gl_bindings.h"
15 #include "ui/gl/gl_image_native_pixmap.h" 16 #include "ui/gl/gl_image_native_pixmap.h"
16 #include "ui/gl/scoped_binders.h" 17 #include "ui/gl/scoped_binders.h"
17 #include "ui/ozone/public/ozone_platform.h" 18 #include "ui/ozone/public/ozone_platform.h"
(...skipping 25 matching lines...) Expand all
43 } 44 }
44 45
45 static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) { 46 static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) {
46 switch (format) { 47 switch (format) {
47 case gfx::BufferFormat::BGRA_8888: 48 case gfx::BufferFormat::BGRA_8888:
48 return GL_BGRA_EXT; 49 return GL_BGRA_EXT;
49 50
50 case gfx::BufferFormat::YVU_420: 51 case gfx::BufferFormat::YVU_420:
51 return GL_RGB_YCRCB_420_CHROMIUM; 52 return GL_RGB_YCRCB_420_CHROMIUM;
52 53
54 case gfx::BufferFormat::YUV_420_BIPLANAR:
55 return GL_RGB_YCBCR_420V_CHROMIUM;
56
53 default: 57 default:
54 NOTREACHED(); 58 NOTREACHED();
55 return GL_BGRA_EXT; 59 return GL_BGRA_EXT;
56 } 60 }
57 } 61 }
58 62
59 bool VaapiDrmPicture::Initialize() { 63 bool VaapiDrmPicture::Initialize() {
60 DCHECK(pixmap_); 64 DCHECK(pixmap_);
61 65
62 va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_); 66 va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return false; 101 return false;
98 } 102 }
99 } 103 }
100 104
101 return true; 105 return true;
102 } 106 }
103 107
104 bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) { 108 bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) {
105 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); 109 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
106 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); 110 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
111 gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ;
112 DCHECK(gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage));
113 if (gpu::IsNativeGpuMemoryBufferConfigurationSupported(
114 format, gfx::BufferUsage::SCANOUT))
115 usage = gfx::BufferUsage::SCANOUT;
107 pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_, 116 pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_,
108 format, gfx::BufferUsage::SCANOUT); 117 format, usage);
109 if (!pixmap_) { 118 if (!pixmap_) {
110 DVLOG(1) << "Failed allocating a pixmap"; 119 DVLOG(1) << "Failed allocating a pixmap";
111 return false; 120 return false;
112 } 121 }
113 122
114 return Initialize(); 123 return Initialize();
115 } 124 }
116 125
117 bool VaapiDrmPicture::ImportGpuMemoryBufferHandle( 126 bool VaapiDrmPicture::ImportGpuMemoryBufferHandle(
118 gfx::BufferFormat format, 127 gfx::BufferFormat format,
(...skipping 11 matching lines...) Expand all
130 139
131 return Initialize(); 140 return Initialize();
132 } 141 }
133 142
134 bool VaapiDrmPicture::DownloadFromSurface( 143 bool VaapiDrmPicture::DownloadFromSurface(
135 const scoped_refptr<VASurface>& va_surface) { 144 const scoped_refptr<VASurface>& va_surface) {
136 return vaapi_wrapper_->BlitSurface(va_surface, va_surface_); 145 return vaapi_wrapper_->BlitSurface(va_surface, va_surface_);
137 } 146 }
138 147
139 bool VaapiDrmPicture::AllowOverlay() const { 148 bool VaapiDrmPicture::AllowOverlay() const {
140 return true; 149 // TODO(dshwang): make it true when cros kernel supports NV12 overlay.
150 // crbug.com/683347
151 return pixmap_->GetBufferUsage() == gfx::BufferUsage::SCANOUT;
141 } 152 }
142 153
143 } // namespace media 154 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698