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

Unified Diff: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 14456004: GPU client side changes for GpuMemoryBuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@glapi
Patch Set: More code reviews Created 7 years, 8 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: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index c0d011345fa3aa6df6b94c9bb0ec459811750274..94b2347f046ddff676beefcab09195af9ae53da4 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -27,14 +27,17 @@
#include "base/synchronization/lock.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/command_buffer/client/gpu_memory_buffer_factory.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/constants.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/gl/gl_context.h"
+#include "ui/gl/gl_image.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
#include "webkit/gpu/gl_bindings_skia_cmd_buffer.h"
@@ -42,8 +45,11 @@
using gpu::Buffer;
using gpu::CommandBuffer;
using gpu::CommandBufferService;
+using gpu::gles2::GpuMemoryBufferFactory;
using gpu::gles2::GLES2CmdHelper;
using gpu::gles2::GLES2Implementation;
+using gpu::gles2::ImageManager;
+using gpu::GpuMemoryBuffer;
using gpu::GpuScheduler;
using gpu::TransferBuffer;
using gpu::TransferBufferManager;
@@ -162,6 +168,8 @@ class GLInProcessContext {
void OnContextLost();
+ ::gpu::gles2::ImageManager* GetImageManager();
+
base::Closure context_lost_callback_;
scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
scoped_ptr<CommandBufferService> command_buffer_;
@@ -190,6 +198,38 @@ const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
const size_t kMinTransferBufferSize = 1 * 256 * 1024;
const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
+class GpuMemoryBufferImageManagerFactory : public GpuMemoryBufferFactory {
+ public:
+ explicit GpuMemoryBufferImageManagerFactory(ImageManager* image_manager);
+ virtual ~GpuMemoryBufferImageManagerFactory();
+
+ // methods from GpuMemoryBufferFactory
+ virtual scoped_ptr<GpuMemoryBuffer> CreateGpuMemoryBuffer(
+ int width, int height, int image_id) OVERRIDE;
+ private:
+ scoped_refptr<ImageManager> image_manager_;
+ DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImageManagerFactory);
+};
+
+GpuMemoryBufferImageManagerFactory::GpuMemoryBufferImageManagerFactory(
+ ImageManager* image_manager) : image_manager_(image_manager) {
+}
+
+GpuMemoryBufferImageManagerFactory::~GpuMemoryBufferImageManagerFactory() {
+}
+
+scoped_ptr<GpuMemoryBuffer> GpuMemoryBufferImageManagerFactory::
+ CreateGpuMemoryBuffer(int width, int height, int image_id) {
+ scoped_ptr<GpuMemoryBuffer> buffer =
+ ::gpu::gles2::GetProcessDefaultGpuMemoryBufferFactory().Run(
+ width, height);
+ scoped_refptr<gfx::GLImage> gl_image =
+ gfx::GLImage::CreateGLImageForGpuMemoryBuffer(buffer->GetNativeBuffer(),
+ gfx::Size(width, height));
+ image_manager_->AddImage(gl_image, image_id);
+ return buffer.Pass();
+}
+
// Singleton used to initialize and terminate the gles2 library.
class GLES2Initializer {
public:
@@ -417,6 +457,10 @@ GLES2Implementation* GLInProcessContext::GetImplementation() {
return gles2_implementation_.get();
}
+::gpu::gles2::ImageManager* GLInProcessContext::GetImageManager() {
+ return decoder_->GetContextGroup()->image_manager();
+}
+
GLInProcessContext::GLInProcessContext(bool share_resources)
: last_error_(SUCCESS),
share_resources_(share_resources),
@@ -601,6 +645,15 @@ bool GLInProcessContext::Initialize(
true,
false));
+ // GLES2Implementation::Initialize() which is called next
+ // needs the GpuMemoryBufferFactory so we set it before
+ // Initialize is called.
+ scoped_ptr<GpuMemoryBufferFactory> gpu_memory_buffer_factory(
+ new GpuMemoryBufferImageManagerFactory(GetImageManager()));
+ // GLES2Implementation takes the ownership of |gpu_memory_buffer_factory|.
+ gles2_implementation_->SetGpuMemoryBufferFactory(
+ gpu_memory_buffer_factory.Pass());
+
if (!gles2_implementation_->Initialize(
kStartTransferBufferSize,
kMinTransferBufferSize,
@@ -1705,6 +1758,12 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::deleteFramebuffer(
gl_->DeleteFramebuffers(1, &framebuffer);
}
+void WebGraphicsContext3DInProcessCommandBufferImpl::deleteImageBuffer(
+ WebGLId imagebuffer) {
+ ClearContext();
+ gl_->DeleteImageBuffers(1, &imagebuffer);
+}
+
void WebGraphicsContext3DInProcessCommandBufferImpl::deleteProgram(
WebGLId program) {
ClearContext();
@@ -1829,6 +1888,13 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
}
}
+void WebGraphicsContext3DInProcessCommandBufferImpl::
+ createGpuMemoryBuffer2DCHROMIUM(WGC3Duint image_id,
+ WGC3Dint width, WGC3Dint height) {
+ ClearContext();
+ gl_->CreateGpuMemoryBuffer2DCHROMIUM(image_id, width, height);
+}
+
DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
WebGLId, WGC3Dint, const WGC3Dchar*)

Powered by Google App Engine
This is Rietveld 408576698