Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / common / gpu / client / webgraphicscontext3d_command_buffer_impl.cc
index 4b91c42..01917ff 100644 (file)
@@ -229,7 +229,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
     const GURL& active_url,
     GpuChannelHost* host,
     const Attributes& attributes,
-    bool bind_generates_resources,
+    bool lose_context_when_out_of_memory,
     const SharedMemoryLimits& limits,
     WebGraphicsContext3DCommandBufferImpl* share_context)
     : initialize_failed_(false),
@@ -246,7 +246,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
       weak_ptr_factory_(this),
       initialized_(false),
       gl_(NULL),
-      bind_generates_resources_(bind_generates_resources),
+      lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
       mem_limits_(limits),
       flush_id_(0) {
   if (share_context) {
@@ -350,6 +350,10 @@ bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer(
   attribs.push_back(attributes_.antialias ? 1 : 0);
   attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT);
   attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0);
+  attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY);
+  attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0);
+  attribs.push_back(BIND_GENERATES_RESOURCES);
+  attribs.push_back(0);
   attribs.push_back(NONE);
 
   // Create a proxy to a command buffer in the GPU process.
@@ -424,12 +428,14 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
   DCHECK(host_.get());
 
   // Create the object exposing the OpenGL API.
-  real_gl_.reset(new gpu::gles2::GLES2Implementation(
-      gles2_helper_.get(),
-      gles2_share_group,
-      transfer_buffer_.get(),
-      bind_generates_resources_,
-      command_buffer_.get()));
+  bool bind_generates_resources = false;
+  real_gl_.reset(
+      new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
+                                          gles2_share_group,
+                                          transfer_buffer_.get(),
+                                          bind_generates_resources,
+                                          lose_context_when_out_of_memory_,
+                                          command_buffer_.get()));
   gl_ = real_gl_.get();
 
   if (!real_gl_->Initialize(
@@ -1191,6 +1197,7 @@ WebGraphicsContext3DCommandBufferImpl*
 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
     GpuChannelHost* host,
     const WebGraphicsContext3D::Attributes& attributes,
+    bool lose_context_when_out_of_memory,
     const GURL& active_url,
     const SharedMemoryLimits& limits,
     WebGraphicsContext3DCommandBufferImpl* share_context) {
@@ -1200,13 +1207,14 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
   if (share_context && share_context->IsCommandBufferContextLost())
     return NULL;
 
-  return new WebGraphicsContext3DCommandBufferImpl(0,
-                                                   active_url,
-                                                   host,
-                                                   attributes,
-                                                   false,
-                                                   limits,
-                                                   share_context);
+  return new WebGraphicsContext3DCommandBufferImpl(
+      0,
+      active_url,
+      host,
+      attributes,
+      lose_context_when_out_of_memory,
+      limits,
+      share_context);
 }
 
 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
@@ -1328,17 +1336,34 @@ void WebGraphicsContext3DCommandBufferImpl::drawElementsInstancedANGLE(
 DELEGATE_TO_GL_2(vertexAttribDivisorANGLE, VertexAttribDivisorANGLE, WGC3Duint,
                  WGC3Duint)
 
-DELEGATE_TO_GL_3R(createImageCHROMIUM, CreateImageCHROMIUM,
-                  WGC3Dsizei, WGC3Dsizei, WGC3Denum,
+DELEGATE_TO_GL_4R(createImageCHROMIUM,
+                  CreateImageCHROMIUM,
+                  WGC3Dsizei,
+                  WGC3Dsizei,
+                  WGC3Denum,
+                  WGC3Denum,
                   WGC3Duint);
 
+WGC3Duint WebGraphicsContext3DCommandBufferImpl::createImageCHROMIUM(
+    WGC3Dsizei width,
+    WGC3Dsizei height,
+    WGC3Denum internalformat) {
+  return gl_->CreateImageCHROMIUM(
+      width, height, internalformat, GL_IMAGE_MAP_CHROMIUM);
+}
+
 DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint);
 
 DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM,
                  WGC3Duint, WGC3Denum, GLint*);
 
-DELEGATE_TO_GL_2R(mapImageCHROMIUM, MapImageCHROMIUM,
-                  WGC3Duint, WGC3Denum, void*);
+DELEGATE_TO_GL_1R(mapImageCHROMIUM, MapImageCHROMIUM, WGC3Duint, void*);
+
+void* WebGraphicsContext3DCommandBufferImpl::mapImageCHROMIUM(
+    WGC3Duint image_id,
+    WGC3Denum access) {
+  return gl_->MapImageCHROMIUM(image_id);
+}
 
 DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint);