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

Unified Diff: gpu/command_buffer/client/gl_in_process_context.cc

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include proper internalformat support.[D Created 7 years, 5 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: gpu/command_buffer/client/gl_in_process_context.cc
diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc
index 305d4be446cf6fbcb0365c09b3760018e77a2205..4f9df99007a92b40692b4d4f7bc15301027727fc 100644
--- a/gpu/command_buffer/client/gl_in_process_context.cc
+++ b/gpu/command_buffer/client/gl_in_process_context.cc
@@ -24,18 +24,14 @@
#include "base/message_loop/message_loop.h"
#include "base/synchronization/lock.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "gpu/command_buffer/client/gpu_memory_buffer_factory.h"
-#include "gpu/command_buffer/client/image_factory.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/constants.h"
-#include "gpu/command_buffer/common/id_allocator.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_context_virtual.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "gpu/command_buffer/service/image_manager.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h"
-#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/size.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image.h"
@@ -44,8 +40,6 @@
namespace gpu {
-using gles2::ImageManager;
-
namespace {
const int32 kCommandBufferSize = 1024 * 1024;
@@ -98,7 +92,6 @@ size_t SharedContextCount() {
class GLInProcessContextImpl
: public GLInProcessContext,
- public gles2::ImageFactory,
public base::SupportsWeakPtr<GLInProcessContextImpl> {
public:
explicit GLInProcessContextImpl(bool share_resources);
@@ -119,12 +112,6 @@ class GLInProcessContextImpl
OVERRIDE;
virtual gles2::GLES2Implementation* GetImplementation() OVERRIDE;
- // ImageFactory implementation:
- virtual scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
- int width, int height, GLenum internalformat,
- unsigned* image_id) OVERRIDE;
- virtual void DeleteGpuMemoryBuffer(unsigned image_id) OVERRIDE;
-
// Other methods:
gles2::GLES2Decoder* GetDecoder();
bool GetBufferChanged(int32 transfer_buffer_id);
@@ -139,10 +126,9 @@ class GLInProcessContextImpl
void CallQueryCallback(size_t index);
bool MakeCurrent();
- gles2::ImageManager* GetImageManager();
-
base::Closure context_lost_callback_;
scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
+ scoped_refptr<gles2::ImageManager> image_manager_;
scoped_ptr<CommandBuffer> command_buffer_;
scoped_ptr<GpuScheduler> gpu_scheduler_;
scoped_ptr<gles2::GLES2Decoder> decoder_;
@@ -180,38 +166,6 @@ AutoLockAndDecoderDetachThread::~AutoLockAndDecoderDetachThread() {
&DetachThread);
}
-scoped_ptr<gfx::GpuMemoryBuffer> GLInProcessContextImpl::CreateGpuMemoryBuffer(
- int width, int height, GLenum internalformat, unsigned int* image_id) {
- // We're taking the lock here because we're accessing the ContextGroup's
- // shared IdManager.
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- scoped_ptr<gfx::GpuMemoryBuffer> buffer(
- g_gpu_memory_buffer_factory->CreateGpuMemoryBuffer(width,
- height,
- internalformat));
- if (!buffer)
- return scoped_ptr<gfx::GpuMemoryBuffer>();
-
- scoped_refptr<gfx::GLImage> gl_image =
- gfx::GLImage::CreateGLImageForGpuMemoryBuffer(buffer->GetHandle(),
- gfx::Size(width, height));
- *image_id = decoder_->GetContextGroup()
- ->GetIdAllocator(gles2::id_namespaces::kImages)->AllocateID();
- GetImageManager()->AddImage(gl_image.get(), *image_id);
- return buffer.Pass();
-}
-
-void GLInProcessContextImpl::DeleteGpuMemoryBuffer(unsigned int image_id) {
- // We're taking the lock here because we're accessing the ContextGroup's
- // shared ImageManager.
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- GetImageManager()->RemoveImage(image_id);
- decoder_->GetContextGroup()->GetIdAllocator(gles2::id_namespaces::kImages)
- ->FreeID(image_id);
-}
-
GLInProcessContextImpl::GLInProcessContextImpl(bool share_resources)
: share_resources_(share_resources),
context_lost_(false) {
@@ -282,10 +236,6 @@ gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() {
return gles2_implementation_.get();
}
-gles2::ImageManager* GLInProcessContextImpl::GetImageManager() {
- return decoder_->GetContextGroup()->image_manager();
-}
-
bool GLInProcessContextImpl::Initialize(
bool is_offscreen,
gfx::AcceleratedWidget window,
@@ -333,8 +283,12 @@ bool GLInProcessContextImpl::Initialize(
manager->Initialize();
}
+ image_manager_ = new gles2::ImageManager();
+
scoped_ptr<CommandBufferService> command_buffer(
- new CommandBufferService(transfer_buffer_manager_.get()));
+ new CommandBufferService(transfer_buffer_manager_.get(),
+ image_manager_.get(),
+ g_gpu_memory_buffer_factory));
command_buffer->SetPutOffsetChangeCallback(base::Bind(
&GLInProcessContextImpl::PumpCommands, base::Unretained(this)));
command_buffer->SetGetBufferChangeCallback(base::Bind(
@@ -461,8 +415,7 @@ bool GLInProcessContextImpl::Initialize(
gles2_helper_.get(),
context_group ? context_group->GetImplementation()->share_group() : NULL,
transfer_buffer_.get(),
- false,
- this));
+ false));
if (!gles2_implementation_->Initialize(
kStartTransferBufferSize,

Powered by Google App Engine
This is Rietveld 408576698