OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // of attribute/value pairs. | 104 // of attribute/value pairs. |
105 static GLInProcessContext* CreateContext( | 105 static GLInProcessContext* CreateContext( |
106 bool is_offscreen, | 106 bool is_offscreen, |
107 gfx::AcceleratedWidget window, | 107 gfx::AcceleratedWidget window, |
108 const gfx::Size& size, | 108 const gfx::Size& size, |
109 bool share_resources, | 109 bool share_resources, |
110 const char* allowed_extensions, | 110 const char* allowed_extensions, |
111 const int32* attrib_list, | 111 const int32* attrib_list, |
112 gfx::GpuPreference gpu_preference); | 112 gfx::GpuPreference gpu_preference); |
113 | 113 |
114 // For an offscreen frame buffer GLInProcessContext, return the texture ID | |
115 // with respect to the parent GLInProcessContext. Returns zero if | |
116 // GLInProcessContext does not have a parent. | |
117 uint32 GetParentTextureId(); | |
118 | |
119 // Create a new texture in the parent's GLInProcessContext. Returns zero if | 114 // Create a new texture in the parent's GLInProcessContext. Returns zero if |
120 // GLInProcessContext does not have a parent. | 115 // GLInProcessContext does not have a parent. |
121 uint32 CreateParentTexture(const gfx::Size& size); | 116 uint32 CreateParentTexture(const gfx::Size& size); |
122 | 117 |
123 // Deletes a texture in the parent's GLInProcessContext. | 118 // Deletes a texture in the parent's GLInProcessContext. |
124 void DeleteParentTexture(uint32 texture); | 119 void DeleteParentTexture(uint32 texture); |
125 | 120 |
126 void SetContextLostCallback(const base::Closure& callback); | 121 void SetContextLostCallback(const base::Closure& callback); |
127 | 122 |
128 // Set the current GLInProcessContext for the calling thread. | 123 // Set the current GLInProcessContext for the calling thread. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 FROM_HERE, | 388 FROM_HERE, |
394 base::Bind(&CallAndDestroy, | 389 base::Bind(&CallAndDestroy, |
395 base::Passed(&signal_sync_point_callback_))); | 390 base::Passed(&signal_sync_point_callback_))); |
396 } | 391 } |
397 } | 392 } |
398 | 393 |
399 bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) { | 394 bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) { |
400 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); | 395 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); |
401 } | 396 } |
402 | 397 |
403 uint32 GLInProcessContext::GetParentTextureId() { | |
404 return 0; | |
405 } | |
406 | |
407 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { | 398 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { |
408 uint32 texture = 0; | 399 uint32 texture = 0; |
409 gles2_implementation_->GenTextures(1, &texture); | 400 gles2_implementation_->GenTextures(1, &texture); |
410 gles2_implementation_->Flush(); | 401 gles2_implementation_->Flush(); |
411 return texture; | 402 return texture; |
412 } | 403 } |
413 | 404 |
414 void GLInProcessContext::DeleteParentTexture(uint32 texture) { | 405 void GLInProcessContext::DeleteParentTexture(uint32 texture) { |
415 gles2_implementation_->DeleteTextures(1, &texture); | 406 gles2_implementation_->DeleteTextures(1, &texture); |
416 } | 407 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 } | 919 } |
929 | 920 |
930 int WebGraphicsContext3DInProcessCommandBufferImpl::width() { | 921 int WebGraphicsContext3DInProcessCommandBufferImpl::width() { |
931 return cached_width_; | 922 return cached_width_; |
932 } | 923 } |
933 | 924 |
934 int WebGraphicsContext3DInProcessCommandBufferImpl::height() { | 925 int WebGraphicsContext3DInProcessCommandBufferImpl::height() { |
935 return cached_height_; | 926 return cached_height_; |
936 } | 927 } |
937 | 928 |
938 bool WebGraphicsContext3DInProcessCommandBufferImpl::isGLES2Compliant() { | |
939 return true; | |
940 } | |
941 | |
942 bool WebGraphicsContext3DInProcessCommandBufferImpl::setParentContext( | 929 bool WebGraphicsContext3DInProcessCommandBufferImpl::setParentContext( |
943 WebGraphicsContext3D* parent_context) { | 930 WebGraphicsContext3D* parent_context) { |
944 return false; | 931 return false; |
945 } | 932 } |
946 | 933 |
947 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::getPlatformTextureId() { | |
948 DCHECK(context_); | |
949 return context_->GetParentTextureId(); | |
950 } | |
951 | |
952 void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() { | 934 void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() { |
953 // Copies the contents of the off-screen render target into the texture | 935 // Copies the contents of the off-screen render target into the texture |
954 // used by the compositor. | 936 // used by the compositor. |
955 context_->SwapBuffers(); | 937 context_->SwapBuffers(); |
956 } | 938 } |
957 | 939 |
958 void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM( | 940 void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM( |
959 int x, int y, int width, int height) { | 941 int x, int y, int width, int height) { |
960 gl_->PostSubBufferCHROMIUM(x, y, width, height); | 942 gl_->PostSubBufferCHROMIUM(x, y, width, height); |
961 } | 943 } |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, | 1986 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, |
2005 WGC3Denum) | 1987 WGC3Denum) |
2006 | 1988 |
2007 void WebGraphicsContext3DInProcessCommandBufferImpl::SetGpuMemoryBufferCreator( | 1989 void WebGraphicsContext3DInProcessCommandBufferImpl::SetGpuMemoryBufferCreator( |
2008 GpuMemoryBufferCreator* creator) { | 1990 GpuMemoryBufferCreator* creator) { |
2009 g_gpu_memory_buffer_creator = creator; | 1991 g_gpu_memory_buffer_creator = creator; |
2010 } | 1992 } |
2011 | 1993 |
2012 } // namespace gpu | 1994 } // namespace gpu |
2013 } // namespace webkit | 1995 } // namespace webkit |
OLD | NEW |