Commit e24532bb authored by kylechar's avatar kylechar Committed by Commit Bot

Devirtualize GLInProcessContext.

There is only one implementation so there doesn't need to be a virtual
base class. Also remove some unused functions.

Bug: 832243
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I581d47639448efa4a0812f604808a03587269320
Reviewed-on: https://chromium-review.googlesource.com/1119122
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572234}
parent bef7bd02
...@@ -65,7 +65,7 @@ AwRenderThreadContextProvider::AwRenderThreadContextProvider( ...@@ -65,7 +65,7 @@ AwRenderThreadContextProvider::AwRenderThreadContextProvider(
limits.start_transfer_buffer_size = 64 * 1024; limits.start_transfer_buffer_size = 64 * 1024;
limits.min_transfer_buffer_size = 64 * 1024; limits.min_transfer_buffer_size = 64 * 1024;
context_ = gpu::GLInProcessContext::CreateWithoutInit(); context_ = std::make_unique<gpu::GLInProcessContext>();
context_->Initialize(service, surface, surface->IsOffscreen(), context_->Initialize(service, surface, surface->IsOffscreen(),
gpu::kNullSurfaceHandle, attributes, limits, nullptr, gpu::kNullSurfaceHandle, attributes, limits, nullptr,
nullptr, nullptr, nullptr); nullptr, nullptr, nullptr);
......
...@@ -47,7 +47,7 @@ std::unique_ptr<gpu::GLInProcessContext> CreateGLInProcessContext( ...@@ -47,7 +47,7 @@ std::unique_ptr<gpu::GLInProcessContext> CreateGLInProcessContext(
attribs.bind_generates_resource = false; attribs.bind_generates_resource = false;
attribs.enable_oop_rasterization = oop_raster; attribs.enable_oop_rasterization = oop_raster;
auto context = gpu::GLInProcessContext::CreateWithoutInit(); auto context = std::make_unique<gpu::GLInProcessContext>();
auto result = context->Initialize( auto result = context->Initialize(
nullptr, nullptr, is_offscreen, gpu::kNullSurfaceHandle, attribs, nullptr, nullptr, is_offscreen, gpu::kNullSurfaceHandle, attribs,
gpu::SharedMemoryLimits(), gpu_memory_buffer_manager, image_factory, gpu::SharedMemoryLimits(), gpu_memory_buffer_manager, image_factory,
......
...@@ -66,7 +66,7 @@ class GLHelperBenchmark : public testing::Test { ...@@ -66,7 +66,7 @@ class GLHelperBenchmark : public testing::Test {
attributes.bind_generates_resource = false; attributes.bind_generates_resource = false;
attributes.gpu_preference = gl::PreferDiscreteGpu; attributes.gpu_preference = gl::PreferDiscreteGpu;
context_ = gpu::GLInProcessContext::CreateWithoutInit(); context_ = std::make_unique<gpu::GLInProcessContext>();
auto result = auto result =
context_->Initialize(nullptr, /* service */ context_->Initialize(nullptr, /* service */
nullptr, /* surface */ nullptr, /* surface */
......
...@@ -64,7 +64,7 @@ class GLHelperTest : public testing::Test { ...@@ -64,7 +64,7 @@ class GLHelperTest : public testing::Test {
attributes.sample_buffers = 1; attributes.sample_buffers = 1;
attributes.bind_generates_resource = false; attributes.bind_generates_resource = false;
context_ = gpu::GLInProcessContext::CreateWithoutInit(); context_ = std::make_unique<gpu::GLInProcessContext>();
auto result = auto result =
context_->Initialize(nullptr, /* service */ context_->Initialize(nullptr, /* service */
nullptr, /* surface */ nullptr, /* surface */
......
...@@ -43,7 +43,7 @@ class YUVReadbackTest : public testing::Test { ...@@ -43,7 +43,7 @@ class YUVReadbackTest : public testing::Test {
attributes.sample_buffers = 1; attributes.sample_buffers = 1;
attributes.bind_generates_resource = false; attributes.bind_generates_resource = false;
context_ = gpu::GLInProcessContext::CreateWithoutInit(); context_ = std::make_unique<gpu::GLInProcessContext>();
auto result = auto result =
context_->Initialize(nullptr, /* service */ context_->Initialize(nullptr, /* service */
nullptr, /* surface */ nullptr, /* surface */
......
...@@ -58,7 +58,7 @@ VizProcessContextProvider::VizProcessContextProvider( ...@@ -58,7 +58,7 @@ VizProcessContextProvider::VizProcessContextProvider(
gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate, gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
const gpu::SharedMemoryLimits& limits) const gpu::SharedMemoryLimits& limits)
: attributes_(CreateAttributes()), : attributes_(CreateAttributes()),
context_(gpu::GLInProcessContext::CreateWithoutInit()), context_(std::make_unique<gpu::GLInProcessContext>()),
context_result_( context_result_(
context_->Initialize(std::move(service), context_->Initialize(std::move(service),
nullptr, nullptr,
...@@ -133,15 +133,6 @@ void VizProcessContextProvider::AddObserver(ContextLostObserver* obs) {} ...@@ -133,15 +133,6 @@ void VizProcessContextProvider::AddObserver(ContextLostObserver* obs) {}
void VizProcessContextProvider::RemoveObserver(ContextLostObserver* obs) {} void VizProcessContextProvider::RemoveObserver(ContextLostObserver* obs) {}
uint32_t VizProcessContextProvider::GetCopyTextureInternalFormat() {
if (attributes_.alpha_size > 0)
return GL_RGBA;
DCHECK_NE(attributes_.red_size, 0);
DCHECK_NE(attributes_.green_size, 0);
DCHECK_NE(attributes_.blue_size, 0);
return GL_RGB;
}
void VizProcessContextProvider::SetUpdateVSyncParametersCallback( void VizProcessContextProvider::SetUpdateVSyncParametersCallback(
const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback& const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback) { callback) {
......
...@@ -62,8 +62,6 @@ class VIZ_SERVICE_EXPORT VizProcessContextProvider ...@@ -62,8 +62,6 @@ class VIZ_SERVICE_EXPORT VizProcessContextProvider
void AddObserver(ContextLostObserver* obs) override; void AddObserver(ContextLostObserver* obs) override;
void RemoveObserver(ContextLostObserver* obs) override; void RemoveObserver(ContextLostObserver* obs) override;
uint32_t GetCopyTextureInternalFormat();
void SetUpdateVSyncParametersCallback( void SetUpdateVSyncParametersCallback(
const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback& const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback); callback);
......
...@@ -34,7 +34,7 @@ class ContextTestBase : public testing::Test { ...@@ -34,7 +34,7 @@ class ContextTestBase : public testing::Test {
attributes.sample_buffers = 1; attributes.sample_buffers = 1;
attributes.bind_generates_resource = false; attributes.bind_generates_resource = false;
auto context = gpu::GLInProcessContext::CreateWithoutInit(); auto context = std::make_unique<gpu::GLInProcessContext>();
auto result = context->Initialize( auto result = context->Initialize(
nullptr, /* service */ nullptr, /* service */
nullptr, /* surface */ nullptr, /* surface */
......
...@@ -11,12 +11,10 @@ ...@@ -11,12 +11,10 @@
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include <GLES2/gl2extchromium.h> #include <GLES2/gl2extchromium.h>
#include <memory>
#include <utility> #include <utility>
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/shared_memory_limits.h" #include "gpu/command_buffer/client/shared_memory_limits.h"
...@@ -34,47 +32,9 @@ ...@@ -34,47 +32,9 @@
namespace gpu { namespace gpu {
namespace { GLInProcessContext::GLInProcessContext() = default;
class GLInProcessContextImpl GLInProcessContext::~GLInProcessContext() {
: public GLInProcessContext,
public base::SupportsWeakPtr<GLInProcessContextImpl> {
public:
GLInProcessContextImpl();
~GLInProcessContextImpl() override;
// GLInProcessContext implementation:
ContextResult Initialize(
scoped_refptr<InProcessCommandBuffer::Service> service,
scoped_refptr<gl::GLSurface> surface,
bool is_offscreen,
SurfaceHandle window,
const ContextCreationAttribs& attribs,
const SharedMemoryLimits& mem_limits,
GpuMemoryBufferManager* gpu_memory_buffer_manager,
ImageFactory* image_factory,
GpuChannelManagerDelegate* gpu_channel_manager_delegate,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
const Capabilities& GetCapabilities() const override;
const GpuFeatureInfo& GetGpuFeatureInfo() const override;
gles2::GLES2Implementation* GetImplementation() override;
void SetUpdateVSyncParametersCallback(
const InProcessCommandBuffer::UpdateVSyncParametersCallback& callback)
override;
void SetLock(base::Lock* lock) override;
private:
std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_;
std::unique_ptr<TransferBuffer> transfer_buffer_;
std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_;
std::unique_ptr<InProcessCommandBuffer> command_buffer_;
DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl);
};
GLInProcessContextImpl::GLInProcessContextImpl() = default;
GLInProcessContextImpl::~GLInProcessContextImpl() {
if (gles2_implementation_) { if (gles2_implementation_) {
// First flush the context to ensure that any pending frees of resources // First flush the context to ensure that any pending frees of resources
// are completed. Otherwise, if this context is part of a share group, // are completed. Otherwise, if this context is part of a share group,
...@@ -91,28 +51,24 @@ GLInProcessContextImpl::~GLInProcessContextImpl() { ...@@ -91,28 +51,24 @@ GLInProcessContextImpl::~GLInProcessContextImpl() {
command_buffer_.reset(); command_buffer_.reset();
} }
const Capabilities& GLInProcessContextImpl::GetCapabilities() const { const Capabilities& GLInProcessContext::GetCapabilities() const {
return command_buffer_->GetCapabilities(); return command_buffer_->GetCapabilities();
} }
const GpuFeatureInfo& GLInProcessContextImpl::GetGpuFeatureInfo() const { const GpuFeatureInfo& GLInProcessContext::GetGpuFeatureInfo() const {
return command_buffer_->GetGpuFeatureInfo(); return command_buffer_->GetGpuFeatureInfo();
} }
gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { gles2::GLES2Implementation* GLInProcessContext::GetImplementation() {
return gles2_implementation_.get(); return gles2_implementation_.get();
} }
void GLInProcessContextImpl::SetUpdateVSyncParametersCallback( void GLInProcessContext::SetUpdateVSyncParametersCallback(
const InProcessCommandBuffer::UpdateVSyncParametersCallback& callback) { const InProcessCommandBuffer::UpdateVSyncParametersCallback& callback) {
command_buffer_->SetUpdateVSyncParametersCallback(callback); command_buffer_->SetUpdateVSyncParametersCallback(callback);
} }
void GLInProcessContextImpl::SetLock(base::Lock* lock) { ContextResult GLInProcessContext::Initialize(
NOTREACHED();
}
ContextResult GLInProcessContextImpl::Initialize(
scoped_refptr<InProcessCommandBuffer::Service> service, scoped_refptr<InProcessCommandBuffer::Service> service,
scoped_refptr<gl::GLSurface> surface, scoped_refptr<gl::GLSurface> surface,
bool is_offscreen, bool is_offscreen,
...@@ -172,11 +128,4 @@ ContextResult GLInProcessContextImpl::Initialize( ...@@ -172,11 +128,4 @@ ContextResult GLInProcessContextImpl::Initialize(
return result; return result;
} }
} // anonymous namespace
// static
std::unique_ptr<GLInProcessContext> GLInProcessContext::CreateWithoutInit() {
return std::make_unique<GLInProcessContextImpl>();
}
} // namespace gpu } // namespace gpu
...@@ -15,20 +15,21 @@ ...@@ -15,20 +15,21 @@
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
namespace gpu { namespace gpu {
class TransferBuffer;
struct GpuFeatureInfo; struct GpuFeatureInfo;
struct SharedMemoryLimits; struct SharedMemoryLimits;
namespace gles2 { namespace gles2 {
class GLES2CmdHelper;
class GLES2Implementation; class GLES2Implementation;
} }
// Wraps everything needed to use an in process GL context.
class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext { class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
public: public:
virtual ~GLInProcessContext() = default; // You must call Initialize() before using the context.
GLInProcessContext();
// TODO(danakj): Devirtualize this class and remove this, just call the ~GLInProcessContext();
// constructor.
static std::unique_ptr<GLInProcessContext> CreateWithoutInit();
// Initialize the GLInProcessContext, if |is_offscreen| is true, renders to an // Initialize the GLInProcessContext, if |is_offscreen| is true, renders to an
// offscreen context. |attrib_list| must be null or a NONE-terminated list // offscreen context. |attrib_list| must be null or a NONE-terminated list
...@@ -39,7 +40,7 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext { ...@@ -39,7 +40,7 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
// not thread safe. If |surface| is null, then the other parameters are used // not thread safe. If |surface| is null, then the other parameters are used
// to correctly create a surface. // to correctly create a surface.
// |gpu_channel_manager| should be non-null when used in the GPU process. // |gpu_channel_manager| should be non-null when used in the GPU process.
virtual ContextResult Initialize( ContextResult Initialize(
scoped_refptr<InProcessCommandBuffer::Service> service, scoped_refptr<InProcessCommandBuffer::Service> service,
scoped_refptr<gl::GLSurface> surface, scoped_refptr<gl::GLSurface> surface,
bool is_offscreen, bool is_offscreen,
...@@ -49,20 +50,25 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext { ...@@ -49,20 +50,25 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
GpuMemoryBufferManager* gpu_memory_buffer_manager, GpuMemoryBufferManager* gpu_memory_buffer_manager,
ImageFactory* image_factory, ImageFactory* image_factory,
GpuChannelManagerDelegate* gpu_channel_manager_delegate, GpuChannelManagerDelegate* gpu_channel_manager_delegate,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) = 0; scoped_refptr<base::SingleThreadTaskRunner> task_runner);
virtual const Capabilities& GetCapabilities() const = 0; const Capabilities& GetCapabilities() const;
virtual const GpuFeatureInfo& GetGpuFeatureInfo() const = 0; const GpuFeatureInfo& GetGpuFeatureInfo() const;
// Allows direct access to the GLES2 implementation so a GLInProcessContext // Allows direct access to the GLES2 implementation so a GLInProcessContext
// can be used without making it current. // can be used without making it current.
virtual gles2::GLES2Implementation* GetImplementation() = 0; gles2::GLES2Implementation* GetImplementation();
void SetUpdateVSyncParametersCallback(
const InProcessCommandBuffer::UpdateVSyncParametersCallback& callback);
virtual void SetLock(base::Lock* lock) = 0; private:
std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_;
std::unique_ptr<TransferBuffer> transfer_buffer_;
std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_;
std::unique_ptr<InProcessCommandBuffer> command_buffer_;
virtual void SetUpdateVSyncParametersCallback( DISALLOW_COPY_AND_ASSIGN(GLInProcessContext);
const InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback) = 0;
}; };
} // namespace gpu } // namespace gpu
......
...@@ -96,7 +96,7 @@ gpu::ContextResult InProcessContextProvider::BindToCurrentThread() { ...@@ -96,7 +96,7 @@ gpu::ContextResult InProcessContextProvider::BindToCurrentThread() {
return bind_result_; return bind_result_;
bind_tried_ = true; bind_tried_ = true;
context_ = gpu::GLInProcessContext::CreateWithoutInit(); context_ = std::make_unique<gpu::GLInProcessContext>();
bind_result_ = context_->Initialize( bind_result_ = context_->Initialize(
nullptr, /* service */ nullptr, /* service */
nullptr, /* surface */ nullptr, /* surface */
......
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