Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 6 | |
| 7 | #include <GLES2/gl2.h> |
| 8 | #ifndef GL_GLEXT_PROTOTYPES |
| 9 | #define GL_GLEXT_PROTOTYPES 1 |
| 10 | #endif |
| 11 | #include <GLES2/gl2ext.h> |
| 12 | #include <GLES2/gl2extchromium.h> |
| 13 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 14 | #include <string> |
| 15 | |
| 16 | #include "base/bind.h" |
| 17 | #include "base/bind_helpers.h" |
| 18 | #include "base/callback.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 19 | #include "base/lazy_instance.h" |
| 20 | #include "base/logging.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 21 | #include "gpu/command_buffer/client/gl_in_process_context.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 22 | #include "gpu/command_buffer/client/gles2_implementation.h" |
| 23 | #include "gpu/command_buffer/client/gles2_lib.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 24 | #include "ui/gfx/size.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 25 | #include "ui/gl/gl_surface.h" |
| 26 | #include "webkit/common/gpu/gl_bindings_skia_cmd_buffer.h" |
| 27 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 28 | using gpu::gles2::GLES2Implementation; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 29 | using gpu::GLInProcessContext; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 30 | |
| 31 | namespace webkit { |
| 32 | namespace gpu { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 33 | |
| 34 | namespace { |
| 35 | |
| 36 | const int32 kCommandBufferSize = 1024 * 1024; |
| 37 | // TODO(kbr): make the transfer buffer size configurable via context |
| 38 | // creation attributes. |
| 39 | const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
| 40 | const size_t kMinTransferBufferSize = 1 * 256 * 1024; |
| 41 | const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
| 42 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 43 | void OnSignalSyncPoint( |
| 44 | WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback* callback) { |
| 45 | callback->onSyncPointReached(); |
| 46 | } |
| 47 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 48 | // Singleton used to initialize and terminate the gles2 library. |
| 49 | class GLES2Initializer { |
| 50 | public: |
| 51 | GLES2Initializer() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 52 | ::gles2::Initialize(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | ~GLES2Initializer() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 56 | ::gles2::Terminate(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | private: |
| 60 | DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); |
| 61 | }; |
| 62 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 63 | static base::LazyInstance<GLES2Initializer> g_gles2_initializer = |
| 64 | LAZY_INSTANCE_INITIALIZER; |
| 65 | |
| 66 | } // namespace anonymous |
| 67 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 68 | // static |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 69 | scoped_ptr<WebKit::WebGraphicsContext3D> |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 70 | WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| 71 | const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 72 | gfx::AcceleratedWidget window) { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 73 | scoped_ptr<WebKit::WebGraphicsContext3D> context; |
| 74 | if (gfx::GLSurface::InitializeOneOff()) { |
| 75 | context.reset(new WebGraphicsContext3DInProcessCommandBufferImpl( |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 76 | scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 77 | } |
| 78 | return context.Pass(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | // static |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 82 | scoped_ptr<WebKit::WebGraphicsContext3D> |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 83 | WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
| 84 | const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 85 | return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 86 | scoped_ptr< ::gpu::GLInProcessContext>(), |
| 87 | attributes, |
| 88 | true, |
| 89 | gfx::kNullAcceleratedWidget)) |
| 90 | .PassAs<WebKit::WebGraphicsContext3D>(); |
| 91 | } |
| 92 | |
| 93 | scoped_ptr<WebKit::WebGraphicsContext3D> |
| 94 | WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
| 95 | scoped_ptr< ::gpu::GLInProcessContext> context, |
| 96 | const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| 97 | return make_scoped_ptr( |
| 98 | new WebGraphicsContext3DInProcessCommandBufferImpl( |
| 99 | context.Pass(), |
| 100 | attributes, |
| 101 | true /* is_offscreen. Not used. */, |
| 102 | gfx::kNullAcceleratedWidget /* window. Not used. */)) |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 103 | .PassAs<WebKit::WebGraphicsContext3D>(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 107 | WebGraphicsContext3DInProcessCommandBufferImpl( |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 108 | scoped_ptr< ::gpu::GLInProcessContext> context, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 109 | const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 110 | bool is_offscreen, |
| 111 | gfx::AcceleratedWidget window) |
| 112 | : is_offscreen_(is_offscreen), |
| 113 | window_(window), |
| 114 | initialized_(false), |
| 115 | initialize_failed_(false), |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 116 | context_(context.Pass()), |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 117 | gl_(NULL), |
| 118 | context_lost_callback_(NULL), |
| 119 | context_lost_reason_(GL_NO_ERROR), |
| 120 | attributes_(attributes), |
| 121 | cached_width_(0), |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 122 | cached_height_(0) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 126 | ~WebGraphicsContext3DInProcessCommandBufferImpl() { |
| 127 | } |
| 128 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 129 | // static |
| 130 | void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( |
| 131 | const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 132 | ::gpu::GLInProcessContextAttribs* output_attribs) { |
| 133 | output_attribs->alpha_size = attributes.alpha ? 8 : 0; |
| 134 | output_attribs->depth_size = attributes.depth ? 24 : 0; |
| 135 | output_attribs->stencil_size = attributes.stencil ? 8 : 0; |
| 136 | output_attribs->samples = attributes.antialias ? 4 : 0; |
| 137 | output_attribs->sample_buffers = attributes.antialias ? 1 : 0; |
| 138 | } |
| 139 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 140 | bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { |
| 141 | if (initialized_) |
| 142 | return true; |
| 143 | |
| 144 | if (initialize_failed_) |
| 145 | return false; |
| 146 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 147 | // Ensure the gles2 library is initialized first in a thread safe way. |
| 148 | g_gles2_initializer.Get(); |
| 149 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 150 | if (!context_) { |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 151 | const char* preferred_extensions = "*"; |
| 152 | |
| 153 | // TODO(kbr): More work will be needed in this implementation to |
| 154 | // properly support GPU switching. Like in the out-of-process |
| 155 | // command buffer implementation, all previously created contexts |
| 156 | // will need to be lost either when the first context requesting the |
| 157 | // discrete GPU is created, or the last one is destroyed. |
| 158 | gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 159 | |
| 160 | ::gpu::GLInProcessContextAttribs attrib_struct; |
| 161 | ConvertAttributes(attributes_, &attrib_struct), |
| 162 | |
| 163 | context_.reset(GLInProcessContext::CreateContext( |
| 164 | is_offscreen_, |
| 165 | window_, |
| 166 | gfx::Size(1, 1), |
| 167 | attributes_.shareResources, |
| 168 | preferred_extensions, |
| 169 | attrib_struct, |
| 170 | gpu_preference)); |
| 171 | } |
| 172 | |
| 173 | if (context_) { |
| 174 | base::Closure context_lost_callback = base::Bind( |
| 175 | &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, |
| 176 | base::Unretained(this)); |
| 177 | context_->SetContextLostCallback(context_lost_callback); |
| 178 | } else { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 179 | initialize_failed_ = true; |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | gl_ = context_->GetImplementation(); |
| 184 | |
| 185 | if (gl_ && attributes_.noExtensions) |
| 186 | gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); |
| 187 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 188 | // Set attributes_ from created offscreen context. |
| 189 | { |
| 190 | GLint alpha_bits = 0; |
| 191 | getIntegerv(GL_ALPHA_BITS, &alpha_bits); |
| 192 | attributes_.alpha = alpha_bits > 0; |
| 193 | GLint depth_bits = 0; |
| 194 | getIntegerv(GL_DEPTH_BITS, &depth_bits); |
| 195 | attributes_.depth = depth_bits > 0; |
| 196 | GLint stencil_bits = 0; |
| 197 | getIntegerv(GL_STENCIL_BITS, &stencil_bits); |
| 198 | attributes_.stencil = stencil_bits > 0; |
| 199 | GLint sample_buffers = 0; |
| 200 | getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers); |
| 201 | attributes_.antialias = sample_buffers > 0; |
| 202 | } |
| 203 | |
| 204 | initialized_ = true; |
| 205 | return true; |
| 206 | } |
| 207 | |
| 208 | bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { |
| 209 | if (!MaybeInitializeGL()) |
| 210 | return false; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 211 | ::gles2::SetGLContext(gl_); |
| 212 | return context_ && !isContextLost(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() { |
| 216 | // NOTE: Comment in the line below to check for code that is not calling |
| 217 | // eglMakeCurrent where appropriate. The issue is code using |
| 218 | // WebGraphicsContext3D does not need to call makeContextCurrent. Code using |
| 219 | // direct OpenGL bindings needs to call the appropriate form of |
| 220 | // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong |
| 221 | // context. Uncommenting the line below clears the current context so that |
| 222 | // any code not calling eglMakeCurrent in the appropriate place should crash. |
| 223 | // This is not a perfect test but generally code that used the direct OpenGL |
| 224 | // bindings should not be mixed with code that uses WebGraphicsContext3D. |
| 225 | // |
| 226 | // GLInProcessContext::MakeCurrent(NULL); |
| 227 | } |
| 228 | |
| 229 | int WebGraphicsContext3DInProcessCommandBufferImpl::width() { |
| 230 | return cached_width_; |
| 231 | } |
| 232 | |
| 233 | int WebGraphicsContext3DInProcessCommandBufferImpl::height() { |
| 234 | return cached_height_; |
| 235 | } |
| 236 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 237 | void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 238 | if (!isContextLost()) { |
| 239 | gl_->SwapBuffers(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 240 | gl_->ShallowFlushCHROMIUM(); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 241 | } |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM( |
| 245 | int x, int y, int width, int height) { |
| 246 | gl_->PostSubBufferCHROMIUM(x, y, width, height); |
| 247 | } |
| 248 | |
| 249 | void WebGraphicsContext3DInProcessCommandBufferImpl::reshape( |
| 250 | int width, int height) { |
| 251 | reshapeWithScaleFactor(width, height, 1.0f); |
| 252 | } |
| 253 | |
| 254 | void WebGraphicsContext3DInProcessCommandBufferImpl::reshapeWithScaleFactor( |
| 255 | int width, int height, float scale_factor) { |
| 256 | cached_width_ = width; |
| 257 | cached_height_ = height; |
| 258 | |
| 259 | // TODO(gmam): See if we can comment this in. |
| 260 | // ClearContext(); |
| 261 | |
| 262 | gl_->ResizeCHROMIUM(width, height, scale_factor); |
| 263 | } |
| 264 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 265 | void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError( |
| 266 | WGC3Denum error) { |
| 267 | if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == |
| 268 | synthetic_errors_.end()) { |
| 269 | synthetic_errors_.push_back(error); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferSubDataCHROMIUM( |
| 274 | WGC3Denum target, |
| 275 | WGC3Dintptr offset, |
| 276 | WGC3Dsizeiptr size, |
| 277 | WGC3Denum access) { |
| 278 | ClearContext(); |
| 279 | return gl_->MapBufferSubDataCHROMIUM(target, offset, size, access); |
| 280 | } |
| 281 | |
| 282 | void WebGraphicsContext3DInProcessCommandBufferImpl::unmapBufferSubDataCHROMIUM( |
| 283 | const void* mem) { |
| 284 | ClearContext(); |
| 285 | return gl_->UnmapBufferSubDataCHROMIUM(mem); |
| 286 | } |
| 287 | |
| 288 | void* WebGraphicsContext3DInProcessCommandBufferImpl::mapTexSubImage2DCHROMIUM( |
| 289 | WGC3Denum target, |
| 290 | WGC3Dint level, |
| 291 | WGC3Dint xoffset, |
| 292 | WGC3Dint yoffset, |
| 293 | WGC3Dsizei width, |
| 294 | WGC3Dsizei height, |
| 295 | WGC3Denum format, |
| 296 | WGC3Denum type, |
| 297 | WGC3Denum access) { |
| 298 | ClearContext(); |
| 299 | return gl_->MapTexSubImage2DCHROMIUM( |
| 300 | target, level, xoffset, yoffset, width, height, format, type, access); |
| 301 | } |
| 302 | |
| 303 | void WebGraphicsContext3DInProcessCommandBufferImpl::unmapTexSubImage2DCHROMIUM( |
| 304 | const void* mem) { |
| 305 | ClearContext(); |
| 306 | gl_->UnmapTexSubImage2DCHROMIUM(mem); |
| 307 | } |
| 308 | |
| 309 | void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM( |
| 310 | bool visible) { |
| 311 | } |
| 312 | |
| 313 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 314 | setMemoryAllocationChangedCallbackCHROMIUM( |
| 315 | WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { |
| 316 | } |
| 317 | |
| 318 | void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT( |
| 319 | WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { |
| 320 | gl_->DiscardFramebufferEXT(target, numAttachments, attachments); |
| 321 | } |
| 322 | |
| 323 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 324 | discardBackbufferCHROMIUM() { |
| 325 | } |
| 326 | |
| 327 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 328 | ensureBackbufferCHROMIUM() { |
| 329 | } |
| 330 | |
| 331 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 332 | copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) { |
| 333 | NOTIMPLEMENTED(); |
| 334 | } |
| 335 | |
| 336 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 337 | rateLimitOffscreenContextCHROMIUM() { |
| 338 | // TODO(gmam): See if we can comment this in. |
| 339 | // ClearContext(); |
| 340 | gl_->RateLimitOffscreenContextCHROMIUM(); |
| 341 | } |
| 342 | |
| 343 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 344 | getRequestableExtensionsCHROMIUM() { |
| 345 | // TODO(gmam): See if we can comment this in. |
| 346 | // ClearContext(); |
| 347 | return WebKit::WebString::fromUTF8( |
| 348 | gl_->GetRequestableExtensionsCHROMIUM()); |
| 349 | } |
| 350 | |
| 351 | void WebGraphicsContext3DInProcessCommandBufferImpl::requestExtensionCHROMIUM( |
| 352 | const char* extension) { |
| 353 | // TODO(gmam): See if we can comment this in. |
| 354 | // ClearContext(); |
| 355 | gl_->RequestExtensionCHROMIUM(extension); |
| 356 | } |
| 357 | |
| 358 | void WebGraphicsContext3DInProcessCommandBufferImpl::blitFramebufferCHROMIUM( |
| 359 | WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, |
| 360 | WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, |
| 361 | WGC3Dbitfield mask, WGC3Denum filter) { |
| 362 | ClearContext(); |
| 363 | gl_->BlitFramebufferEXT( |
| 364 | srcX0, srcY0, srcX1, srcY1, |
| 365 | dstX0, dstY0, dstX1, dstY1, |
| 366 | mask, filter); |
| 367 | } |
| 368 | |
| 369 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 370 | renderbufferStorageMultisampleCHROMIUM( |
| 371 | WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, |
| 372 | WGC3Dsizei width, WGC3Dsizei height) { |
| 373 | ClearContext(); |
| 374 | gl_->RenderbufferStorageMultisampleEXT( |
| 375 | target, samples, internalformat, width, height); |
| 376 | } |
| 377 | |
| 378 | // Helper macros to reduce the amount of code. |
| 379 | |
| 380 | #define DELEGATE_TO_GL(name, glname) \ |
| 381 | void WebGraphicsContext3DInProcessCommandBufferImpl::name() { \ |
| 382 | ClearContext(); \ |
| 383 | gl_->glname(); \ |
| 384 | } |
| 385 | |
| 386 | #define DELEGATE_TO_GL_1(name, glname, t1) \ |
| 387 | void WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ |
| 388 | ClearContext(); \ |
| 389 | gl_->glname(a1); \ |
| 390 | } |
| 391 | |
| 392 | #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \ |
| 393 | rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ |
| 394 | ClearContext(); \ |
| 395 | return gl_->glname(a1); \ |
| 396 | } |
| 397 | |
| 398 | #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \ |
| 399 | rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ |
| 400 | ClearContext(); \ |
| 401 | return gl_->glname(a1) ? true : false; \ |
| 402 | } |
| 403 | |
| 404 | #define DELEGATE_TO_GL_2(name, glname, t1, t2) \ |
| 405 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 406 | t1 a1, t2 a2) { \ |
| 407 | ClearContext(); \ |
| 408 | gl_->glname(a1, a2); \ |
| 409 | } |
| 410 | |
| 411 | #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \ |
| 412 | rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1, t2 a2) { \ |
| 413 | ClearContext(); \ |
| 414 | return gl_->glname(a1, a2); \ |
| 415 | } |
| 416 | |
| 417 | #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \ |
| 418 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 419 | t1 a1, t2 a2, t3 a3) { \ |
| 420 | ClearContext(); \ |
| 421 | gl_->glname(a1, a2, a3); \ |
| 422 | } |
| 423 | |
| 424 | #define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \ |
| 425 | rt WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 426 | t1 a1, t2 a2, t3 a3) { \ |
| 427 | ClearContext(); \ |
| 428 | return gl_->glname(a1, a2, a3); \ |
| 429 | } |
| 430 | |
| 431 | #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \ |
| 432 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 433 | t1 a1, t2 a2, t3 a3, t4 a4) { \ |
| 434 | ClearContext(); \ |
| 435 | gl_->glname(a1, a2, a3, a4); \ |
| 436 | } |
| 437 | |
| 438 | #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \ |
| 439 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 440 | t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \ |
| 441 | ClearContext(); \ |
| 442 | gl_->glname(a1, a2, a3, a4, a5); \ |
| 443 | } |
| 444 | |
| 445 | #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \ |
| 446 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 447 | t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \ |
| 448 | ClearContext(); \ |
| 449 | gl_->glname(a1, a2, a3, a4, a5, a6); \ |
| 450 | } |
| 451 | |
| 452 | #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \ |
| 453 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 454 | t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) { \ |
| 455 | ClearContext(); \ |
| 456 | gl_->glname(a1, a2, a3, a4, a5, a6, a7); \ |
| 457 | } |
| 458 | |
| 459 | #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \ |
| 460 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 461 | t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) { \ |
| 462 | ClearContext(); \ |
| 463 | gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \ |
| 464 | } |
| 465 | |
| 466 | #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ |
| 467 | void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ |
| 468 | t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) { \ |
| 469 | ClearContext(); \ |
| 470 | gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ |
| 471 | } |
| 472 | |
| 473 | DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) |
| 474 | |
| 475 | DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) |
| 476 | |
| 477 | DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, |
| 478 | WGC3Duint, const WGC3Dchar*) |
| 479 | |
| 480 | DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) |
| 481 | |
| 482 | void WebGraphicsContext3DInProcessCommandBufferImpl::bindFramebuffer( |
| 483 | WGC3Denum target, |
| 484 | WebGLId framebuffer) { |
| 485 | ClearContext(); |
| 486 | gl_->BindFramebuffer(target, framebuffer); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId) |
| 490 | |
| 491 | DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId) |
| 492 | |
| 493 | DELEGATE_TO_GL_4(blendColor, BlendColor, |
| 494 | WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) |
| 495 | |
| 496 | DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum) |
| 497 | |
| 498 | DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate, |
| 499 | WGC3Denum, WGC3Denum) |
| 500 | |
| 501 | DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum) |
| 502 | |
| 503 | DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate, |
| 504 | WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum) |
| 505 | |
| 506 | DELEGATE_TO_GL_4(bufferData, BufferData, |
| 507 | WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum) |
| 508 | |
| 509 | DELEGATE_TO_GL_4(bufferSubData, BufferSubData, |
| 510 | WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*) |
| 511 | |
| 512 | DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus, |
| 513 | WGC3Denum, WGC3Denum) |
| 514 | |
| 515 | DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield) |
| 516 | |
| 517 | DELEGATE_TO_GL_4(clearColor, ClearColor, |
| 518 | WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) |
| 519 | |
| 520 | DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf) |
| 521 | |
| 522 | DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint) |
| 523 | |
| 524 | DELEGATE_TO_GL_4(colorMask, ColorMask, |
| 525 | WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean) |
| 526 | |
| 527 | DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId) |
| 528 | |
| 529 | DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D, |
| 530 | WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, |
| 531 | WGC3Dsizei, WGC3Dsizei, const void*) |
| 532 | |
| 533 | DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D, |
| 534 | WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, |
| 535 | WGC3Denum, WGC3Dsizei, const void*) |
| 536 | |
| 537 | DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D, |
| 538 | WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, |
| 539 | WGC3Dsizei, WGC3Dsizei, WGC3Dint) |
| 540 | |
| 541 | DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D, |
| 542 | WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, |
| 543 | WGC3Dsizei, WGC3Dsizei) |
| 544 | |
| 545 | DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum) |
| 546 | |
| 547 | DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum) |
| 548 | |
| 549 | DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean) |
| 550 | |
| 551 | DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf) |
| 552 | |
| 553 | DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId) |
| 554 | |
| 555 | DELEGATE_TO_GL_1(disable, Disable, WGC3Denum) |
| 556 | |
| 557 | DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray, |
| 558 | WGC3Duint) |
| 559 | |
| 560 | DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei) |
| 561 | |
| 562 | void WebGraphicsContext3DInProcessCommandBufferImpl::drawElements( |
| 563 | WGC3Denum mode, |
| 564 | WGC3Dsizei count, |
| 565 | WGC3Denum type, |
| 566 | WGC3Dintptr offset) { |
| 567 | ClearContext(); |
| 568 | gl_->DrawElements( |
| 569 | mode, count, type, |
| 570 | reinterpret_cast<void*>(static_cast<intptr_t>(offset))); |
| 571 | } |
| 572 | |
| 573 | DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) |
| 574 | |
| 575 | DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, |
| 576 | WGC3Duint) |
| 577 | |
| 578 | DELEGATE_TO_GL(finish, Finish) |
| 579 | |
| 580 | DELEGATE_TO_GL(flush, Flush) |
| 581 | |
| 582 | DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, |
| 583 | WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) |
| 584 | |
| 585 | DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D, |
| 586 | WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint) |
| 587 | |
| 588 | DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum) |
| 589 | |
| 590 | DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum) |
| 591 | |
| 592 | bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveAttrib( |
| 593 | WebGLId program, WGC3Duint index, ActiveInfo& info) { |
| 594 | ClearContext(); |
| 595 | if (!program) { |
| 596 | synthesizeGLError(GL_INVALID_VALUE); |
| 597 | return false; |
| 598 | } |
| 599 | GLint max_name_length = -1; |
| 600 | gl_->GetProgramiv( |
| 601 | program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); |
| 602 | if (max_name_length < 0) |
| 603 | return false; |
| 604 | scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); |
| 605 | if (!name) { |
| 606 | synthesizeGLError(GL_OUT_OF_MEMORY); |
| 607 | return false; |
| 608 | } |
| 609 | GLsizei length = 0; |
| 610 | GLint size = -1; |
| 611 | GLenum type = 0; |
| 612 | gl_->GetActiveAttrib( |
| 613 | program, index, max_name_length, &length, &size, &type, name.get()); |
| 614 | if (size < 0) { |
| 615 | return false; |
| 616 | } |
| 617 | info.name = WebKit::WebString::fromUTF8(name.get(), length); |
| 618 | info.type = type; |
| 619 | info.size = size; |
| 620 | return true; |
| 621 | } |
| 622 | |
| 623 | bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveUniform( |
| 624 | WebGLId program, WGC3Duint index, ActiveInfo& info) { |
| 625 | ClearContext(); |
| 626 | GLint max_name_length = -1; |
| 627 | gl_->GetProgramiv( |
| 628 | program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); |
| 629 | if (max_name_length < 0) |
| 630 | return false; |
| 631 | scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); |
| 632 | if (!name) { |
| 633 | synthesizeGLError(GL_OUT_OF_MEMORY); |
| 634 | return false; |
| 635 | } |
| 636 | GLsizei length = 0; |
| 637 | GLint size = -1; |
| 638 | GLenum type = 0; |
| 639 | gl_->GetActiveUniform( |
| 640 | program, index, max_name_length, &length, &size, &type, name.get()); |
| 641 | if (size < 0) { |
| 642 | return false; |
| 643 | } |
| 644 | info.name = WebKit::WebString::fromUTF8(name.get(), length); |
| 645 | info.type = type; |
| 646 | info.size = size; |
| 647 | return true; |
| 648 | } |
| 649 | |
| 650 | DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders, |
| 651 | WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*) |
| 652 | |
| 653 | DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation, |
| 654 | WebGLId, const WGC3Dchar*, WGC3Dint) |
| 655 | |
| 656 | DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*) |
| 657 | |
| 658 | DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv, |
| 659 | WGC3Denum, WGC3Denum, WGC3Dint*) |
| 660 | |
| 661 | WebKit::WebGraphicsContext3D::Attributes |
| 662 | WebGraphicsContext3DInProcessCommandBufferImpl::getContextAttributes() { |
| 663 | return attributes_; |
| 664 | } |
| 665 | |
| 666 | WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::getError() { |
| 667 | ClearContext(); |
| 668 | if (!synthetic_errors_.empty()) { |
| 669 | std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin(); |
| 670 | WGC3Denum err = *iter; |
| 671 | synthetic_errors_.erase(iter); |
| 672 | return err; |
| 673 | } |
| 674 | |
| 675 | return gl_->GetError(); |
| 676 | } |
| 677 | |
| 678 | bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 679 | return context_lost_reason_ != GL_NO_ERROR; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*) |
| 683 | |
| 684 | DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv, |
| 685 | GetFramebufferAttachmentParameteriv, |
| 686 | WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*) |
| 687 | |
| 688 | DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*) |
| 689 | |
| 690 | DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*) |
| 691 | |
| 692 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 693 | getProgramInfoLog(WebGLId program) { |
| 694 | ClearContext(); |
| 695 | GLint logLength = 0; |
| 696 | gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); |
| 697 | if (!logLength) |
| 698 | return WebKit::WebString(); |
| 699 | scoped_ptr<GLchar[]> log(new GLchar[logLength]); |
| 700 | if (!log) |
| 701 | return WebKit::WebString(); |
| 702 | GLsizei returnedLogLength = 0; |
| 703 | gl_->GetProgramInfoLog( |
| 704 | program, logLength, &returnedLogLength, log.get()); |
| 705 | DCHECK_EQ(logLength, returnedLogLength + 1); |
| 706 | WebKit::WebString res = |
| 707 | WebKit::WebString::fromUTF8(log.get(), returnedLogLength); |
| 708 | return res; |
| 709 | } |
| 710 | |
| 711 | DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv, |
| 712 | WGC3Denum, WGC3Denum, WGC3Dint*) |
| 713 | |
| 714 | DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*) |
| 715 | |
| 716 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 717 | getShaderInfoLog(WebGLId shader) { |
| 718 | ClearContext(); |
| 719 | GLint logLength = 0; |
| 720 | gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); |
| 721 | if (!logLength) |
| 722 | return WebKit::WebString(); |
| 723 | scoped_ptr<GLchar[]> log(new GLchar[logLength]); |
| 724 | if (!log) |
| 725 | return WebKit::WebString(); |
| 726 | GLsizei returnedLogLength = 0; |
| 727 | gl_->GetShaderInfoLog( |
| 728 | shader, logLength, &returnedLogLength, log.get()); |
| 729 | DCHECK_EQ(logLength, returnedLogLength + 1); |
| 730 | WebKit::WebString res = |
| 731 | WebKit::WebString::fromUTF8(log.get(), returnedLogLength); |
| 732 | return res; |
| 733 | } |
| 734 | |
| 735 | DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat, |
| 736 | WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*) |
| 737 | |
| 738 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 739 | getShaderSource(WebGLId shader) { |
| 740 | ClearContext(); |
| 741 | GLint logLength = 0; |
| 742 | gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength); |
| 743 | if (!logLength) |
| 744 | return WebKit::WebString(); |
| 745 | scoped_ptr<GLchar[]> log(new GLchar[logLength]); |
| 746 | if (!log) |
| 747 | return WebKit::WebString(); |
| 748 | GLsizei returnedLogLength = 0; |
| 749 | gl_->GetShaderSource( |
| 750 | shader, logLength, &returnedLogLength, log.get()); |
| 751 | if (!returnedLogLength) |
| 752 | return WebKit::WebString(); |
| 753 | DCHECK_EQ(logLength, returnedLogLength + 1); |
| 754 | WebKit::WebString res = |
| 755 | WebKit::WebString::fromUTF8(log.get(), returnedLogLength); |
| 756 | return res; |
| 757 | } |
| 758 | |
| 759 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 760 | getTranslatedShaderSourceANGLE(WebGLId shader) { |
| 761 | ClearContext(); |
| 762 | GLint logLength = 0; |
| 763 | gl_->GetShaderiv( |
| 764 | shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength); |
| 765 | if (!logLength) |
| 766 | return WebKit::WebString(); |
| 767 | scoped_ptr<GLchar[]> log(new GLchar[logLength]); |
| 768 | if (!log) |
| 769 | return WebKit::WebString(); |
| 770 | GLsizei returnedLogLength = 0; |
| 771 | gl_->GetTranslatedShaderSourceANGLE( |
| 772 | shader, logLength, &returnedLogLength, log.get()); |
| 773 | if (!returnedLogLength) |
| 774 | return WebKit::WebString(); |
| 775 | DCHECK_EQ(logLength, returnedLogLength + 1); |
| 776 | WebKit::WebString res = |
| 777 | WebKit::WebString::fromUTF8(log.get(), returnedLogLength); |
| 778 | return res; |
| 779 | } |
| 780 | |
| 781 | WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::getString( |
| 782 | WGC3Denum name) { |
| 783 | ClearContext(); |
| 784 | return WebKit::WebString::fromUTF8( |
| 785 | reinterpret_cast<const char*>(gl_->GetString(name))); |
| 786 | } |
| 787 | |
| 788 | DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv, |
| 789 | WGC3Denum, WGC3Denum, WGC3Dfloat*) |
| 790 | |
| 791 | DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv, |
| 792 | WGC3Denum, WGC3Denum, WGC3Dint*) |
| 793 | |
| 794 | DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*) |
| 795 | |
| 796 | DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*) |
| 797 | |
| 798 | DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation, |
| 799 | WebGLId, const WGC3Dchar*, WGC3Dint) |
| 800 | |
| 801 | DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv, |
| 802 | WGC3Duint, WGC3Denum, WGC3Dfloat*) |
| 803 | |
| 804 | DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv, |
| 805 | WGC3Duint, WGC3Denum, WGC3Dint*) |
| 806 | |
| 807 | WGC3Dsizeiptr WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 808 | getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) { |
| 809 | ClearContext(); |
| 810 | GLvoid* value = NULL; |
| 811 | // NOTE: If pname is ever a value that returns more then 1 element |
| 812 | // this will corrupt memory. |
| 813 | gl_->GetVertexAttribPointerv(index, pname, &value); |
| 814 | return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value)); |
| 815 | } |
| 816 | |
| 817 | DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum) |
| 818 | |
| 819 | DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean) |
| 820 | |
| 821 | DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean) |
| 822 | |
| 823 | DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean) |
| 824 | |
| 825 | DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean) |
| 826 | |
| 827 | DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean) |
| 828 | |
| 829 | DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean) |
| 830 | |
| 831 | DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean) |
| 832 | |
| 833 | DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat) |
| 834 | |
| 835 | DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId) |
| 836 | |
| 837 | DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint) |
| 838 | |
| 839 | DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat) |
| 840 | |
| 841 | DELEGATE_TO_GL_7(readPixels, ReadPixels, |
| 842 | WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum, |
| 843 | WGC3Denum, void*) |
| 844 | |
| 845 | void WebGraphicsContext3DInProcessCommandBufferImpl::releaseShaderCompiler() { |
| 846 | ClearContext(); |
| 847 | } |
| 848 | |
| 849 | DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage, |
| 850 | WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei) |
| 851 | |
| 852 | DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean) |
| 853 | |
| 854 | DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) |
| 855 | |
| 856 | void WebGraphicsContext3DInProcessCommandBufferImpl::shaderSource( |
| 857 | WebGLId shader, const WGC3Dchar* string) { |
| 858 | ClearContext(); |
| 859 | GLint length = strlen(string); |
| 860 | gl_->ShaderSource(shader, 1, &string, &length); |
| 861 | } |
| 862 | |
| 863 | DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint) |
| 864 | |
| 865 | DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate, |
| 866 | WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint) |
| 867 | |
| 868 | DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint) |
| 869 | |
| 870 | DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate, |
| 871 | WGC3Denum, WGC3Duint) |
| 872 | |
| 873 | DELEGATE_TO_GL_3(stencilOp, StencilOp, |
| 874 | WGC3Denum, WGC3Denum, WGC3Denum) |
| 875 | |
| 876 | DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate, |
| 877 | WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum) |
| 878 | |
| 879 | DELEGATE_TO_GL_9(texImage2D, TexImage2D, |
| 880 | WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, |
| 881 | WGC3Dint, WGC3Denum, WGC3Denum, const void*) |
| 882 | |
| 883 | DELEGATE_TO_GL_3(texParameterf, TexParameterf, |
| 884 | WGC3Denum, WGC3Denum, WGC3Dfloat); |
| 885 | |
| 886 | static const unsigned int kTextureWrapR = 0x8072; |
| 887 | |
| 888 | void WebGraphicsContext3DInProcessCommandBufferImpl::texParameteri( |
| 889 | WGC3Denum target, WGC3Denum pname, WGC3Dint param) { |
| 890 | ClearContext(); |
| 891 | // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in |
| 892 | // GraphicsContext3D.cpp is strictly necessary to avoid seams at the |
| 893 | // edge of cube maps, and, if it is, push it into the GLES2 service |
| 894 | // side code. |
| 895 | if (pname == kTextureWrapR) { |
| 896 | return; |
| 897 | } |
| 898 | gl_->TexParameteri(target, pname, param); |
| 899 | } |
| 900 | |
| 901 | DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D, |
| 902 | WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 903 | WGC3Dsizei, WGC3Denum, WGC3Denum, const void*) |
| 904 | |
| 905 | DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat) |
| 906 | |
| 907 | DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei, |
| 908 | const WGC3Dfloat*) |
| 909 | |
| 910 | DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint) |
| 911 | |
| 912 | DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) |
| 913 | |
| 914 | DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat) |
| 915 | |
| 916 | DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei, |
| 917 | const WGC3Dfloat*) |
| 918 | |
| 919 | DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint) |
| 920 | |
| 921 | DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) |
| 922 | |
| 923 | DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint, |
| 924 | WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) |
| 925 | |
| 926 | DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei, |
| 927 | const WGC3Dfloat*) |
| 928 | |
| 929 | DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint) |
| 930 | |
| 931 | DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) |
| 932 | |
| 933 | DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint, |
| 934 | WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) |
| 935 | |
| 936 | DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei, |
| 937 | const WGC3Dfloat*) |
| 938 | |
| 939 | DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint, |
| 940 | WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint) |
| 941 | |
| 942 | DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) |
| 943 | |
| 944 | DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv, |
| 945 | WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) |
| 946 | |
| 947 | DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv, |
| 948 | WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) |
| 949 | |
| 950 | DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv, |
| 951 | WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) |
| 952 | |
| 953 | DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId) |
| 954 | |
| 955 | DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId) |
| 956 | |
| 957 | DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat) |
| 958 | |
| 959 | DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint, |
| 960 | const WGC3Dfloat*) |
| 961 | |
| 962 | DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint, |
| 963 | WGC3Dfloat, WGC3Dfloat) |
| 964 | |
| 965 | DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint, |
| 966 | const WGC3Dfloat*) |
| 967 | |
| 968 | DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint, |
| 969 | WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) |
| 970 | |
| 971 | DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint, |
| 972 | const WGC3Dfloat*) |
| 973 | |
| 974 | DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint, |
| 975 | WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) |
| 976 | |
| 977 | DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint, |
| 978 | const WGC3Dfloat*) |
| 979 | |
| 980 | void WebGraphicsContext3DInProcessCommandBufferImpl::vertexAttribPointer( |
| 981 | WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized, |
| 982 | WGC3Dsizei stride, WGC3Dintptr offset) { |
| 983 | ClearContext(); |
| 984 | gl_->VertexAttribPointer( |
| 985 | index, size, type, normalized, stride, |
| 986 | reinterpret_cast<void*>(static_cast<intptr_t>(offset))); |
| 987 | } |
| 988 | |
| 989 | DELEGATE_TO_GL_4(viewport, Viewport, |
| 990 | WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) |
| 991 | |
| 992 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createBuffer() { |
| 993 | ClearContext(); |
| 994 | GLuint o; |
| 995 | gl_->GenBuffers(1, &o); |
| 996 | return o; |
| 997 | } |
| 998 | |
| 999 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createFramebuffer() { |
| 1000 | ClearContext(); |
| 1001 | GLuint o = 0; |
| 1002 | gl_->GenFramebuffers(1, &o); |
| 1003 | return o; |
| 1004 | } |
| 1005 | |
| 1006 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createProgram() { |
| 1007 | ClearContext(); |
| 1008 | return gl_->CreateProgram(); |
| 1009 | } |
| 1010 | |
| 1011 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createRenderbuffer() { |
| 1012 | ClearContext(); |
| 1013 | GLuint o; |
| 1014 | gl_->GenRenderbuffers(1, &o); |
| 1015 | return o; |
| 1016 | } |
| 1017 | |
| 1018 | DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId); |
| 1019 | |
| 1020 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createTexture() { |
| 1021 | ClearContext(); |
| 1022 | GLuint o; |
| 1023 | gl_->GenTextures(1, &o); |
| 1024 | return o; |
| 1025 | } |
| 1026 | |
| 1027 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteBuffer( |
| 1028 | WebGLId buffer) { |
| 1029 | ClearContext(); |
| 1030 | gl_->DeleteBuffers(1, &buffer); |
| 1031 | } |
| 1032 | |
| 1033 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteFramebuffer( |
| 1034 | WebGLId framebuffer) { |
| 1035 | ClearContext(); |
| 1036 | gl_->DeleteFramebuffers(1, &framebuffer); |
| 1037 | } |
| 1038 | |
| 1039 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteProgram( |
| 1040 | WebGLId program) { |
| 1041 | ClearContext(); |
| 1042 | gl_->DeleteProgram(program); |
| 1043 | } |
| 1044 | |
| 1045 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteRenderbuffer( |
| 1046 | WebGLId renderbuffer) { |
| 1047 | ClearContext(); |
| 1048 | gl_->DeleteRenderbuffers(1, &renderbuffer); |
| 1049 | } |
| 1050 | |
| 1051 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteShader( |
| 1052 | WebGLId shader) { |
| 1053 | ClearContext(); |
| 1054 | gl_->DeleteShader(shader); |
| 1055 | } |
| 1056 | |
| 1057 | void WebGraphicsContext3DInProcessCommandBufferImpl::deleteTexture( |
| 1058 | WebGLId texture) { |
| 1059 | ClearContext(); |
| 1060 | gl_->DeleteTextures(1, &texture); |
| 1061 | } |
| 1062 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1063 | void WebGraphicsContext3DInProcessCommandBufferImpl::OnSwapBuffersComplete() { |
| 1064 | } |
| 1065 | |
| 1066 | void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback( |
| 1067 | WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
| 1068 | context_lost_callback_ = cb; |
| 1069 | } |
| 1070 | |
| 1071 | WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 1072 | getGraphicsResetStatusARB() { |
| 1073 | return context_lost_reason_; |
| 1074 | } |
| 1075 | |
| 1076 | DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, |
| 1077 | WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) |
| 1078 | |
| 1079 | DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, |
| 1080 | WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) |
| 1081 | |
| 1082 | WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createQueryEXT() { |
| 1083 | GLuint o; |
| 1084 | gl_->GenQueriesEXT(1, &o); |
| 1085 | return o; |
| 1086 | } |
| 1087 | |
| 1088 | void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 1089 | deleteQueryEXT(WebGLId query) { |
| 1090 | gl_->DeleteQueriesEXT(1, &query); |
| 1091 | } |
| 1092 | |
| 1093 | DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean) |
| 1094 | DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId) |
| 1095 | DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum) |
| 1096 | DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*) |
| 1097 | DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT, |
| 1098 | WebGLId, WGC3Denum, WGC3Duint*) |
| 1099 | |
| 1100 | DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, WGC3Duint, |
| 1101 | WGC3Duint, WGC3Dint, WGC3Denum, WGC3Denum) |
| 1102 | |
| 1103 | void WebGraphicsContext3DInProcessCommandBufferImpl::insertEventMarkerEXT( |
| 1104 | const WGC3Dchar* marker) { |
| 1105 | gl_->InsertEventMarkerEXT(0, marker); |
| 1106 | } |
| 1107 | |
| 1108 | void WebGraphicsContext3DInProcessCommandBufferImpl::pushGroupMarkerEXT( |
| 1109 | const WGC3Dchar* marker) { |
| 1110 | gl_->PushGroupMarkerEXT(0, marker); |
| 1111 | } |
| 1112 | |
| 1113 | DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT); |
| 1114 | |
| 1115 | DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM, |
| 1116 | WGC3Denum, WGC3Dint) |
| 1117 | DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM, |
| 1118 | WGC3Denum, WGC3Dint) |
| 1119 | |
| 1120 | void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferCHROMIUM( |
| 1121 | WGC3Denum target, WGC3Denum access) { |
| 1122 | ClearContext(); |
| 1123 | return gl_->MapBufferCHROMIUM(target, access); |
| 1124 | } |
| 1125 | |
| 1126 | WGC3Dboolean WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 1127 | unmapBufferCHROMIUM(WGC3Denum target) { |
| 1128 | ClearContext(); |
| 1129 | return gl_->UnmapBufferCHROMIUM(target); |
| 1130 | } |
| 1131 | |
| 1132 | GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 1133 | onCreateGrGLInterface() { |
| 1134 | return CreateCommandBufferSkiaGLBinding(); |
| 1135 | } |
| 1136 | |
| 1137 | void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
| 1138 | // TODO(kbr): improve the precision here. |
| 1139 | context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
| 1140 | if (context_lost_callback_) { |
| 1141 | context_lost_callback_->onContextLost(); |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | DELEGATE_TO_GL_3R(createImageCHROMIUM, CreateImageCHROMIUM, |
| 1146 | WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Duint); |
| 1147 | |
| 1148 | DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint); |
| 1149 | |
| 1150 | DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM, |
| 1151 | WGC3Duint, WGC3Denum, GLint*); |
| 1152 | |
| 1153 | DELEGATE_TO_GL_2R(mapImageCHROMIUM, MapImageCHROMIUM, |
| 1154 | WGC3Duint, WGC3Denum, void*); |
| 1155 | |
| 1156 | DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint); |
| 1157 | |
| 1158 | DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, |
| 1159 | WebGLId, WGC3Dint, const WGC3Dchar*) |
| 1160 | |
| 1161 | DELEGATE_TO_GL(shallowFlushCHROMIUM, ShallowFlushCHROMIUM) |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1162 | DELEGATE_TO_GL(shallowFinishCHROMIUM, ShallowFinishCHROMIUM) |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1163 | |
| 1164 | DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*) |
| 1165 | DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM, |
| 1166 | WGC3Denum, const WGC3Dbyte*) |
| 1167 | DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM, |
| 1168 | WGC3Denum, const WGC3Dbyte*) |
| 1169 | |
| 1170 | DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, |
| 1171 | WGC3Dsizei, const WGC3Denum*) |
| 1172 | |
| 1173 | unsigned WebGraphicsContext3DInProcessCommandBufferImpl::insertSyncPoint() { |
| 1174 | shallowFlushCHROMIUM(); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | |
| 1178 | void WebGraphicsContext3DInProcessCommandBufferImpl::signalSyncPoint( |
| 1179 | unsigned sync_point, |
| 1180 | WebGraphicsSyncPointCallback* callback) { |
| 1181 | // Take ownership of the callback. |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1182 | context_->SignalSyncPoint( |
| 1183 | sync_point, base::Bind(&OnSignalSyncPoint, base::Owned(callback))); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1184 | } |
| 1185 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1186 | void WebGraphicsContext3DInProcessCommandBufferImpl::signalQuery( |
| 1187 | unsigned query, |
| 1188 | WebGraphicsSyncPointCallback* callback) { |
| 1189 | // Take ownership of the callback. |
| 1190 | context_->SignalQuery(query, |
| 1191 | base::Bind(&OnSignalSyncPoint, base::Owned(callback))); |
| 1192 | } |
| 1193 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1194 | void WebGraphicsContext3DInProcessCommandBufferImpl::loseContextCHROMIUM( |
| 1195 | WGC3Denum current, WGC3Denum other) { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1196 | gl_->LoseContextCHROMIUM(current, other); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1197 | gl_->ShallowFlushCHROMIUM(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, |
| 1201 | WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint, |
| 1202 | WGC3Denum, WGC3Denum, const void*) |
| 1203 | |
| 1204 | DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM, |
| 1205 | WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, |
| 1206 | WGC3Denum, WGC3Denum, const void*) |
| 1207 | |
| 1208 | DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, |
| 1209 | WGC3Denum) |
| 1210 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1211 | } // namespace gpu |
| 1212 | } // namespace webkit |