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

Unified Diff: content/common/gpu/media/rendering_helper.cc

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing modifications in video accelerators Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/rendering_helper.cc
diff --git a/content/common/gpu/media/rendering_helper.cc b/content/common/gpu/media/rendering_helper.cc
index 00e85f9f0ecd0c44b1961175d1fc5ce248670712..3252a0e125bce99b4ad5e9294c91d1b89f8eefc0 100644
--- a/content/common/gpu/media/rendering_helper.cc
+++ b/content/common/gpu/media/rendering_helper.cc
@@ -19,7 +19,6 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_egl.h"
-#include "ui/gl/gl_surface_glx.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -27,14 +26,19 @@
#if defined(USE_X11)
#include "ui/gfx/x/x11_types.h"
-#endif
-
-#if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
+#include "ui/gl/gl_surface_glx.h"
#define GL_VARIANT_GLX 1
#else
#define GL_VARIANT_EGL 1
#endif
+#if defined(USE_OZONE)
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/ozone/public/ui_thread_gpu.h"
+#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_delegate.h"
+#endif
+
// Helper for Shader creation.
static void CreateShader(GLuint program,
GLenum type,
@@ -57,6 +61,51 @@ static void CreateShader(GLuint program,
namespace content {
+#if defined(USE_OZONE)
+
+const int kTestWindowWidth = 800;
+const int kTestWindowHeight = 600;
+
+class RenderingHelper::StubOzoneDelegate : public ui::PlatformWindowDelegate {
+ public:
+ StubOzoneDelegate() : widget_(gfx::kNullAcceleratedWidget) {
+ platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
+ this, gfx::Rect(kTestWindowWidth, kTestWindowHeight));
+ }
+ virtual ~StubOzoneDelegate() {}
+
+ virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE {}
+
+ virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {}
+
+ virtual void DispatchEvent(ui::Event* event) OVERRIDE {}
+
+ virtual void OnCloseRequest() OVERRIDE {}
+ virtual void OnClosed() OVERRIDE {}
+
+ virtual void OnWindowStateChanged(
+ ui::PlatformWindowState new_state) OVERRIDE{};
Pawel Osciak 2014/10/08 08:17:21 I think we need a space before OVERRIDE (I may be
llandwerlin-old 2014/10/08 09:31:17 I did run git cl format and was a bit surprised th
+
+ virtual void OnLostCapture() OVERRIDE{};
+
+ virtual void OnAcceleratedWidgetAvailable(
+ gfx::AcceleratedWidget widget) OVERRIDE {
+ widget_ = widget;
+ };
+
+ virtual void OnActivationChanged(bool active) OVERRIDE{};
+
+ gfx::AcceleratedWidget GetAcceleratedWidget() const { return widget_; }
+
+ gfx::Size GetSize() { return platform_window_->GetBounds().size(); }
+
+ private:
+ scoped_ptr<ui::PlatformWindow> platform_window_;
+ gfx::AcceleratedWidget widget_;
+};
+
+#endif
+
RenderingHelperParams::RenderingHelperParams() {}
RenderingHelperParams::~RenderingHelperParams() {}
@@ -84,13 +133,21 @@ RenderingHelper::RenderedVideo::~RenderedVideo() {
// static
bool RenderingHelper::InitializeOneOff() {
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
+
#if GL_VARIANT_GLX
cmd_line->AppendSwitchASCII(switches::kUseGL,
gfx::kGLImplementationDesktopName);
#else
cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName);
#endif
+
+#if defined(USE_OZONE)
+ static ui::UiThreadGpu ui_thread_gpu;
+ ui::OzonePlatform::InitializeForUI();
+ return gfx::GLSurface::InitializeOneOff() && ui_thread_gpu.Initialize();
+#else
return gfx::GLSurface::InitializeOneOff();
+#endif
}
RenderingHelper::RenderingHelper() {
@@ -164,6 +221,11 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
XStoreName(display, window_, "VideoDecodeAcceleratorTest");
XSelectInput(display, window_, ExposureMask);
XMapWindow(display, window_);
+#elif defined(USE_OZONE)
+ platform_window_delegate_.reset(new RenderingHelper::StubOzoneDelegate());
+ window_ = platform_window_delegate_->GetAcceleratedWidget();
+
+ screen_size_ = platform_window_delegate_->GetSize();
#else
#error unknown platform
#endif
@@ -430,7 +492,11 @@ void RenderingHelper::DeleteTexture(uint32 texture_id) {
CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR);
}
-void* RenderingHelper::GetGLContext() {
+scoped_refptr<gfx::GLContext> RenderingHelper::GetGLContext() {
+ return gl_context_;
+}
+
+void* RenderingHelper::GetGLContextHandle() {
return gl_context_->GetHandle();
}
@@ -452,7 +518,7 @@ void RenderingHelper::Clear() {
#if defined(OS_WIN)
if (window_)
DestroyWindow(window_);
-#else
+#elif defined(USE_X11)
// Destroy resources acquired in Initialize, in reverse-acquisition order.
if (window_) {
CHECK(XUnmapWindow(gfx::GetXDisplay(), window_));
@@ -515,8 +581,14 @@ void RenderingHelper::RenderContent() {
// In render_as_thumbnails_ mode, we render the FBO content on the
// screen instead of the decoded textures.
GLSetViewPort(videos_[0].render_area);
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
RenderTexture(GL_TEXTURE_2D, thumbnails_texture_id_);
} else {
+ GLSetViewPort(gfx::Rect(screen_size_));
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
for (size_t i = 0; i < videos_.size(); ++i) {
RenderedVideo* video = &videos_[i];
if (video->pending_frames.empty())

Powered by Google App Engine
This is Rietveld 408576698