Commit 7e4d7965 authored by Aldo Culquicondor's avatar Aldo Culquicondor Committed by Commit Bot

Rename GraphicsDelegate to CompositorDelegate

The compositor delegate will own and manage the surfaces, viewports and
buffers. The newly added public interface restricts the manipulation of
contexts to the client (RenderLoop). A native GL implementation is
provided.

Bug: 767282
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:linux_vr;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I23138f85ba859a64cbcc60c2d8f32757ec941f22
Reviewed-on: https://chromium-review.googlesource.com/1173394Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Aldo Culquicondor <acondor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583349}
parent b3cb7284
...@@ -88,10 +88,9 @@ void VrGLThread::Init() { ...@@ -88,10 +88,9 @@ void VrGLThread::Init() {
weak_browser_ui_ = vr_shell_gl_->GetBrowserUiWeakPtr(); weak_browser_ui_ = vr_shell_gl_->GetBrowserUiWeakPtr();
task_runner()->PostTask( task_runner()->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&VrShellGl::Init, vr_shell_gl_->GetWeakPtr(),
base::BindOnce(&VrShellGl::Initialize, vr_shell_gl_->GetWeakPtr(), base::Unretained(gl_surface_created_event_),
base::Unretained(gl_surface_created_event_), base::Passed(std::move(surface_callback_))));
base::Passed(std::move(surface_callback_))));
} }
void VrGLThread::CleanUp() { void VrGLThread::CleanUp() {
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "chrome/browser/android/vr/vr_shell.h" #include "chrome/browser/android/vr/vr_shell.h"
#include "chrome/browser/vr/assets_loader.h" #include "chrome/browser/vr/assets_loader.h"
#include "chrome/browser/vr/gl_texture_location.h" #include "chrome/browser/vr/gl_texture_location.h"
#include "chrome/browser/vr/graphics_delegate.h"
#include "chrome/browser/vr/metrics/session_metrics_helper.h" #include "chrome/browser/vr/metrics/session_metrics_helper.h"
#include "chrome/browser/vr/model/assets.h" #include "chrome/browser/vr/model/assets.h"
#include "chrome/browser/vr/model/camera_model.h" #include "chrome/browser/vr/model/camera_model.h"
...@@ -193,7 +192,7 @@ VrShellGl::VrShellGl(GlBrowserInterface* browser, ...@@ -193,7 +192,7 @@ VrShellGl::VrShellGl(GlBrowserInterface* browser,
bool start_in_web_vr_mode, bool start_in_web_vr_mode,
bool pause_content, bool pause_content,
bool low_density) bool low_density)
: RenderLoop(std::move(ui), browser, kWebVRSlidingAverageSize), : RenderLoop(std::move(ui), browser, this, kWebVRSlidingAverageSize),
webvr_vsync_align_( webvr_vsync_align_(
base::FeatureList::IsEnabled(features::kWebVrVsyncAlign)), base::FeatureList::IsEnabled(features::kWebVrVsyncAlign)),
low_density_(low_density), low_density_(low_density),
...@@ -223,9 +222,8 @@ VrShellGl::~VrShellGl() { ...@@ -223,9 +222,8 @@ VrShellGl::~VrShellGl() {
webxr_.EndPresentation(); webxr_.EndPresentation();
} }
void VrShellGl::Initialize( void VrShellGl::Init(base::WaitableEvent* gl_surface_created_event,
base::WaitableEvent* gl_surface_created_event, base::OnceCallback<gfx::AcceleratedWidget()> callback) {
base::OnceCallback<gfx::AcceleratedWidget()> callback) {
if (surfaceless_rendering_) { if (surfaceless_rendering_) {
InitializeGl(nullptr); InitializeGl(nullptr);
} else { } else {
...@@ -254,9 +252,7 @@ void VrShellGl::InitializeGl(gfx::AcceleratedWidget window) { ...@@ -254,9 +252,7 @@ void VrShellGl::InitializeGl(gfx::AcceleratedWidget window) {
return; return;
} }
graphics_delegate_ = std::make_unique<GraphicsDelegate>(surface_); if (!BaseCompositorDelegate::Initialize(surface_)) {
if (!graphics_delegate_->Initialize()) {
ForceExitVr(); ForceExitVr();
return; return;
} }
...@@ -1228,7 +1224,6 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) { ...@@ -1228,7 +1224,6 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) {
void VrShellGl::DrawIntoAcquiredFrame(int16_t frame_index, void VrShellGl::DrawIntoAcquiredFrame(int16_t frame_index,
base::TimeTicks current_time) { base::TimeTicks current_time) {
TRACE_EVENT1("gpu", "VrShellGl::DrawIntoAcquiredFrame", "frame", frame_index); TRACE_EVENT1("gpu", "VrShellGl::DrawIntoAcquiredFrame", "frame", frame_index);
last_used_head_pose_ = render_info_.head_pose;
bool is_webxr_frame = frame_index >= 0; bool is_webxr_frame = frame_index >= 0;
DCHECK(!is_webxr_frame || webxr_.HaveProcessingFrame()); DCHECK(!is_webxr_frame || webxr_.HaveProcessingFrame());
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "chrome/browser/android/vr/android_vsync_helper.h" #include "chrome/browser/android/vr/android_vsync_helper.h"
#include "chrome/browser/android/vr/vr_controller.h"
#include "chrome/browser/android/vr/web_xr_presentation_state.h" #include "chrome/browser/android/vr/web_xr_presentation_state.h"
#include "chrome/browser/vr/base_compositor_delegate.h"
#include "chrome/browser/vr/fps_meter.h" #include "chrome/browser/vr/fps_meter.h"
#include "chrome/browser/vr/model/controller_model.h" #include "chrome/browser/vr/model/controller_model.h"
#include "chrome/browser/vr/render_info.h" #include "chrome/browser/vr/render_info.h"
...@@ -97,6 +97,7 @@ struct Viewport { ...@@ -97,6 +97,7 @@ struct Viewport {
// This class manages all GLThread owned objects and GL rendering for VrShell. // This class manages all GLThread owned objects and GL rendering for VrShell.
// It is not threadsafe and must only be used on the GL thread. // It is not threadsafe and must only be used on the GL thread.
class VrShellGl : public RenderLoop, class VrShellGl : public RenderLoop,
public BaseCompositorDelegate,
public device::mojom::XRPresentationProvider, public device::mojom::XRPresentationProvider,
public device::mojom::XRFrameDataProvider { public device::mojom::XRFrameDataProvider {
public: public:
...@@ -110,8 +111,8 @@ class VrShellGl : public RenderLoop, ...@@ -110,8 +111,8 @@ class VrShellGl : public RenderLoop,
bool low_density); bool low_density);
~VrShellGl() override; ~VrShellGl() override;
void Initialize(base::WaitableEvent* gl_surface_created_event, void Init(base::WaitableEvent* gl_surface_created_event,
base::OnceCallback<gfx::AcceleratedWidget()> callback); base::OnceCallback<gfx::AcceleratedWidget()> callback);
void OnTriggerEvent(bool pressed); void OnTriggerEvent(bool pressed);
void OnExitPresent(); void OnExitPresent();
...@@ -400,8 +401,6 @@ class VrShellGl : public RenderLoop, ...@@ -400,8 +401,6 @@ class VrShellGl : public RenderLoop,
std::vector<gvr::BufferSpec> specs_; std::vector<gvr::BufferSpec> specs_;
gfx::Transform last_used_head_pose_;
ControllerModel controller_model_; ControllerModel controller_model_;
std::unique_ptr<PlatformUiInputDelegate> vr_dialog_input_delegate_; std::unique_ptr<PlatformUiInputDelegate> vr_dialog_input_delegate_;
......
...@@ -214,6 +214,9 @@ component("vr_ui") { ...@@ -214,6 +214,9 @@ component("vr_ui") {
component("vr_common") { component("vr_common") {
sources = [ sources = [
"base_compositor_delegate.cc",
"base_compositor_delegate.h",
"compositor_delegate.h",
"controller_delegate.h", "controller_delegate.h",
"controller_delegate_for_testing.cc", "controller_delegate_for_testing.cc",
"controller_delegate_for_testing.h", "controller_delegate_for_testing.h",
...@@ -221,8 +224,6 @@ component("vr_common") { ...@@ -221,8 +224,6 @@ component("vr_common") {
"fps_meter.h", "fps_meter.h",
"gesture_detector.cc", "gesture_detector.cc",
"gesture_detector.h", "gesture_detector.h",
"graphics_delegate.cc",
"graphics_delegate.h",
"render_loop.cc", "render_loop.cc",
"render_loop.h", "render_loop.h",
"render_loop_browser_interface.h", "render_loop_browser_interface.h",
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/vr/graphics_delegate.h" #include "chrome/browser/vr/base_compositor_delegate.h"
#include <utility>
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h" #include "ui/gl/gl_share_group.h"
...@@ -11,15 +13,16 @@ ...@@ -11,15 +13,16 @@
namespace vr { namespace vr {
GraphicsDelegate::GraphicsDelegate(const scoped_refptr<gl::GLSurface>& surface) BaseCompositorDelegate::BaseCompositorDelegate() {}
: surface_(surface) {}
GraphicsDelegate::~GraphicsDelegate() { BaseCompositorDelegate::~BaseCompositorDelegate() {
if (curr_context_id_ != NONE) if (curr_context_id_ != kNone)
contexts_[curr_context_id_]->ReleaseCurrent(surface_.get()); contexts_[curr_context_id_]->ReleaseCurrent(surface_.get());
} }
bool GraphicsDelegate::Initialize() { bool BaseCompositorDelegate::Initialize(
const scoped_refptr<gl::GLSurface>& surface) {
surface_ = surface;
share_group_ = base::MakeRefCounted<gl::GLShareGroup>(); share_group_ = base::MakeRefCounted<gl::GLShareGroup>();
for (auto& context : contexts_) { for (auto& context : contexts_) {
context = gl::init::CreateGLContext(share_group_.get(), surface_.get(), context = gl::init::CreateGLContext(share_group_.get(), surface_.get(),
...@@ -29,19 +32,19 @@ bool GraphicsDelegate::Initialize() { ...@@ -29,19 +32,19 @@ bool GraphicsDelegate::Initialize() {
return false; return false;
} }
} }
return MakeMainContextCurrent(); return MakeContextCurrent(kMainContext);
}
bool GraphicsDelegate::MakeMainContextCurrent() {
return MakeContextCurrent(MAIN_CONTEXT);
} }
bool GraphicsDelegate::MakeSkiaContextCurrent() { bool BaseCompositorDelegate::RunInSkiaContext(SkiaContextCallback callback) {
return MakeContextCurrent(SKIA_CONTEXT); DCHECK_EQ(curr_context_id_, kMainContext);
if (!MakeContextCurrent(kSkiaContext))
return false;
std::move(callback).Run();
return MakeContextCurrent(kMainContext);
} }
bool GraphicsDelegate::MakeContextCurrent(ContextId context_id) { bool BaseCompositorDelegate::MakeContextCurrent(ContextId context_id) {
DCHECK(context_id > NONE && context_id < NUM_CONTEXTS); DCHECK(context_id > kNone && context_id < kNumContexts);
if (curr_context_id_ == context_id) if (curr_context_id_ == context_id)
return true; return true;
auto& context = contexts_[context_id]; auto& context = contexts_[context_id];
...@@ -49,6 +52,7 @@ bool GraphicsDelegate::MakeContextCurrent(ContextId context_id) { ...@@ -49,6 +52,7 @@ bool GraphicsDelegate::MakeContextCurrent(ContextId context_id) {
LOG(ERROR) << "gl::GLContext::MakeCurrent() failed"; LOG(ERROR) << "gl::GLContext::MakeCurrent() failed";
return false; return false;
} }
curr_context_id_ = context_id;
return true; return true;
} }
......
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_GRAPHICS_DELEGATE_H_ #ifndef CHROME_BROWSER_VR_BASE_COMPOSITOR_DELEGATE_H_
#define CHROME_BROWSER_VR_GRAPHICS_DELEGATE_H_ #define CHROME_BROWSER_VR_BASE_COMPOSITOR_DELEGATE_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "chrome/browser/vr/vr_export.h" #include "chrome/browser/vr/compositor_delegate.h"
#include "ui/gfx/native_widget_types.h"
namespace gl { namespace gl {
class GLContext; class GLContext;
...@@ -18,27 +17,28 @@ class GLSurface; ...@@ -18,27 +17,28 @@ class GLSurface;
namespace vr { namespace vr {
class VR_EXPORT GraphicsDelegate { class VR_EXPORT BaseCompositorDelegate : public CompositorDelegate {
public: public:
explicit GraphicsDelegate(const scoped_refptr<gl::GLSurface>& surface); BaseCompositorDelegate();
~GraphicsDelegate(); ~BaseCompositorDelegate() override;
bool Initialize();
bool MakeMainContextCurrent(); // CompositorDelegate implementation.
bool MakeSkiaContextCurrent(); bool Initialize(const scoped_refptr<gl::GLSurface>& surface) override;
bool RunInSkiaContext(SkiaContextCallback callback) override;
private: private:
enum ContextId { NONE = -1, MAIN_CONTEXT, SKIA_CONTEXT, NUM_CONTEXTS }; enum ContextId { kNone = -1, kMainContext, kSkiaContext, kNumContexts };
bool MakeContextCurrent(ContextId context_id); bool MakeContextCurrent(ContextId context_id);
scoped_refptr<gl::GLSurface> surface_; scoped_refptr<gl::GLSurface> surface_;
scoped_refptr<gl::GLShareGroup> share_group_; scoped_refptr<gl::GLShareGroup> share_group_;
scoped_refptr<gl::GLContext> contexts_[NUM_CONTEXTS]; scoped_refptr<gl::GLContext> contexts_[kNumContexts];
ContextId curr_context_id_ = NONE; ContextId curr_context_id_ = kNone;
DISALLOW_COPY_AND_ASSIGN(GraphicsDelegate); DISALLOW_COPY_AND_ASSIGN(BaseCompositorDelegate);
}; };
} // namespace vr } // namespace vr
#endif // CHROME_BROWSER_VR_GRAPHICS_DELEGATE_H_ #endif // CHROME_BROWSER_VR_BASE_COMPOSITOR_DELEGATE_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_COMPOSITOR_DELEGATE_H_
#define CHROME_BROWSER_VR_COMPOSITOR_DELEGATE_H_
#include "chrome/browser/vr/vr_export.h"
namespace gl {
class GLSurface;
} // namespace gl
namespace vr {
class VR_EXPORT CompositorDelegate {
public:
typedef base::OnceCallback<void()> SkiaContextCallback;
virtual ~CompositorDelegate() {}
// These methods return true when succeeded.
virtual bool Initialize(const scoped_refptr<gl::GLSurface>& surface) = 0;
virtual bool RunInSkiaContext(SkiaContextCallback callback) = 0;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_COMPOSITOR_DELEGATE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/vr/elements/content_element.h" #include "chrome/browser/vr/elements/platform_ui_element.h"
#include "chrome/browser/vr/platform_ui_input_delegate.h" #include "chrome/browser/vr/platform_ui_input_delegate.h"
#include "chrome/browser/vr/ui_element_renderer.h" #include "chrome/browser/vr/ui_element_renderer.h"
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/common/trace_event_common.h" #include "base/trace_event/common/trace_event_common.h"
#include "chrome/browser/vr/compositor_delegate.h"
#include "chrome/browser/vr/controller_delegate_for_testing.h" #include "chrome/browser/vr/controller_delegate_for_testing.h"
#include "chrome/browser/vr/graphics_delegate.h"
#include "chrome/browser/vr/input_event.h" #include "chrome/browser/vr/input_event.h"
#include "chrome/browser/vr/model/controller_model.h" #include "chrome/browser/vr/model/controller_model.h"
#include "chrome/browser/vr/model/reticle_model.h" #include "chrome/browser/vr/model/reticle_model.h"
...@@ -22,9 +22,11 @@ namespace vr { ...@@ -22,9 +22,11 @@ namespace vr {
RenderLoop::RenderLoop(std::unique_ptr<UiInterface> ui, RenderLoop::RenderLoop(std::unique_ptr<UiInterface> ui,
RenderLoopBrowserInterface* browser, RenderLoopBrowserInterface* browser,
CompositorDelegate* compositor_delegate,
size_t sliding_time_size) size_t sliding_time_size)
: ui_(std::move(ui)), : ui_(std::move(ui)),
browser_(browser), browser_(browser),
compositor_delegate_(compositor_delegate),
ui_processing_time_(sliding_time_size), ui_processing_time_(sliding_time_size),
ui_controller_update_time_(sliding_time_size) {} ui_controller_update_time_(sliding_time_size) {}
RenderLoop::~RenderLoop() = default; RenderLoop::~RenderLoop() = default;
...@@ -53,7 +55,6 @@ void RenderLoop::UpdateUi(const RenderInfo& render_info, ...@@ -53,7 +55,6 @@ void RenderLoop::UpdateUi(const RenderInfo& render_info,
base::TimeTicks current_time, base::TimeTicks current_time,
FrameType frame_type) { FrameType frame_type) {
TRACE_EVENT0("gpu", __func__); TRACE_EVENT0("gpu", __func__);
DCHECK(graphics_delegate_);
// Update the render position of all UI elements. // Update the render position of all UI elements.
base::TimeTicks timing_start = base::TimeTicks::Now(); base::TimeTicks timing_start = base::TimeTicks::Now();
...@@ -65,12 +66,8 @@ void RenderLoop::UpdateUi(const RenderInfo& render_info, ...@@ -65,12 +66,8 @@ void RenderLoop::UpdateUi(const RenderInfo& render_info,
controller_time = ProcessControllerInput(render_info, current_time); controller_time = ProcessControllerInput(render_info, current_time);
if (ui_->SceneHasDirtyTextures()) { if (ui_->SceneHasDirtyTextures()) {
if (!graphics_delegate_->MakeSkiaContextCurrent()) { if (!compositor_delegate_->RunInSkiaContext(base::BindOnce(
ForceExitVr(); &UiInterface::UpdateSceneTextures, base::Unretained(ui_.get())))) {
return;
}
ui_->UpdateSceneTextures();
if (!graphics_delegate_->MakeMainContextCurrent()) {
ForceExitVr(); ForceExitVr();
return; return;
} }
......
...@@ -21,7 +21,7 @@ class TimeTicks; ...@@ -21,7 +21,7 @@ class TimeTicks;
namespace vr { namespace vr {
enum class VrUiTestActivityResult; enum class VrUiTestActivityResult;
class GraphicsDelegate; class CompositorDelegate;
class RenderLoopBrowserInterface; class RenderLoopBrowserInterface;
class UiInterface; class UiInterface;
struct ControllerTestInput; struct ControllerTestInput;
...@@ -40,6 +40,7 @@ class VR_EXPORT RenderLoop { ...@@ -40,6 +40,7 @@ class VR_EXPORT RenderLoop {
explicit RenderLoop(std::unique_ptr<UiInterface> ui, explicit RenderLoop(std::unique_ptr<UiInterface> ui,
RenderLoopBrowserInterface* browser, RenderLoopBrowserInterface* browser,
CompositorDelegate* compositor_delegate,
size_t sliding_time_size); size_t sliding_time_size);
virtual ~RenderLoop(); virtual ~RenderLoop();
...@@ -73,7 +74,6 @@ class VR_EXPORT RenderLoop { ...@@ -73,7 +74,6 @@ class VR_EXPORT RenderLoop {
} }
std::unique_ptr<UiInterface> ui_; std::unique_ptr<UiInterface> ui_;
std::unique_ptr<GraphicsDelegate> graphics_delegate_;
private: private:
base::TimeDelta ProcessControllerInput(const RenderInfo& render_info, base::TimeDelta ProcessControllerInput(const RenderInfo& render_info,
...@@ -85,6 +85,7 @@ class VR_EXPORT RenderLoop { ...@@ -85,6 +85,7 @@ class VR_EXPORT RenderLoop {
RenderLoopBrowserInterface* browser_; RenderLoopBrowserInterface* browser_;
CompositorDelegate* compositor_delegate_;
std::unique_ptr<ControllerDelegate> controller_delegate_; std::unique_ptr<ControllerDelegate> controller_delegate_;
std::unique_ptr<ControllerDelegate> controller_delegate_for_testing_; std::unique_ptr<ControllerDelegate> controller_delegate_for_testing_;
bool using_controller_delegate_for_testing_ = false; bool using_controller_delegate_for_testing_ = false;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "chrome/browser/vr/test/gl_test_environment.h" #include "chrome/browser/vr/test/gl_test_environment.h"
#include "chrome/browser/vr/graphics_delegate.h" #include "chrome/browser/vr/base_compositor_delegate.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
#include "ui/gl/init/gl_factory.h" #include "ui/gl/init/gl_factory.h"
#include "ui/gl/test/gl_image_test_support.h" #include "ui/gl/test/gl_image_test_support.h"
...@@ -16,8 +16,8 @@ GlTestEnvironment::GlTestEnvironment(const gfx::Size frame_buffer_size) { ...@@ -16,8 +16,8 @@ GlTestEnvironment::GlTestEnvironment(const gfx::Size frame_buffer_size) {
// Setup offscreen GL context. // Setup offscreen GL context.
gl::GLImageTestSupport::InitializeGL(base::nullopt); gl::GLImageTestSupport::InitializeGL(base::nullopt);
surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
graphics_delegate_ = std::make_unique<GraphicsDelegate>(surface_); compositor_delegate_ = std::make_unique<BaseCompositorDelegate>();
if (!graphics_delegate_->Initialize()) if (!compositor_delegate_->Initialize(surface_))
return; return;
if (gl::GLContext::GetCurrent()->GetVersionInfo()->IsAtLeastGL(3, 3)) { if (gl::GLContext::GetCurrent()->GetVersionInfo()->IsAtLeastGL(3, 3)) {
...@@ -36,7 +36,7 @@ GlTestEnvironment::~GlTestEnvironment() { ...@@ -36,7 +36,7 @@ GlTestEnvironment::~GlTestEnvironment() {
if (vao_) { if (vao_) {
glDeleteVertexArraysOES(1, &vao_); glDeleteVertexArraysOES(1, &vao_);
} }
graphics_delegate_.reset(); compositor_delegate_.reset();
surface_ = nullptr; surface_ = nullptr;
gl::GLImageTestSupport::CleanupGL(); gl::GLImageTestSupport::CleanupGL();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
namespace vr { namespace vr {
class GraphicsDelegate; class CompositorDelegate;
class GlTestEnvironment { class GlTestEnvironment {
public: public:
...@@ -25,7 +25,7 @@ class GlTestEnvironment { ...@@ -25,7 +25,7 @@ class GlTestEnvironment {
private: private:
scoped_refptr<gl::GLSurface> surface_; scoped_refptr<gl::GLSurface> surface_;
std::unique_ptr<GraphicsDelegate> graphics_delegate_; std::unique_ptr<CompositorDelegate> compositor_delegate_;
GLuint vao_ = 0; GLuint vao_ = 0;
GLuint frame_buffer_ = 0; GLuint frame_buffer_ = 0;
}; };
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#include "chrome/browser/vr/testapp/gl_renderer.h" #include "chrome/browser/vr/testapp/gl_renderer.h"
#include <memory>
#include <utility>
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/vr/graphics_delegate.h" #include "chrome/browser/vr/base_compositor_delegate.h"
#include "chrome/browser/vr/testapp/vr_test_context.h" #include "chrome/browser/vr/testapp/vr_test_context.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
...@@ -37,12 +40,13 @@ GlRenderer::GlRenderer(const scoped_refptr<gl::GLSurface>& surface, ...@@ -37,12 +40,13 @@ GlRenderer::GlRenderer(const scoped_refptr<gl::GLSurface>& surface,
GlRenderer::~GlRenderer() {} GlRenderer::~GlRenderer() {}
bool GlRenderer::Initialize() { bool GlRenderer::Initialize() {
auto graphics_delegate = std::make_unique<GraphicsDelegate>(surface_); std::unique_ptr<CompositorDelegate> compositor_delegate =
if (!graphics_delegate->Initialize()) { std::make_unique<BaseCompositorDelegate>();
if (!compositor_delegate->Initialize(surface_)) {
return false; return false;
} }
vr_->OnGlInitialized(std::move(graphics_delegate)); vr_->OnGlInitialized(std::move(compositor_delegate));
PostRenderFrameTask(gfx::SwapResult::SWAP_ACK); PostRenderFrameTask(gfx::SwapResult::SWAP_ACK);
return true; return true;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "chrome/browser/vr/testapp/vr_test_context.h" #include "chrome/browser/vr/testapp/vr_test_context.h"
#include <memory> #include <memory>
#include <utility>
#include <vector>
#include "base/i18n/icu_util.h" #include "base/i18n/icu_util.h"
#include "base/numerics/ranges.h" #include "base/numerics/ranges.h"
...@@ -13,8 +15,8 @@ ...@@ -13,8 +15,8 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/version.h" #include "base/version.h"
#include "chrome/browser/vr/assets_load_status.h" #include "chrome/browser/vr/assets_load_status.h"
#include "chrome/browser/vr/compositor_delegate.h"
#include "chrome/browser/vr/gl_texture_location.h" #include "chrome/browser/vr/gl_texture_location.h"
#include "chrome/browser/vr/graphics_delegate.h"
#include "chrome/browser/vr/model/assets.h" #include "chrome/browser/vr/model/assets.h"
#include "chrome/browser/vr/model/model.h" #include "chrome/browser/vr/model/model.h"
#include "chrome/browser/vr/model/omnibox_suggestions.h" #include "chrome/browser/vr/model/omnibox_suggestions.h"
...@@ -171,9 +173,8 @@ void VrTestContext::DrawFrame() { ...@@ -171,9 +173,8 @@ void VrTestContext::DrawFrame() {
UpdateController(render_info, current_time); UpdateController(render_info, current_time);
graphics_delegate_->MakeSkiaContextCurrent(); compositor_delegate_->RunInSkiaContext(
ui_->UpdateSceneTextures(); base::BindOnce(&UiInterface::UpdateSceneTextures, base::Unretained(ui_)));
graphics_delegate_->MakeMainContextCurrent();
auto load_progress = (current_time - page_load_start_).InMilliseconds() / auto load_progress = (current_time - page_load_start_).InMilliseconds() /
kPageLoadTimeMilliseconds; kPageLoadTimeMilliseconds;
...@@ -455,8 +456,8 @@ ControllerModel VrTestContext::UpdateController(const RenderInfo& render_info, ...@@ -455,8 +456,8 @@ ControllerModel VrTestContext::UpdateController(const RenderInfo& render_info,
} }
void VrTestContext::OnGlInitialized( void VrTestContext::OnGlInitialized(
std::unique_ptr<GraphicsDelegate> graphics_delegate) { std::unique_ptr<CompositorDelegate> compositor_delegate) {
graphics_delegate_ = std::move(graphics_delegate); compositor_delegate_ = std::move(compositor_delegate);
unsigned int content_texture_id = CreateTexture(0xFF000080); unsigned int content_texture_id = CreateTexture(0xFF000080);
unsigned int ui_texture_id = CreateTexture(0xFF008000); unsigned int ui_texture_id = CreateTexture(0xFF008000);
......
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
#ifndef CHROME_BROWSER_VR_TESTAPP_VR_TEST_CONTEXT_H_ #ifndef CHROME_BROWSER_VR_TESTAPP_VR_TEST_CONTEXT_H_
#define CHROME_BROWSER_VR_TESTAPP_VR_TEST_CONTEXT_H_ #define CHROME_BROWSER_VR_TESTAPP_VR_TEST_CONTEXT_H_
#include "base/macros.h" #include <memory>
#include <cstdint>
#include <queue> #include <queue>
#include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/vr/content_input_delegate.h" #include "chrome/browser/vr/content_input_delegate.h"
#include "chrome/browser/vr/model/controller_model.h" #include "chrome/browser/vr/model/controller_model.h"
...@@ -24,7 +23,7 @@ class Event; ...@@ -24,7 +23,7 @@ class Event;
namespace vr { namespace vr {
class GraphicsDelegate; class CompositorDelegate;
class TextInputDelegate; class TextInputDelegate;
class TestKeyboardDelegate; class TestKeyboardDelegate;
class Ui; class Ui;
...@@ -37,7 +36,7 @@ class VrTestContext : public vr::UiBrowserInterface { ...@@ -37,7 +36,7 @@ class VrTestContext : public vr::UiBrowserInterface {
VrTestContext(); VrTestContext();
~VrTestContext() override; ~VrTestContext() override;
void OnGlInitialized(std::unique_ptr<GraphicsDelegate> graphics_delegate); void OnGlInitialized(std::unique_ptr<CompositorDelegate> compositor_delegate);
// TODO(vollick): we should refactor VrShellGl's rendering logic and use it // TODO(vollick): we should refactor VrShellGl's rendering logic and use it
// directly. crbug.com/767282 // directly. crbug.com/767282
void DrawFrame(); void DrawFrame();
...@@ -121,7 +120,7 @@ class VrTestContext : public vr::UiBrowserInterface { ...@@ -121,7 +120,7 @@ class VrTestContext : public vr::UiBrowserInterface {
std::unique_ptr<TextInputDelegate> text_input_delegate_; std::unique_ptr<TextInputDelegate> text_input_delegate_;
std::unique_ptr<TestKeyboardDelegate> keyboard_delegate_; std::unique_ptr<TestKeyboardDelegate> keyboard_delegate_;
std::unique_ptr<GraphicsDelegate> graphics_delegate_; std::unique_ptr<CompositorDelegate> compositor_delegate_;
PlatformController::Handedness handedness_ = PlatformController::kRightHanded; PlatformController::Handedness handedness_ = PlatformController::kRightHanded;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment