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

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: 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 c63e85585557856c6eb46ac035fe8ebd2aa2bb37..a2d366c6c7e6209c3094dc27a11f5919fcf81ba6 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -33,8 +33,10 @@
#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"
@@ -143,6 +145,8 @@ class GLInProcessContext {
::gpu::gles2::GLES2Decoder* GetDecoder();
+ ::gpu::gles2::ImageManager* GetImageManager();
+
private:
explicit GLInProcessContext(bool share_resources);
@@ -385,6 +389,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),
@@ -1644,6 +1652,11 @@ WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createTexture() {
void WebGraphicsContext3DInProcessCommandBufferImpl::deleteBuffer(
WebGLId buffer) {
ClearContext();
+ // It is safe to call this method even though the buffer being deleted
+ // isn't a GPU memory buffer as it eventually translates to a
+ // hash_map::erase() which doesn't throw an exception if the key
+ // isn't in the hash_map
+ DeleteImageForGpuMemoryBuffer(buffer);
gl_->DeleteBuffers(1, &buffer);
}
@@ -1777,6 +1790,50 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
}
}
+void WebGraphicsContext3DInProcessCommandBufferImpl::
+ CreateImageForGpuMemoryBuffer(WGC3Dsizei width, WGC3Dsizei height) {
+ gl_->Flush();
+ gfx::GpuMemoryBufferHandle buffer =
+ const_cast<GLubyte*>(
+ gl_->GetString(GL_BOUND_GPU_MEMORY_BUFFER_CHROMIUM_POINTER));
+ DCHECK(buffer);
+
+ scoped_refptr<gfx::GLImage> gl_image =
+ gfx::GLImage::CreateGLImageForGpuMemoryBuffer(
+ buffer, gfx::Size(width, height));
+
+ GLint buffer_id = 0;
+ gl_->GetIntegerv(GL_BOUND_GPU_MEMORY_BUFFER_CHROMIUM, &buffer_id);
+ DCHECK(buffer_id != 0);
+ context_->GetImageManager()->AddImage(gl_image, buffer_id);
+}
+
+void WebGraphicsContext3DInProcessCommandBufferImpl::
+ DeleteImageForGpuMemoryBuffer() {
+ gl_->Flush();
+ GLint buffer_id = 0;
+ gl_->GetIntegerv(GL_BOUND_GPU_MEMORY_BUFFER_CHROMIUM, &buffer_id);
+ DCHECK(buffer_id != 0);
+ context_->GetImageManager()->RemoveImage(buffer_id);
+}
+
+void WebGraphicsContext3DInProcessCommandBufferImpl::
+ DeleteImageForGpuMemoryBuffer(WebGLId buffer_id) {
+ gl_->Flush();
+ context_->GetImageManager()->RemoveImage(buffer_id);
+}
+
+void WebGraphicsContext3DInProcessCommandBufferImpl::imageBufferDataCHROMIUM(
+ WGC3Denum target, WGC3Dsizei width, WGC3Dsizei height) {
+ ClearContext();
+ gl_->ImageBufferDataCHROMIUM(target, width, height);
+ if (width == 0 && height == 0) {
+ DeleteImageForGpuMemoryBuffer();
+ } else {
+ CreateImageForGpuMemoryBuffer(width, height);
+ }
+}
+
DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
WebGLId, WGC3Dint, const WGC3Dchar*)

Powered by Google App Engine
This is Rietveld 408576698