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(
limits.start_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(),
gpu::kNullSurfaceHandle, attributes, limits, nullptr,
nullptr, nullptr, nullptr);
......
......@@ -47,7 +47,7 @@ std::unique_ptr<gpu::GLInProcessContext> CreateGLInProcessContext(
attribs.bind_generates_resource = false;
attribs.enable_oop_rasterization = oop_raster;
auto context = gpu::GLInProcessContext::CreateWithoutInit();
auto context = std::make_unique<gpu::GLInProcessContext>();
auto result = context->Initialize(
nullptr, nullptr, is_offscreen, gpu::kNullSurfaceHandle, attribs,
gpu::SharedMemoryLimits(), gpu_memory_buffer_manager, image_factory,
......
......@@ -66,7 +66,7 @@ class GLHelperBenchmark : public testing::Test {
attributes.bind_generates_resource = false;
attributes.gpu_preference = gl::PreferDiscreteGpu;
context_ = gpu::GLInProcessContext::CreateWithoutInit();
context_ = std::make_unique<gpu::GLInProcessContext>();
auto result =
context_->Initialize(nullptr, /* service */
nullptr, /* surface */
......
......@@ -64,7 +64,7 @@ class GLHelperTest : public testing::Test {
attributes.sample_buffers = 1;
attributes.bind_generates_resource = false;
context_ = gpu::GLInProcessContext::CreateWithoutInit();
context_ = std::make_unique<gpu::GLInProcessContext>();
auto result =
context_->Initialize(nullptr, /* service */
nullptr, /* surface */
......
......@@ -43,7 +43,7 @@ class YUVReadbackTest : public testing::Test {
attributes.sample_buffers = 1;
attributes.bind_generates_resource = false;
context_ = gpu::GLInProcessContext::CreateWithoutInit();
context_ = std::make_unique<gpu::GLInProcessContext>();
auto result =
context_->Initialize(nullptr, /* service */
nullptr, /* surface */
......
......@@ -58,7 +58,7 @@ VizProcessContextProvider::VizProcessContextProvider(
gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
const gpu::SharedMemoryLimits& limits)
: attributes_(CreateAttributes()),
context_(gpu::GLInProcessContext::CreateWithoutInit()),
context_(std::make_unique<gpu::GLInProcessContext>()),
context_result_(
context_->Initialize(std::move(service),
nullptr,
......@@ -133,15 +133,6 @@ void VizProcessContextProvider::AddObserver(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(
const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback) {
......
......@@ -62,8 +62,6 @@ class VIZ_SERVICE_EXPORT VizProcessContextProvider
void AddObserver(ContextLostObserver* obs) override;
void RemoveObserver(ContextLostObserver* obs) override;
uint32_t GetCopyTextureInternalFormat();
void SetUpdateVSyncParametersCallback(
const gpu::InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback);
......
......@@ -34,7 +34,7 @@ class ContextTestBase : public testing::Test {
attributes.sample_buffers = 1;
attributes.bind_generates_resource = false;
auto context = gpu::GLInProcessContext::CreateWithoutInit();
auto context = std::make_unique<gpu::GLInProcessContext>();
auto result = context->Initialize(
nullptr, /* service */
nullptr, /* surface */
......
......@@ -11,12 +11,10 @@
#include <GLES2/gl2ext.h>
#include <GLES2/gl2extchromium.h>
#include <memory>
#include <utility>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
......@@ -34,47 +32,9 @@
namespace gpu {
namespace {
class GLInProcessContextImpl
: 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() {
GLInProcessContext::GLInProcessContext() = default;
GLInProcessContext::~GLInProcessContext() {
if (gles2_implementation_) {
// First flush the context to ensure that any pending frees of resources
// are completed. Otherwise, if this context is part of a share group,
......@@ -91,28 +51,24 @@ GLInProcessContextImpl::~GLInProcessContextImpl() {
command_buffer_.reset();
}
const Capabilities& GLInProcessContextImpl::GetCapabilities() const {
const Capabilities& GLInProcessContext::GetCapabilities() const {
return command_buffer_->GetCapabilities();
}
const GpuFeatureInfo& GLInProcessContextImpl::GetGpuFeatureInfo() const {
const GpuFeatureInfo& GLInProcessContext::GetGpuFeatureInfo() const {
return command_buffer_->GetGpuFeatureInfo();
}
gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() {
gles2::GLES2Implementation* GLInProcessContext::GetImplementation() {
return gles2_implementation_.get();
}
void GLInProcessContextImpl::SetUpdateVSyncParametersCallback(
void GLInProcessContext::SetUpdateVSyncParametersCallback(
const InProcessCommandBuffer::UpdateVSyncParametersCallback& callback) {
command_buffer_->SetUpdateVSyncParametersCallback(callback);
}
void GLInProcessContextImpl::SetLock(base::Lock* lock) {
NOTREACHED();
}
ContextResult GLInProcessContextImpl::Initialize(
ContextResult GLInProcessContext::Initialize(
scoped_refptr<InProcessCommandBuffer::Service> service,
scoped_refptr<gl::GLSurface> surface,
bool is_offscreen,
......@@ -172,11 +128,4 @@ ContextResult GLInProcessContextImpl::Initialize(
return result;
}
} // anonymous namespace
// static
std::unique_ptr<GLInProcessContext> GLInProcessContext::CreateWithoutInit() {
return std::make_unique<GLInProcessContextImpl>();
}
} // namespace gpu
......@@ -15,20 +15,21 @@
#include "ui/gl/gl_surface.h"
namespace gpu {
class TransferBuffer;
struct GpuFeatureInfo;
struct SharedMemoryLimits;
namespace gles2 {
class GLES2CmdHelper;
class GLES2Implementation;
}
// Wraps everything needed to use an in process GL context.
class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
public:
virtual ~GLInProcessContext() = default;
// TODO(danakj): Devirtualize this class and remove this, just call the
// constructor.
static std::unique_ptr<GLInProcessContext> CreateWithoutInit();
// You must call Initialize() before using the context.
GLInProcessContext();
~GLInProcessContext();
// Initialize the GLInProcessContext, if |is_offscreen| is true, renders to an
// offscreen context. |attrib_list| must be null or a NONE-terminated list
......@@ -39,7 +40,7 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
// not thread safe. If |surface| is null, then the other parameters are used
// to correctly create a surface.
// |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<gl::GLSurface> surface,
bool is_offscreen,
......@@ -49,20 +50,25 @@ class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
GpuMemoryBufferManager* gpu_memory_buffer_manager,
ImageFactory* image_factory,
GpuChannelManagerDelegate* gpu_channel_manager_delegate,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) = 0;
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
virtual const Capabilities& GetCapabilities() const = 0;
virtual const GpuFeatureInfo& GetGpuFeatureInfo() const = 0;
const Capabilities& GetCapabilities() const;
const GpuFeatureInfo& GetGpuFeatureInfo() const;
// Allows direct access to the GLES2 implementation so a GLInProcessContext
// 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(
const InProcessCommandBuffer::UpdateVSyncParametersCallback&
callback) = 0;
DISALLOW_COPY_AND_ASSIGN(GLInProcessContext);
};
} // namespace gpu
......
......@@ -96,7 +96,7 @@ gpu::ContextResult InProcessContextProvider::BindToCurrentThread() {
return bind_result_;
bind_tried_ = true;
context_ = gpu::GLInProcessContext::CreateWithoutInit();
context_ = std::make_unique<gpu::GLInProcessContext>();
bind_result_ = context_->Initialize(
nullptr, /* service */
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