diff options
Diffstat (limited to 'chromium/mojo/gles2')
-rw-r--r-- | chromium/mojo/gles2/command_buffer_client_impl.cc | 35 | ||||
-rw-r--r-- | chromium/mojo/gles2/command_buffer_client_impl.h | 16 | ||||
-rw-r--r-- | chromium/mojo/gles2/gles2_context.cc | 30 | ||||
-rw-r--r-- | chromium/mojo/gles2/gles2_context.h | 15 | ||||
-rw-r--r-- | chromium/mojo/gles2/gles2_impl.cc | 2 |
5 files changed, 47 insertions, 51 deletions
diff --git a/chromium/mojo/gles2/command_buffer_client_impl.cc b/chromium/mojo/gles2/command_buffer_client_impl.cc index 14f0569ce14..1d78f850f5f 100644 --- a/chromium/mojo/gles2/command_buffer_client_impl.cc +++ b/chromium/mojo/gles2/command_buffer_client_impl.cc @@ -16,6 +16,7 @@ #include "components/mus/gles2/command_buffer_type_conversions.h" #include "components/mus/gles2/mojo_buffer_backing.h" #include "components/mus/gles2/mojo_gpu_memory_buffer.h" +#include "gpu/command_buffer/client/gpu_control_client.h" #include "gpu/command_buffer/common/command_buffer_id.h" #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/command_buffer/common/sync_token.h" @@ -61,15 +62,11 @@ void InitializeCallback(mus::mojom::CommandBufferInitializeResultPtr* output, } // namespace -CommandBufferDelegate::~CommandBufferDelegate() {} - -void CommandBufferDelegate::ContextLost() {} - CommandBufferClientImpl::CommandBufferClientImpl( - CommandBufferDelegate* delegate, const std::vector<int32_t>& attribs, mojo::ScopedMessagePipeHandle command_buffer_handle) - : delegate_(delegate), + : gpu_control_client_(nullptr), + destroyed_(false), attribs_(attribs), client_binding_(this), command_buffer_id_(), @@ -193,7 +190,7 @@ scoped_refptr<gpu::Buffer> CommandBufferClientImpl::CreateTransferBuffer( command_buffer_->RegisterTransferBuffer(*id, std::move(duped), static_cast<uint32_t>(size)); - scoped_ptr<gpu::BufferBacking> backing( + std::unique_ptr<gpu::BufferBacking> backing( new mus::MojoBufferBacking(std::move(handle), memory, size)); scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(std::move(backing))); return buffer; @@ -203,6 +200,10 @@ void CommandBufferClientImpl::DestroyTransferBuffer(int32_t id) { command_buffer_->DestroyTransferBuffer(id); } +void CommandBufferClientImpl::SetGpuControlClient(gpu::GpuControlClient* c) { + gpu_control_client_ = c; +} + gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { return capabilities_; } @@ -268,10 +269,11 @@ int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage( size_t height, unsigned internalformat, unsigned usage) { - scoped_ptr<gfx::GpuMemoryBuffer> buffer(mus::MojoGpuMemoryBufferImpl::Create( - gfx::Size(static_cast<int>(width), static_cast<int>(height)), - gpu::DefaultBufferFormatForImageFormat(internalformat), - gfx::BufferUsage::SCANOUT)); + std::unique_ptr<gfx::GpuMemoryBuffer> buffer( + mus::MojoGpuMemoryBufferImpl::Create( + gfx::Size(static_cast<int>(width), static_cast<int>(height)), + gpu::DefaultBufferFormatForImageFormat(internalformat), + gfx::BufferUsage::SCANOUT)); if (!buffer) return -1; @@ -285,10 +287,14 @@ void CommandBufferClientImpl::SignalQuery(uint32_t query, } void CommandBufferClientImpl::Destroyed(int32_t lost_reason, int32_t error) { + if (destroyed_) + return; last_state_.context_lost_reason = static_cast<gpu::error::ContextLostReason>(lost_reason); last_state_.error = static_cast<gpu::error::Error>(error); - delegate_->ContextLost(); + if (gpu_control_client_) + gpu_control_client_->OnGpuControlLostContext(); + destroyed_ = true; } void CommandBufferClientImpl::SignalAck(uint32_t id) { @@ -331,11 +337,6 @@ void CommandBufferClientImpl::MakeProgressAndUpdateState() { void CommandBufferClientImpl::SetLock(base::Lock* lock) { } -bool CommandBufferClientImpl::IsGpuChannelLost() { - // This is only possible for out-of-process command buffers. - return false; -} - void CommandBufferClientImpl::EnsureWorkVisible() { // This is only relevant for out-of-process command buffers. } diff --git a/chromium/mojo/gles2/command_buffer_client_impl.h b/chromium/mojo/gles2/command_buffer_client_impl.h index 995ff1c9511..45bcf402a0c 100644 --- a/chromium/mojo/gles2/command_buffer_client_impl.h +++ b/chromium/mojo/gles2/command_buffer_client_impl.h @@ -9,10 +9,10 @@ #include <stdint.h> #include <map> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "components/mus/public/interfaces/command_buffer.mojom.h" #include "gpu/command_buffer/client/gpu_control.h" #include "gpu/command_buffer/common/command_buffer.h" @@ -27,25 +27,18 @@ class RunLoop; namespace gles2 { class CommandBufferClientImpl; -class CommandBufferDelegate { - public: - virtual ~CommandBufferDelegate(); - virtual void ContextLost(); -}; - class CommandBufferClientImpl : public mus::mojom::CommandBufferClient, public gpu::CommandBuffer, public gpu::GpuControl { public: explicit CommandBufferClientImpl( - CommandBufferDelegate* delegate, const std::vector<int32_t>& attribs, mojo::ScopedMessagePipeHandle command_buffer_handle); ~CommandBufferClientImpl() override; + bool Initialize(); // CommandBuffer implementation: - bool Initialize() override; State GetLastState() override; int32_t GetLastToken() override; void Flush(int32_t put_offset) override; @@ -58,6 +51,7 @@ class CommandBufferClientImpl void DestroyTransferBuffer(int32_t id) override; // gpu::GpuControl implementation: + void SetGpuControlClient(gpu::GpuControlClient*) override; gpu::Capabilities GetCapabilities() override; int32_t CreateImage(ClientBuffer buffer, size_t width, @@ -70,7 +64,6 @@ class CommandBufferClientImpl unsigned usage) override; void SignalQuery(uint32_t query, const base::Closure& callback) override; void SetLock(base::Lock*) override; - bool IsGpuChannelLost() override; void EnsureWorkVisible() override; gpu::CommandBufferNamespace GetNamespaceID() const override; gpu::CommandBufferId GetCommandBufferID() const override; @@ -96,7 +89,8 @@ class CommandBufferClientImpl gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } - CommandBufferDelegate* delegate_; + gpu::GpuControlClient* gpu_control_client_; + bool destroyed_; std::vector<int32_t> attribs_; mojo::Binding<mus::mojom::CommandBufferClient> client_binding_; mus::mojom::CommandBufferPtr command_buffer_; diff --git a/chromium/mojo/gles2/gles2_context.cc b/chromium/mojo/gles2/gles2_context.cc index 90ba14e8c95..8159407b87f 100644 --- a/chromium/mojo/gles2/gles2_context.cc +++ b/chromium/mojo/gles2/gles2_context.cc @@ -11,24 +11,18 @@ #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_implementation.h" +#include "gpu/command_buffer/client/shared_memory_limits.h" #include "gpu/command_buffer/client/transfer_buffer.h" #include "mojo/public/c/gles2/gles2.h" #include "mojo/public/cpp/system/core.h" namespace gles2 { -namespace { -const size_t kDefaultCommandBufferSize = 1024 * 1024; -const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; -const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; -const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; -} - GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, mojo::ScopedMessagePipeHandle command_buffer_handle, MojoGLES2ContextLost lost_callback, void* closure) - : command_buffer_(this, attribs, std::move(command_buffer_handle)), + : command_buffer_(attribs, std::move(command_buffer_handle)), lost_callback_(lost_callback), closure_(closure) {} @@ -37,8 +31,10 @@ GLES2Context::~GLES2Context() {} bool GLES2Context::Initialize() { if (!command_buffer_.Initialize()) return false; + + constexpr gpu::SharedMemoryLimits default_limits; gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); - if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) + if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) return false; gles2_helper_->SetAutomaticFlushes(false); transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); @@ -57,12 +53,18 @@ bool GLES2Context::Initialize() { lose_context_when_out_of_memory, support_client_side_arrays, &command_buffer_)); - return implementation_->Initialize(kDefaultStartTransferBufferSize, - kDefaultMinTransferBufferSize, - kDefaultMaxTransferBufferSize, - gpu::gles2::GLES2Implementation::kNoLimit); + if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, + default_limits.min_transfer_buffer_size, + default_limits.max_transfer_buffer_size, + default_limits.mapped_memory_reclaim_limit)) + return false; + implementation_->SetLostContextCallback( + base::Bind(&GLES2Context::OnLostContext, base::Unretained(this))); + return true; } -void GLES2Context::ContextLost() { lost_callback_(closure_); } +void GLES2Context::OnLostContext() { + lost_callback_(closure_); +} } // namespace gles2 diff --git a/chromium/mojo/gles2/gles2_context.h b/chromium/mojo/gles2/gles2_context.h index e5dac202253..618d4bdfe45 100644 --- a/chromium/mojo/gles2/gles2_context.h +++ b/chromium/mojo/gles2/gles2_context.h @@ -7,10 +7,10 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "mojo/gles2/command_buffer_client_impl.h" #include "mojo/public/c/gles2/gles2.h" @@ -27,14 +27,13 @@ class GLES2Implementation; namespace gles2 { -class GLES2Context : public CommandBufferDelegate, - public MojoGLES2ContextPrivate { +class GLES2Context : public MojoGLES2ContextPrivate { public: explicit GLES2Context(const std::vector<int32_t>& attribs, mojo::ScopedMessagePipeHandle command_buffer_handle, MojoGLES2ContextLost lost_callback, void* closure); - ~GLES2Context() override; + virtual ~GLES2Context(); bool Initialize(); gpu::gles2::GLES2Interface* interface() const { @@ -43,12 +42,12 @@ class GLES2Context : public CommandBufferDelegate, gpu::ContextSupport* context_support() const { return implementation_.get(); } private: - void ContextLost() override; + void OnLostContext(); CommandBufferClientImpl command_buffer_; - scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; - scoped_ptr<gpu::TransferBuffer> transfer_buffer_; - scoped_ptr<gpu::gles2::GLES2Implementation> implementation_; + std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; + std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; + std::unique_ptr<gpu::gles2::GLES2Implementation> implementation_; MojoGLES2ContextLost lost_callback_; void* closure_; diff --git a/chromium/mojo/gles2/gles2_impl.cc b/chromium/mojo/gles2/gles2_impl.cc index c1875f41b7b..4cab046f312 100644 --- a/chromium/mojo/gles2/gles2_impl.cc +++ b/chromium/mojo/gles2/gles2_impl.cc @@ -42,7 +42,7 @@ MojoGLES2Context MojoGLES2CreateContext(MojoHandle handle, } } attribs.push_back(kNone); - scoped_ptr<GLES2Context> client(new GLES2Context( + std::unique_ptr<GLES2Context> client(new GLES2Context( attribs, std::move(scoped_handle), lost_callback, closure)); if (!client->Initialize()) client.reset(); |