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

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

Issue 1269503007: Unify graphics buffer format & usage enums for GpuMemoryBuffer & SurfaceFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add header to BUILD.gn Created 5 years, 4 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 "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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return va_surface; 89 return va_surface;
90 } 90 }
91 91
92 scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CreateNativePixmap( 92 scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CreateNativePixmap(
93 gfx::Size size) { 93 gfx::Size size) {
94 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); 94 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
95 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); 95 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
96 96
97 // Create a buffer from Ozone. 97 // Create a buffer from Ozone.
98 return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, 98 return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
99 ui::SurfaceFactoryOzone::BGRA_8888, 99 gfx::BufferFormat::BGRA_8888,
100 ui::SurfaceFactoryOzone::SCANOUT); 100 gfx::BufferUsage::SCANOUT);
101 } 101 }
102 102
103 bool VaapiDrmPicture::Initialize() { 103 bool VaapiDrmPicture::Initialize() {
104 // We want to create a VASurface and an EGLImage out of the same 104 // We want to create a VASurface and an EGLImage out of the same
105 // memory buffer, so we can output decoded pictures to it using 105 // memory buffer, so we can output decoded pictures to it using
106 // VAAPI and also use it to paint with GL. 106 // VAAPI and also use it to paint with GL.
107 pixmap_ = CreateNativePixmap(size()); 107 pixmap_ = CreateNativePixmap(size());
108 if (!pixmap_) { 108 if (!pixmap_) {
109 LOG(ERROR) << "Failed creating an Ozone NativePixmap"; 109 LOG(ERROR) << "Failed creating an Ozone NativePixmap";
110 return false; 110 return false;
(...skipping 11 matching lines...) Expand all
122 pixmap_->SetScalingCallback(base::Bind(&VaapiDrmPicture::CallScalePixmap, 122 pixmap_->SetScalingCallback(base::Bind(&VaapiDrmPicture::CallScalePixmap,
123 weak_this_factory_.GetWeakPtr())); 123 weak_this_factory_.GetWeakPtr()));
124 124
125 if (!make_context_current_.Run()) 125 if (!make_context_current_.Run())
126 return false; 126 return false;
127 127
128 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, 128 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES,
129 texture_id()); 129 texture_id());
130 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 130 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
131 new gfx::GLImageOzoneNativePixmap(size(), GL_BGRA_EXT)); 131 new gfx::GLImageOzoneNativePixmap(size(), GL_BGRA_EXT));
132 if (!image->Initialize(pixmap_.get(), gfx::GpuMemoryBuffer::BGRA_8888)) { 132 if (!image->Initialize(pixmap_.get(), gfx::BufferFormat::BGRA_8888)) {
133 LOG(ERROR) << "Failed to create GLImage"; 133 LOG(ERROR) << "Failed to create GLImage";
134 return false; 134 return false;
135 } 135 }
136 gl_image_ = image; 136 gl_image_ = image;
137 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { 137 if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) {
138 LOG(ERROR) << "Failed to bind texture to GLImage"; 138 LOG(ERROR) << "Failed to bind texture to GLImage";
139 return false; 139 return false;
140 } 140 }
141 141
142 return true; 142 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 scoped_refptr<gfx::GLImage> VaapiDrmPicture::GetImageToBind() { 194 scoped_refptr<gfx::GLImage> VaapiDrmPicture::GetImageToBind() {
195 return gl_image_; 195 return gl_image_;
196 } 196 }
197 197
198 bool VaapiDrmPicture::AllowOverlay() const { 198 bool VaapiDrmPicture::AllowOverlay() const {
199 return true; 199 return true;
200 } 200 }
201 201
202 } // namespace 202 } // namespace
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/renderer/media/renderer_gpu_video_accelerator_factories.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698