1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/gl/GLContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,3019 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef GLCONTEXT_H_ 1.11 +#define GLCONTEXT_H_ 1.12 + 1.13 +#include <stdio.h> 1.14 +#include <stdint.h> 1.15 +#include <ctype.h> 1.16 +#include <map> 1.17 +#include <bitset> 1.18 + 1.19 +#ifdef DEBUG 1.20 +#include <string.h> 1.21 +#endif 1.22 + 1.23 +#ifdef WIN32 1.24 +#include <windows.h> 1.25 +#endif 1.26 + 1.27 +#ifdef GetClassName 1.28 +#undef GetClassName 1.29 +#endif 1.30 + 1.31 +#include "GLDefs.h" 1.32 +#include "GLLibraryLoader.h" 1.33 +#include "gfx3DMatrix.h" 1.34 +#include "nsISupportsImpl.h" 1.35 +#include "plstr.h" 1.36 +#include "nsDataHashtable.h" 1.37 +#include "nsHashKeys.h" 1.38 +#include "nsAutoPtr.h" 1.39 +#include "GLContextTypes.h" 1.40 +#include "GLTextureImage.h" 1.41 +#include "SurfaceTypes.h" 1.42 +#include "GLScreenBuffer.h" 1.43 +#include "GLContextSymbols.h" 1.44 +#include "mozilla/GenericRefCounted.h" 1.45 +#include "mozilla/Scoped.h" 1.46 +#include "gfx2DGlue.h" 1.47 + 1.48 +#ifdef DEBUG 1.49 +#define MOZ_ENABLE_GL_TRACKING 1 1.50 +#endif 1.51 + 1.52 +class nsIntRegion; 1.53 +class nsIRunnable; 1.54 +class nsIThread; 1.55 + 1.56 +namespace android { 1.57 + class GraphicBuffer; 1.58 +} 1.59 + 1.60 +namespace mozilla { 1.61 + namespace gfx { 1.62 + class SourceSurface; 1.63 + class DataSourceSurface; 1.64 + struct SurfaceCaps; 1.65 + } 1.66 + 1.67 + namespace gl { 1.68 + class GLContext; 1.69 + class GLLibraryEGL; 1.70 + class GLScreenBuffer; 1.71 + class TextureGarbageBin; 1.72 + class GLBlitHelper; 1.73 + class GLBlitTextureImageHelper; 1.74 + class GLReadTexImageHelper; 1.75 + class SharedSurface_GL; 1.76 + } 1.77 + 1.78 + namespace layers { 1.79 + class ColorTextureLayerProgram; 1.80 + } 1.81 +} 1.82 + 1.83 +namespace mozilla { 1.84 +namespace gl { 1.85 + 1.86 +MOZ_BEGIN_ENUM_CLASS(GLFeature) 1.87 + bind_buffer_offset, 1.88 + blend_minmax, 1.89 + depth_texture, 1.90 + draw_buffers, 1.91 + draw_instanced, 1.92 + draw_range_elements, 1.93 + element_index_uint, 1.94 + ES2_compatibility, 1.95 + ES3_compatibility, 1.96 + frag_color_float, 1.97 + frag_depth, 1.98 + framebuffer_blit, 1.99 + framebuffer_multisample, 1.100 + framebuffer_object, 1.101 + get_query_object_iv, 1.102 + instanced_arrays, 1.103 + instanced_non_arrays, 1.104 + occlusion_query, 1.105 + occlusion_query_boolean, 1.106 + occlusion_query2, 1.107 + packed_depth_stencil, 1.108 + query_objects, 1.109 + renderbuffer_color_float, 1.110 + renderbuffer_color_half_float, 1.111 + robustness, 1.112 + sRGB, 1.113 + standard_derivatives, 1.114 + texture_float, 1.115 + texture_float_linear, 1.116 + texture_half_float, 1.117 + texture_half_float_linear, 1.118 + texture_non_power_of_two, 1.119 + transform_feedback, 1.120 + vertex_array_object, 1.121 + EnumMax 1.122 +MOZ_END_ENUM_CLASS(GLFeature) 1.123 + 1.124 +MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t) 1.125 + Unknown = 0, 1.126 + OpenGL, // only for IsAtLeast's <profile> parameter 1.127 + OpenGLCore, 1.128 + OpenGLCompatibility, 1.129 + OpenGLES 1.130 +MOZ_END_ENUM_CLASS(ContextProfile) 1.131 + 1.132 +MOZ_BEGIN_ENUM_CLASS(GLVendor) 1.133 + Intel, 1.134 + NVIDIA, 1.135 + ATI, 1.136 + Qualcomm, 1.137 + Imagination, 1.138 + Nouveau, 1.139 + Vivante, 1.140 + VMware, 1.141 + Other 1.142 +MOZ_END_ENUM_CLASS(GLVendor) 1.143 + 1.144 +MOZ_BEGIN_ENUM_CLASS(GLRenderer) 1.145 + Adreno200, 1.146 + Adreno205, 1.147 + AdrenoTM205, 1.148 + AdrenoTM320, 1.149 + SGX530, 1.150 + SGX540, 1.151 + Tegra, 1.152 + AndroidEmulator, 1.153 + GalliumLlvmpipe, 1.154 + Other 1.155 +MOZ_END_ENUM_CLASS(GLRenderer) 1.156 + 1.157 +class GLContext 1.158 + : public GLLibraryLoader 1.159 + , public GenericAtomicRefCounted 1.160 +{ 1.161 +// ----------------------------------------------------------------------------- 1.162 +// basic enums 1.163 +public: 1.164 + 1.165 +// ----------------------------------------------------------------------------- 1.166 +// basic getters 1.167 +public: 1.168 + 1.169 + /** 1.170 + * Returns true if the context is using ANGLE. This should only be overridden 1.171 + * for an ANGLE implementation. 1.172 + */ 1.173 + virtual bool IsANGLE() const { 1.174 + return false; 1.175 + } 1.176 + 1.177 + /** 1.178 + * Return true if we are running on a OpenGL core profile context 1.179 + */ 1.180 + inline bool IsCoreProfile() const { 1.181 + MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); 1.182 + 1.183 + return mProfile == ContextProfile::OpenGLCore; 1.184 + } 1.185 + 1.186 + /** 1.187 + * Return true if we are running on a OpenGL compatibility profile context 1.188 + * (legacy profile 2.1 on Max OS X) 1.189 + */ 1.190 + inline bool IsCompatibilityProfile() const { 1.191 + MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); 1.192 + 1.193 + return mProfile == ContextProfile::OpenGLCompatibility; 1.194 + } 1.195 + 1.196 + /** 1.197 + * Return true if the context is a true OpenGL ES context or an ANGLE context 1.198 + */ 1.199 + inline bool IsGLES() const { 1.200 + MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); 1.201 + 1.202 + return mProfile == ContextProfile::OpenGLES; 1.203 + } 1.204 + 1.205 + static const char* GetProfileName(ContextProfile profile) 1.206 + { 1.207 + switch (profile) 1.208 + { 1.209 + case ContextProfile::OpenGL: 1.210 + return "OpenGL"; 1.211 + case ContextProfile::OpenGLCore: 1.212 + return "OpenGL Core"; 1.213 + case ContextProfile::OpenGLCompatibility: 1.214 + return "OpenGL Compatibility"; 1.215 + case ContextProfile::OpenGLES: 1.216 + return "OpenGL ES"; 1.217 + default: 1.218 + break; 1.219 + } 1.220 + 1.221 + MOZ_ASSERT(profile != ContextProfile::Unknown, "unknown context profile"); 1.222 + return "OpenGL unknown profile"; 1.223 + } 1.224 + 1.225 + /** 1.226 + * Return true if we are running on a OpenGL core profile context 1.227 + */ 1.228 + const char* ProfileString() const { 1.229 + return GetProfileName(mProfile); 1.230 + } 1.231 + 1.232 + /** 1.233 + * Return true if the context is compatible with given parameters 1.234 + * 1.235 + * IsAtLeast(ContextProfile::OpenGL, N) is exactly same as 1.236 + * IsAtLeast(ContextProfile::OpenGLCore, N) || IsAtLeast(ContextProfile::OpenGLCompatibility, N) 1.237 + */ 1.238 + inline bool IsAtLeast(ContextProfile profile, unsigned int version) const 1.239 + { 1.240 + MOZ_ASSERT(profile != ContextProfile::Unknown, "IsAtLeast: bad <profile> parameter"); 1.241 + MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); 1.242 + MOZ_ASSERT(mVersion != 0, "unknown context version"); 1.243 + 1.244 + if (version > mVersion) { 1.245 + return false; 1.246 + } 1.247 + 1.248 + if (profile == ContextProfile::OpenGL) { 1.249 + return profile == ContextProfile::OpenGLCore || 1.250 + profile == ContextProfile::OpenGLCompatibility; 1.251 + } 1.252 + 1.253 + return profile == mProfile; 1.254 + } 1.255 + 1.256 + /** 1.257 + * Return the version of the context. 1.258 + * Example : 1.259 + * If this a OpenGL 2.1, that will return 210 1.260 + */ 1.261 + inline unsigned int Version() const { 1.262 + return mVersion; 1.263 + } 1.264 + 1.265 + const char* VersionString() const { 1.266 + return mVersionString.get(); 1.267 + } 1.268 + 1.269 + GLVendor Vendor() const { 1.270 + return mVendor; 1.271 + } 1.272 + 1.273 + GLRenderer Renderer() const { 1.274 + return mRenderer; 1.275 + } 1.276 + 1.277 + bool IsContextLost() const { 1.278 + return mContextLost; 1.279 + } 1.280 + 1.281 + /** 1.282 + * If this context is double-buffered, returns TRUE. 1.283 + */ 1.284 + virtual bool IsDoubleBuffered() const { 1.285 + return false; 1.286 + } 1.287 + 1.288 + virtual GLContextType GetContextType() const = 0; 1.289 + 1.290 + virtual bool IsCurrent() = 0; 1.291 + 1.292 +protected: 1.293 + 1.294 + bool mInitialized; 1.295 + bool mIsOffscreen; 1.296 + bool mIsGlobalSharedContext; 1.297 + bool mContextLost; 1.298 + 1.299 + /** 1.300 + * mVersion store the OpenGL's version, multiplied by 100. For example, if 1.301 + * the context is an OpenGL 2.1 context, mVersion value will be 210. 1.302 + */ 1.303 + unsigned int mVersion; 1.304 + nsCString mVersionString; 1.305 + ContextProfile mProfile; 1.306 + 1.307 + GLVendor mVendor; 1.308 + GLRenderer mRenderer; 1.309 + 1.310 + inline void SetProfileVersion(ContextProfile profile, unsigned int version) { 1.311 + MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before initialization!"); 1.312 + MOZ_ASSERT(profile != ContextProfile::Unknown && profile != ContextProfile::OpenGL, "Invalid `profile` for SetProfileVersion"); 1.313 + MOZ_ASSERT(version >= 100, "Invalid `version` for SetProfileVersion"); 1.314 + 1.315 + mVersion = version; 1.316 + mProfile = profile; 1.317 + } 1.318 + 1.319 + 1.320 +// ----------------------------------------------------------------------------- 1.321 +// Extensions management 1.322 +/** 1.323 + * This mechanism is designed to know if an extension is supported. In the long 1.324 + * term, we would like to only use the extension group queries XXX_* to have 1.325 + * full compatibility with context version and profiles (especialy the core that 1.326 + * officialy don't bring any extensions). 1.327 + */ 1.328 +public: 1.329 + 1.330 + /** 1.331 + * Known GL extensions that can be queried by 1.332 + * IsExtensionSupported. The results of this are cached, and as 1.333 + * such it's safe to use this even in performance critical code. 1.334 + * If you add to this array, remember to add to the string names 1.335 + * in GLContext.cpp. 1.336 + */ 1.337 + enum GLExtensions { 1.338 + EXT_framebuffer_object, 1.339 + ARB_framebuffer_object, 1.340 + ARB_texture_rectangle, 1.341 + EXT_bgra, 1.342 + EXT_texture_format_BGRA8888, 1.343 + OES_depth24, 1.344 + OES_depth32, 1.345 + OES_stencil8, 1.346 + OES_texture_npot, 1.347 + ARB_depth_texture, 1.348 + OES_depth_texture, 1.349 + OES_packed_depth_stencil, 1.350 + IMG_read_format, 1.351 + EXT_read_format_bgra, 1.352 + APPLE_client_storage, 1.353 + APPLE_texture_range, 1.354 + ARB_texture_non_power_of_two, 1.355 + ARB_pixel_buffer_object, 1.356 + ARB_ES2_compatibility, 1.357 + ARB_ES3_compatibility, 1.358 + OES_texture_float, 1.359 + OES_texture_float_linear, 1.360 + ARB_texture_float, 1.361 + OES_texture_half_float, 1.362 + OES_texture_half_float_linear, 1.363 + NV_half_float, 1.364 + EXT_color_buffer_float, 1.365 + EXT_color_buffer_half_float, 1.366 + ARB_color_buffer_float, 1.367 + EXT_unpack_subimage, 1.368 + OES_standard_derivatives, 1.369 + EXT_texture_filter_anisotropic, 1.370 + EXT_texture_compression_s3tc, 1.371 + EXT_texture_compression_dxt1, 1.372 + ANGLE_texture_compression_dxt3, 1.373 + ANGLE_texture_compression_dxt5, 1.374 + AMD_compressed_ATC_texture, 1.375 + IMG_texture_compression_pvrtc, 1.376 + EXT_framebuffer_blit, 1.377 + ANGLE_framebuffer_blit, 1.378 + EXT_framebuffer_multisample, 1.379 + ANGLE_framebuffer_multisample, 1.380 + OES_rgb8_rgba8, 1.381 + ARB_robustness, 1.382 + EXT_robustness, 1.383 + ARB_sync, 1.384 + OES_EGL_image, 1.385 + OES_EGL_sync, 1.386 + OES_EGL_image_external, 1.387 + EXT_packed_depth_stencil, 1.388 + OES_element_index_uint, 1.389 + OES_vertex_array_object, 1.390 + ARB_vertex_array_object, 1.391 + APPLE_vertex_array_object, 1.392 + ARB_draw_buffers, 1.393 + EXT_draw_buffers, 1.394 + EXT_gpu_shader4, 1.395 + EXT_blend_minmax, 1.396 + ARB_draw_instanced, 1.397 + EXT_draw_instanced, 1.398 + NV_draw_instanced, 1.399 + ARB_instanced_arrays, 1.400 + NV_instanced_arrays, 1.401 + ANGLE_instanced_arrays, 1.402 + EXT_occlusion_query_boolean, 1.403 + ARB_occlusion_query2, 1.404 + EXT_transform_feedback, 1.405 + NV_transform_feedback, 1.406 + ANGLE_depth_texture, 1.407 + EXT_sRGB, 1.408 + EXT_texture_sRGB, 1.409 + ARB_framebuffer_sRGB, 1.410 + EXT_framebuffer_sRGB, 1.411 + KHR_debug, 1.412 + ARB_half_float_pixel, 1.413 + EXT_frag_depth, 1.414 + OES_compressed_ETC1_RGB8_texture, 1.415 + EXT_draw_range_elements, 1.416 + Extensions_Max, 1.417 + Extensions_End 1.418 + }; 1.419 + 1.420 + bool IsExtensionSupported(GLExtensions aKnownExtension) const { 1.421 + return mAvailableExtensions[aKnownExtension]; 1.422 + } 1.423 + 1.424 + void MarkExtensionUnsupported(GLExtensions aKnownExtension) { 1.425 + mAvailableExtensions[aKnownExtension] = 0; 1.426 + } 1.427 + 1.428 + void MarkExtensionSupported(GLExtensions aKnownExtension) { 1.429 + mAvailableExtensions[aKnownExtension] = 1; 1.430 + } 1.431 + 1.432 + 1.433 +public: 1.434 + 1.435 + template<size_t N> 1.436 + static void InitializeExtensionsBitSet(std::bitset<N>& extensionsBitset, const char* extStr, const char** extList, bool verbose = false) 1.437 + { 1.438 + char* exts = ::strdup(extStr); 1.439 + 1.440 + if (verbose) 1.441 + printf_stderr("Extensions: %s\n", exts); 1.442 + 1.443 + char* cur = exts; 1.444 + bool done = false; 1.445 + while (!done) { 1.446 + char* space = strchr(cur, ' '); 1.447 + if (space) { 1.448 + *space = '\0'; 1.449 + } else { 1.450 + done = true; 1.451 + } 1.452 + 1.453 + for (int i = 0; extList[i]; ++i) { 1.454 + if (PL_strcasecmp(cur, extList[i]) == 0) { 1.455 + if (verbose) 1.456 + printf_stderr("Found extension %s\n", cur); 1.457 + extensionsBitset[i] = true; 1.458 + } 1.459 + } 1.460 + 1.461 + cur = space + 1; 1.462 + } 1.463 + 1.464 + free(exts); 1.465 + } 1.466 + 1.467 + 1.468 +protected: 1.469 + std::bitset<Extensions_Max> mAvailableExtensions; 1.470 + 1.471 + 1.472 +// ----------------------------------------------------------------------------- 1.473 +// Feature queries 1.474 +/* 1.475 + * This mecahnism introduces a new way to check if a OpenGL feature is 1.476 + * supported, regardless of whether it is supported by an extension or natively 1.477 + * by the context version/profile 1.478 + */ 1.479 +public: 1.480 + bool IsSupported(GLFeature feature) const { 1.481 + return mAvailableFeatures[size_t(feature)]; 1.482 + } 1.483 + 1.484 + static const char* GetFeatureName(GLFeature feature); 1.485 + 1.486 + 1.487 +private: 1.488 + std::bitset<size_t(GLFeature::EnumMax)> mAvailableFeatures; 1.489 + 1.490 + /** 1.491 + * Init features regarding OpenGL extension and context version and profile 1.492 + */ 1.493 + void InitFeatures(); 1.494 + 1.495 + /** 1.496 + * Mark the feature and associated extensions as unsupported 1.497 + */ 1.498 + void MarkUnsupported(GLFeature feature); 1.499 + 1.500 +// ----------------------------------------------------------------------------- 1.501 +// Robustness handling 1.502 +public: 1.503 + 1.504 + bool HasRobustness() const { 1.505 + return mHasRobustness; 1.506 + } 1.507 + 1.508 + /** 1.509 + * The derived class is expected to provide information on whether or not it 1.510 + * supports robustness. 1.511 + */ 1.512 + virtual bool SupportsRobustness() const = 0; 1.513 + 1.514 + 1.515 +private: 1.516 + bool mHasRobustness; 1.517 + 1.518 + 1.519 +// ----------------------------------------------------------------------------- 1.520 +// Error handling 1.521 +public: 1.522 + 1.523 + static const char* GLErrorToString(GLenum aError) 1.524 + { 1.525 + switch (aError) { 1.526 + case LOCAL_GL_INVALID_ENUM: 1.527 + return "GL_INVALID_ENUM"; 1.528 + case LOCAL_GL_INVALID_VALUE: 1.529 + return "GL_INVALID_VALUE"; 1.530 + case LOCAL_GL_INVALID_OPERATION: 1.531 + return "GL_INVALID_OPERATION"; 1.532 + case LOCAL_GL_STACK_OVERFLOW: 1.533 + return "GL_STACK_OVERFLOW"; 1.534 + case LOCAL_GL_STACK_UNDERFLOW: 1.535 + return "GL_STACK_UNDERFLOW"; 1.536 + case LOCAL_GL_OUT_OF_MEMORY: 1.537 + return "GL_OUT_OF_MEMORY"; 1.538 + case LOCAL_GL_TABLE_TOO_LARGE: 1.539 + return "GL_TABLE_TOO_LARGE"; 1.540 + case LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION: 1.541 + return "GL_INVALID_FRAMEBUFFER_OPERATION"; 1.542 + default: 1.543 + return ""; 1.544 + } 1.545 + } 1.546 + 1.547 + 1.548 + /** \returns the first GL error, and guarantees that all GL error flags are cleared, 1.549 + * i.e. that a subsequent GetError call will return NO_ERROR 1.550 + */ 1.551 + GLenum GetAndClearError() 1.552 + { 1.553 + // the first error is what we want to return 1.554 + GLenum error = fGetError(); 1.555 + 1.556 + if (error) { 1.557 + // clear all pending errors 1.558 + while(fGetError()) {} 1.559 + } 1.560 + 1.561 + return error; 1.562 + } 1.563 + 1.564 + 1.565 + /*** In GL debug mode, we completely override glGetError ***/ 1.566 + 1.567 + GLenum fGetError() 1.568 + { 1.569 +#ifdef DEBUG 1.570 + // debug mode ends up eating the error in AFTER_GL_CALL 1.571 + if (DebugMode()) { 1.572 + GLenum err = mGLError; 1.573 + mGLError = LOCAL_GL_NO_ERROR; 1.574 + return err; 1.575 + } 1.576 +#endif // DEBUG 1.577 + 1.578 + return mSymbols.fGetError(); 1.579 + } 1.580 + 1.581 + 1.582 +#ifdef DEBUG 1.583 +private: 1.584 + 1.585 + GLenum mGLError; 1.586 +#endif // DEBUG 1.587 + 1.588 + 1.589 +// ----------------------------------------------------------------------------- 1.590 +// MOZ_GL_DEBUG implementation 1.591 +private: 1.592 + 1.593 +#undef BEFORE_GL_CALL 1.594 +#undef AFTER_GL_CALL 1.595 + 1.596 +#ifdef MOZ_ENABLE_GL_TRACKING 1.597 + 1.598 +#ifndef MOZ_FUNCTION_NAME 1.599 +# ifdef __GNUC__ 1.600 +# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__ 1.601 +# elif defined(_MSC_VER) 1.602 +# define MOZ_FUNCTION_NAME __FUNCTION__ 1.603 +# else 1.604 +# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name. 1.605 +# endif 1.606 +#endif 1.607 + 1.608 + void BeforeGLCall(const char* glFunction) 1.609 + { 1.610 + MOZ_ASSERT(IsCurrent()); 1.611 + if (DebugMode()) { 1.612 + GLContext *currentGLContext = nullptr; 1.613 + 1.614 + currentGLContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS); 1.615 + 1.616 + if (DebugMode() & DebugTrace) 1.617 + printf_stderr("[gl:%p] > %s\n", this, glFunction); 1.618 + if (this != currentGLContext) { 1.619 + printf_stderr("Fatal: %s called on non-current context %p. " 1.620 + "The current context for this thread is %p.\n", 1.621 + glFunction, this, currentGLContext); 1.622 + NS_ABORT(); 1.623 + } 1.624 + } 1.625 + } 1.626 + 1.627 + void AfterGLCall(const char* glFunction) 1.628 + { 1.629 + if (DebugMode()) { 1.630 + // calling fFinish() immediately after every GL call makes sure that if this GL command crashes, 1.631 + // the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces 1.632 + // tend to be meaningless 1.633 + mSymbols.fFinish(); 1.634 + mGLError = mSymbols.fGetError(); 1.635 + if (DebugMode() & DebugTrace) 1.636 + printf_stderr("[gl:%p] < %s [0x%04x]\n", this, glFunction, mGLError); 1.637 + if (mGLError != LOCAL_GL_NO_ERROR) { 1.638 + printf_stderr("GL ERROR: %s generated GL error %s(0x%04x)\n", 1.639 + glFunction, 1.640 + GLErrorToString(mGLError), 1.641 + mGLError); 1.642 + if (DebugMode() & DebugAbortOnError) 1.643 + NS_ABORT(); 1.644 + } 1.645 + } 1.646 + } 1.647 + 1.648 + GLContext *TrackingContext() 1.649 + { 1.650 + GLContext *tip = this; 1.651 + while (tip->mSharedContext) 1.652 + tip = tip->mSharedContext; 1.653 + return tip; 1.654 + } 1.655 + 1.656 +#define BEFORE_GL_CALL \ 1.657 + do { \ 1.658 + BeforeGLCall(MOZ_FUNCTION_NAME); \ 1.659 + } while (0) 1.660 + 1.661 +#define AFTER_GL_CALL \ 1.662 + do { \ 1.663 + AfterGLCall(MOZ_FUNCTION_NAME); \ 1.664 + } while (0) 1.665 + 1.666 +#define TRACKING_CONTEXT(a) \ 1.667 + do { \ 1.668 + TrackingContext()->a; \ 1.669 + } while (0) 1.670 + 1.671 +#else // ifdef DEBUG 1.672 + 1.673 +#define BEFORE_GL_CALL do { } while (0) 1.674 +#define AFTER_GL_CALL do { } while (0) 1.675 +#define TRACKING_CONTEXT(a) do {} while (0) 1.676 + 1.677 +#endif // ifdef DEBUG 1.678 + 1.679 +#define ASSERT_SYMBOL_PRESENT(func) \ 1.680 + do {\ 1.681 + MOZ_ASSERT(strstr(MOZ_FUNCTION_NAME, #func) != nullptr, "Mismatched symbol check.");\ 1.682 + if (MOZ_UNLIKELY(!mSymbols.func)) {\ 1.683 + printf_stderr("RUNTIME ASSERT: Uninitialized GL function: %s\n", #func);\ 1.684 + MOZ_CRASH();\ 1.685 + }\ 1.686 + } while (0) 1.687 + 1.688 + // Do whatever setup is necessary to draw to our offscreen FBO, if it's 1.689 + // bound. 1.690 + void BeforeGLDrawCall() { 1.691 + } 1.692 + 1.693 + // Do whatever tear-down is necessary after drawing to our offscreen FBO, 1.694 + // if it's bound. 1.695 + void AfterGLDrawCall() 1.696 + { 1.697 + if (mScreen) 1.698 + mScreen->AfterDrawCall(); 1.699 + } 1.700 + 1.701 + // Do whatever setup is necessary to read from our offscreen FBO, if it's 1.702 + // bound. 1.703 + void BeforeGLReadCall() 1.704 + { 1.705 + if (mScreen) 1.706 + mScreen->BeforeReadCall(); 1.707 + } 1.708 + 1.709 + // Do whatever tear-down is necessary after reading from our offscreen FBO, 1.710 + // if it's bound. 1.711 + void AfterGLReadCall() { 1.712 + } 1.713 + 1.714 + 1.715 +// ----------------------------------------------------------------------------- 1.716 +// GL official entry points 1.717 +public: 1.718 + 1.719 + void fActiveTexture(GLenum texture) { 1.720 + BEFORE_GL_CALL; 1.721 + mSymbols.fActiveTexture(texture); 1.722 + AFTER_GL_CALL; 1.723 + } 1.724 + 1.725 + void fAttachShader(GLuint program, GLuint shader) { 1.726 + BEFORE_GL_CALL; 1.727 + mSymbols.fAttachShader(program, shader); 1.728 + AFTER_GL_CALL; 1.729 + } 1.730 + 1.731 + void fBeginQuery(GLenum target, GLuint id) { 1.732 + BEFORE_GL_CALL; 1.733 + ASSERT_SYMBOL_PRESENT(fBeginQuery); 1.734 + mSymbols.fBeginQuery(target, id); 1.735 + AFTER_GL_CALL; 1.736 + } 1.737 + 1.738 + void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) { 1.739 + BEFORE_GL_CALL; 1.740 + mSymbols.fBindAttribLocation(program, index, name); 1.741 + AFTER_GL_CALL; 1.742 + } 1.743 + 1.744 + void fBindBuffer(GLenum target, GLuint buffer) { 1.745 + BEFORE_GL_CALL; 1.746 + mSymbols.fBindBuffer(target, buffer); 1.747 + AFTER_GL_CALL; 1.748 + } 1.749 + 1.750 + void fBindFramebuffer(GLenum target, GLuint framebuffer) { 1.751 + if (!mScreen) { 1.752 + raw_fBindFramebuffer(target, framebuffer); 1.753 + return; 1.754 + } 1.755 + 1.756 + switch (target) { 1.757 + case LOCAL_GL_DRAW_FRAMEBUFFER_EXT: 1.758 + mScreen->BindDrawFB(framebuffer); 1.759 + return; 1.760 + 1.761 + case LOCAL_GL_READ_FRAMEBUFFER_EXT: 1.762 + mScreen->BindReadFB(framebuffer); 1.763 + return; 1.764 + 1.765 + case LOCAL_GL_FRAMEBUFFER: 1.766 + mScreen->BindFB(framebuffer); 1.767 + return; 1.768 + 1.769 + default: 1.770 + // Nothing we care about, likely an error. 1.771 + break; 1.772 + } 1.773 + 1.774 + raw_fBindFramebuffer(target, framebuffer); 1.775 + } 1.776 + 1.777 + void fBindTexture(GLenum target, GLuint texture) { 1.778 + BEFORE_GL_CALL; 1.779 + mSymbols.fBindTexture(target, texture); 1.780 + AFTER_GL_CALL; 1.781 + } 1.782 + 1.783 + void fBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { 1.784 + BEFORE_GL_CALL; 1.785 + mSymbols.fBlendColor(red, green, blue, alpha); 1.786 + AFTER_GL_CALL; 1.787 + } 1.788 + 1.789 + void fBlendEquation(GLenum mode) { 1.790 + BEFORE_GL_CALL; 1.791 + mSymbols.fBlendEquation(mode); 1.792 + AFTER_GL_CALL; 1.793 + } 1.794 + 1.795 + void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { 1.796 + BEFORE_GL_CALL; 1.797 + mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha); 1.798 + AFTER_GL_CALL; 1.799 + } 1.800 + 1.801 + void fBlendFunc(GLenum sfactor, GLenum dfactor) { 1.802 + BEFORE_GL_CALL; 1.803 + mSymbols.fBlendFunc(sfactor, dfactor); 1.804 + AFTER_GL_CALL; 1.805 + } 1.806 + 1.807 + void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) { 1.808 + BEFORE_GL_CALL; 1.809 + mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); 1.810 + AFTER_GL_CALL; 1.811 + } 1.812 + 1.813 +private: 1.814 + void raw_fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) { 1.815 + BEFORE_GL_CALL; 1.816 + mSymbols.fBufferData(target, size, data, usage); 1.817 + AFTER_GL_CALL; 1.818 + } 1.819 + 1.820 +public: 1.821 + void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) { 1.822 + raw_fBufferData(target, size, data, usage); 1.823 + 1.824 + // bug 744888 1.825 + if (WorkAroundDriverBugs() && 1.826 + !data && 1.827 + Vendor() == GLVendor::NVIDIA) 1.828 + { 1.829 + char c = 0; 1.830 + fBufferSubData(target, size-1, 1, &c); 1.831 + } 1.832 + } 1.833 + 1.834 + void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) { 1.835 + BEFORE_GL_CALL; 1.836 + mSymbols.fBufferSubData(target, offset, size, data); 1.837 + AFTER_GL_CALL; 1.838 + } 1.839 + 1.840 +private: 1.841 + void raw_fClear(GLbitfield mask) { 1.842 + BEFORE_GL_CALL; 1.843 + mSymbols.fClear(mask); 1.844 + AFTER_GL_CALL; 1.845 + } 1.846 + 1.847 +public: 1.848 + void fClear(GLbitfield mask) { 1.849 + BeforeGLDrawCall(); 1.850 + raw_fClear(mask); 1.851 + AfterGLDrawCall(); 1.852 + } 1.853 + 1.854 + void fClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) { 1.855 + BEFORE_GL_CALL; 1.856 + mSymbols.fClearColor(r, g, b, a); 1.857 + AFTER_GL_CALL; 1.858 + } 1.859 + 1.860 + void fClearStencil(GLint s) { 1.861 + BEFORE_GL_CALL; 1.862 + mSymbols.fClearStencil(s); 1.863 + AFTER_GL_CALL; 1.864 + } 1.865 + 1.866 + void fClientActiveTexture(GLenum texture) { 1.867 + BEFORE_GL_CALL; 1.868 + mSymbols.fClientActiveTexture(texture); 1.869 + AFTER_GL_CALL; 1.870 + } 1.871 + 1.872 + void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) { 1.873 + BEFORE_GL_CALL; 1.874 + mSymbols.fColorMask(red, green, blue, alpha); 1.875 + AFTER_GL_CALL; 1.876 + } 1.877 + 1.878 + void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) { 1.879 + BEFORE_GL_CALL; 1.880 + mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels); 1.881 + AFTER_GL_CALL; 1.882 + } 1.883 + 1.884 + void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels) { 1.885 + BEFORE_GL_CALL; 1.886 + mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pixels); 1.887 + AFTER_GL_CALL; 1.888 + } 1.889 + 1.890 + void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { 1.891 + if (!IsTextureSizeSafeToPassToDriver(target, width, height)) { 1.892 + // pass wrong values to cause the GL to generate GL_INVALID_VALUE. 1.893 + // See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver. 1.894 + level = -1; 1.895 + width = -1; 1.896 + height = -1; 1.897 + border = -1; 1.898 + } 1.899 + 1.900 + BeforeGLReadCall(); 1.901 + raw_fCopyTexImage2D(target, level, internalformat, 1.902 + x, y, width, height, border); 1.903 + AfterGLReadCall(); 1.904 + } 1.905 + 1.906 + void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { 1.907 + BeforeGLReadCall(); 1.908 + raw_fCopyTexSubImage2D(target, level, xoffset, yoffset, 1.909 + x, y, width, height); 1.910 + AfterGLReadCall(); 1.911 + } 1.912 + 1.913 + void fCullFace(GLenum mode) { 1.914 + BEFORE_GL_CALL; 1.915 + mSymbols.fCullFace(mode); 1.916 + AFTER_GL_CALL; 1.917 + } 1.918 + 1.919 + void fDebugMessageCallback(GLDEBUGPROC callback, const GLvoid* userParam) { 1.920 + BEFORE_GL_CALL; 1.921 + ASSERT_SYMBOL_PRESENT(fDebugMessageCallback); 1.922 + mSymbols.fDebugMessageCallback(callback, userParam); 1.923 + AFTER_GL_CALL; 1.924 + } 1.925 + 1.926 + void fDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, realGLboolean enabled) { 1.927 + BEFORE_GL_CALL; 1.928 + ASSERT_SYMBOL_PRESENT(fDebugMessageControl); 1.929 + mSymbols.fDebugMessageControl(source, type, severity, count, ids, enabled); 1.930 + AFTER_GL_CALL; 1.931 + } 1.932 + 1.933 + void fDebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf) { 1.934 + BEFORE_GL_CALL; 1.935 + ASSERT_SYMBOL_PRESENT(fDebugMessageInsert); 1.936 + mSymbols.fDebugMessageInsert(source, type, id, severity, length, buf); 1.937 + AFTER_GL_CALL; 1.938 + } 1.939 + 1.940 + void fDetachShader(GLuint program, GLuint shader) { 1.941 + BEFORE_GL_CALL; 1.942 + mSymbols.fDetachShader(program, shader); 1.943 + AFTER_GL_CALL; 1.944 + } 1.945 + 1.946 + void fDepthFunc(GLenum func) { 1.947 + BEFORE_GL_CALL; 1.948 + mSymbols.fDepthFunc(func); 1.949 + AFTER_GL_CALL; 1.950 + } 1.951 + 1.952 + void fDepthMask(realGLboolean flag) { 1.953 + BEFORE_GL_CALL; 1.954 + mSymbols.fDepthMask(flag); 1.955 + AFTER_GL_CALL; 1.956 + } 1.957 + 1.958 + void fDisable(GLenum capability) { 1.959 + BEFORE_GL_CALL; 1.960 + mSymbols.fDisable(capability); 1.961 + AFTER_GL_CALL; 1.962 + } 1.963 + 1.964 + void fDisableClientState(GLenum capability) { 1.965 + BEFORE_GL_CALL; 1.966 + mSymbols.fDisableClientState(capability); 1.967 + AFTER_GL_CALL; 1.968 + } 1.969 + 1.970 + void fDisableVertexAttribArray(GLuint index) { 1.971 + BEFORE_GL_CALL; 1.972 + mSymbols.fDisableVertexAttribArray(index); 1.973 + AFTER_GL_CALL; 1.974 + } 1.975 + 1.976 + void fDrawBuffer(GLenum mode) { 1.977 + BEFORE_GL_CALL; 1.978 + mSymbols.fDrawBuffer(mode); 1.979 + AFTER_GL_CALL; 1.980 + } 1.981 + 1.982 +private: 1.983 + void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) { 1.984 + BEFORE_GL_CALL; 1.985 + mSymbols.fDrawArrays(mode, first, count); 1.986 + AFTER_GL_CALL; 1.987 + } 1.988 + 1.989 + void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { 1.990 + BEFORE_GL_CALL; 1.991 + mSymbols.fDrawElements(mode, count, type, indices); 1.992 + AFTER_GL_CALL; 1.993 + } 1.994 + 1.995 +public: 1.996 + void fDrawArrays(GLenum mode, GLint first, GLsizei count) { 1.997 + BeforeGLDrawCall(); 1.998 + raw_fDrawArrays(mode, first, count); 1.999 + AfterGLDrawCall(); 1.1000 + } 1.1001 + 1.1002 + void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { 1.1003 + BeforeGLDrawCall(); 1.1004 + raw_fDrawElements(mode, count, type, indices); 1.1005 + AfterGLDrawCall(); 1.1006 + } 1.1007 + 1.1008 + void fEnable(GLenum capability) { 1.1009 + BEFORE_GL_CALL; 1.1010 + mSymbols.fEnable(capability); 1.1011 + AFTER_GL_CALL; 1.1012 + } 1.1013 + 1.1014 + void fEnableClientState(GLenum capability) { 1.1015 + BEFORE_GL_CALL; 1.1016 + mSymbols.fEnableClientState(capability); 1.1017 + AFTER_GL_CALL; 1.1018 + } 1.1019 + 1.1020 + void fEnableVertexAttribArray(GLuint index) { 1.1021 + BEFORE_GL_CALL; 1.1022 + mSymbols.fEnableVertexAttribArray(index); 1.1023 + AFTER_GL_CALL; 1.1024 + } 1.1025 + 1.1026 + void fEndQuery(GLenum target) { 1.1027 + BEFORE_GL_CALL; 1.1028 + ASSERT_SYMBOL_PRESENT(fEndQuery); 1.1029 + mSymbols.fEndQuery(target); 1.1030 + AFTER_GL_CALL; 1.1031 + } 1.1032 + 1.1033 + void fFinish() { 1.1034 + BEFORE_GL_CALL; 1.1035 + mSymbols.fFinish(); 1.1036 + AFTER_GL_CALL; 1.1037 + } 1.1038 + 1.1039 + void fFlush() { 1.1040 + BEFORE_GL_CALL; 1.1041 + mSymbols.fFlush(); 1.1042 + AFTER_GL_CALL; 1.1043 + } 1.1044 + 1.1045 + void fFrontFace(GLenum face) { 1.1046 + BEFORE_GL_CALL; 1.1047 + mSymbols.fFrontFace(face); 1.1048 + AFTER_GL_CALL; 1.1049 + } 1.1050 + 1.1051 + void fGetActiveAttrib(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { 1.1052 + BEFORE_GL_CALL; 1.1053 + mSymbols.fGetActiveAttrib(program, index, maxLength, length, size, type, name); 1.1054 + AFTER_GL_CALL; 1.1055 + } 1.1056 + 1.1057 + void fGetActiveUniform(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { 1.1058 + BEFORE_GL_CALL; 1.1059 + mSymbols.fGetActiveUniform(program, index, maxLength, length, size, type, name); 1.1060 + AFTER_GL_CALL; 1.1061 + } 1.1062 + 1.1063 + void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) { 1.1064 + BEFORE_GL_CALL; 1.1065 + mSymbols.fGetAttachedShaders(program, maxCount, count, shaders); 1.1066 + AFTER_GL_CALL; 1.1067 + } 1.1068 + 1.1069 + GLint fGetAttribLocation(GLuint program, const GLchar* name) { 1.1070 + BEFORE_GL_CALL; 1.1071 + GLint retval = mSymbols.fGetAttribLocation(program, name); 1.1072 + AFTER_GL_CALL; 1.1073 + return retval; 1.1074 + } 1.1075 + 1.1076 +private: 1.1077 + void raw_fGetIntegerv(GLenum pname, GLint *params) { 1.1078 + BEFORE_GL_CALL; 1.1079 + mSymbols.fGetIntegerv(pname, params); 1.1080 + AFTER_GL_CALL; 1.1081 + } 1.1082 + 1.1083 +public: 1.1084 + 1.1085 + void fGetIntegerv(GLenum pname, GLint *params) { 1.1086 + switch (pname) 1.1087 + { 1.1088 + // LOCAL_GL_FRAMEBUFFER_BINDING is equal to 1.1089 + // LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, 1.1090 + // so we don't need two cases. 1.1091 + case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT: 1.1092 + if (mScreen) { 1.1093 + *params = mScreen->GetDrawFB(); 1.1094 + } else { 1.1095 + raw_fGetIntegerv(pname, params); 1.1096 + } 1.1097 + break; 1.1098 + 1.1099 + case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT: 1.1100 + if (mScreen) { 1.1101 + *params = mScreen->GetReadFB(); 1.1102 + } else { 1.1103 + raw_fGetIntegerv(pname, params); 1.1104 + } 1.1105 + break; 1.1106 + 1.1107 + case LOCAL_GL_MAX_TEXTURE_SIZE: 1.1108 + MOZ_ASSERT(mMaxTextureSize>0); 1.1109 + *params = mMaxTextureSize; 1.1110 + break; 1.1111 + 1.1112 + case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE: 1.1113 + MOZ_ASSERT(mMaxCubeMapTextureSize>0); 1.1114 + *params = mMaxCubeMapTextureSize; 1.1115 + break; 1.1116 + 1.1117 + case LOCAL_GL_MAX_RENDERBUFFER_SIZE: 1.1118 + MOZ_ASSERT(mMaxRenderbufferSize>0); 1.1119 + *params = mMaxRenderbufferSize; 1.1120 + break; 1.1121 + 1.1122 + case LOCAL_GL_VIEWPORT: 1.1123 + for (size_t i = 0; i < 4; i++) { 1.1124 + params[i] = mViewportRect[i]; 1.1125 + } 1.1126 + break; 1.1127 + 1.1128 + case LOCAL_GL_SCISSOR_BOX: 1.1129 + for (size_t i = 0; i < 4; i++) { 1.1130 + params[i] = mScissorRect[i]; 1.1131 + } 1.1132 + break; 1.1133 + 1.1134 + default: 1.1135 + raw_fGetIntegerv(pname, params); 1.1136 + break; 1.1137 + } 1.1138 + } 1.1139 + 1.1140 + void GetUIntegerv(GLenum pname, GLuint *params) { 1.1141 + fGetIntegerv(pname, reinterpret_cast<GLint*>(params)); 1.1142 + } 1.1143 + 1.1144 + void fGetFloatv(GLenum pname, GLfloat *params) { 1.1145 + BEFORE_GL_CALL; 1.1146 + mSymbols.fGetFloatv(pname, params); 1.1147 + AFTER_GL_CALL; 1.1148 + } 1.1149 + 1.1150 + void fGetBooleanv(GLenum pname, realGLboolean *params) { 1.1151 + BEFORE_GL_CALL; 1.1152 + mSymbols.fGetBooleanv(pname, params); 1.1153 + AFTER_GL_CALL; 1.1154 + } 1.1155 + 1.1156 + void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { 1.1157 + BEFORE_GL_CALL; 1.1158 + mSymbols.fGetBufferParameteriv(target, pname, params); 1.1159 + AFTER_GL_CALL; 1.1160 + } 1.1161 + 1.1162 + GLuint fGetDebugMessageLog(GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog) { 1.1163 + BEFORE_GL_CALL; 1.1164 + ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog); 1.1165 + GLuint ret = mSymbols.fGetDebugMessageLog(count, bufsize, sources, types, ids, severities, lengths, messageLog); 1.1166 + AFTER_GL_CALL; 1.1167 + return ret; 1.1168 + } 1.1169 + 1.1170 + void fGetPointerv(GLenum pname, GLvoid** params) { 1.1171 + BEFORE_GL_CALL; 1.1172 + ASSERT_SYMBOL_PRESENT(fGetPointerv); 1.1173 + mSymbols.fGetPointerv(pname, params); 1.1174 + AFTER_GL_CALL; 1.1175 + } 1.1176 + 1.1177 + void fGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label) { 1.1178 + BEFORE_GL_CALL; 1.1179 + ASSERT_SYMBOL_PRESENT(fGetObjectLabel); 1.1180 + mSymbols.fGetObjectLabel(identifier, name, bufSize, length, label); 1.1181 + AFTER_GL_CALL; 1.1182 + } 1.1183 + 1.1184 + void fGetObjectPtrLabel(const GLvoid* ptr, GLsizei bufSize, GLsizei* length, GLchar* label) { 1.1185 + BEFORE_GL_CALL; 1.1186 + ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel); 1.1187 + mSymbols.fGetObjectPtrLabel(ptr, bufSize, length, label); 1.1188 + AFTER_GL_CALL; 1.1189 + } 1.1190 + 1.1191 + void fGenerateMipmap(GLenum target) { 1.1192 + BEFORE_GL_CALL; 1.1193 + mSymbols.fGenerateMipmap(target); 1.1194 + AFTER_GL_CALL; 1.1195 + } 1.1196 + 1.1197 + void fGetProgramiv(GLuint program, GLenum pname, GLint* param) { 1.1198 + BEFORE_GL_CALL; 1.1199 + mSymbols.fGetProgramiv(program, pname, param); 1.1200 + AFTER_GL_CALL; 1.1201 + } 1.1202 + 1.1203 + void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { 1.1204 + BEFORE_GL_CALL; 1.1205 + mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog); 1.1206 + AFTER_GL_CALL; 1.1207 + } 1.1208 + 1.1209 + void fTexParameteri(GLenum target, GLenum pname, GLint param) { 1.1210 + BEFORE_GL_CALL; 1.1211 + mSymbols.fTexParameteri(target, pname, param); 1.1212 + AFTER_GL_CALL; 1.1213 + } 1.1214 + 1.1215 + void fTexParameteriv(GLenum target, GLenum pname, const GLint* params) { 1.1216 + BEFORE_GL_CALL; 1.1217 + mSymbols.fTexParameteriv(target, pname, params); 1.1218 + AFTER_GL_CALL; 1.1219 + } 1.1220 + 1.1221 + void fTexParameterf(GLenum target, GLenum pname, GLfloat param) { 1.1222 + BEFORE_GL_CALL; 1.1223 + mSymbols.fTexParameterf(target, pname, param); 1.1224 + AFTER_GL_CALL; 1.1225 + } 1.1226 + 1.1227 + const GLubyte* fGetString(GLenum name) { 1.1228 + BEFORE_GL_CALL; 1.1229 + const GLubyte *result = mSymbols.fGetString(name); 1.1230 + AFTER_GL_CALL; 1.1231 + return result; 1.1232 + } 1.1233 + 1.1234 + void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *img) { 1.1235 + BEFORE_GL_CALL; 1.1236 + ASSERT_SYMBOL_PRESENT(fGetTexImage); 1.1237 + mSymbols.fGetTexImage(target, level, format, type, img); 1.1238 + AFTER_GL_CALL; 1.1239 + } 1.1240 + 1.1241 + void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) 1.1242 + { 1.1243 + BEFORE_GL_CALL; 1.1244 + ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv); 1.1245 + mSymbols.fGetTexLevelParameteriv(target, level, pname, params); 1.1246 + AFTER_GL_CALL; 1.1247 + } 1.1248 + 1.1249 + void fGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { 1.1250 + BEFORE_GL_CALL; 1.1251 + mSymbols.fGetTexParameterfv(target, pname, params); 1.1252 + AFTER_GL_CALL; 1.1253 + } 1.1254 + 1.1255 + void fGetTexParameteriv(GLenum target, GLenum pname, GLint* params) { 1.1256 + BEFORE_GL_CALL; 1.1257 + mSymbols.fGetTexParameteriv(target, pname, params); 1.1258 + AFTER_GL_CALL; 1.1259 + } 1.1260 + 1.1261 + void fGetUniformfv(GLuint program, GLint location, GLfloat* params) { 1.1262 + BEFORE_GL_CALL; 1.1263 + mSymbols.fGetUniformfv(program, location, params); 1.1264 + AFTER_GL_CALL; 1.1265 + } 1.1266 + 1.1267 + void fGetUniformiv(GLuint program, GLint location, GLint* params) { 1.1268 + BEFORE_GL_CALL; 1.1269 + mSymbols.fGetUniformiv(program, location, params); 1.1270 + AFTER_GL_CALL; 1.1271 + } 1.1272 + 1.1273 + GLint fGetUniformLocation (GLint programObj, const GLchar* name) { 1.1274 + BEFORE_GL_CALL; 1.1275 + GLint retval = mSymbols.fGetUniformLocation(programObj, name); 1.1276 + AFTER_GL_CALL; 1.1277 + return retval; 1.1278 + } 1.1279 + 1.1280 + void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) { 1.1281 + BEFORE_GL_CALL; 1.1282 + mSymbols.fGetVertexAttribfv(index, pname, retval); 1.1283 + AFTER_GL_CALL; 1.1284 + } 1.1285 + 1.1286 + void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) { 1.1287 + BEFORE_GL_CALL; 1.1288 + mSymbols.fGetVertexAttribiv(index, pname, retval); 1.1289 + AFTER_GL_CALL; 1.1290 + } 1.1291 + 1.1292 + void fGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** retval) { 1.1293 + BEFORE_GL_CALL; 1.1294 + mSymbols.fGetVertexAttribPointerv(index, pname, retval); 1.1295 + AFTER_GL_CALL; 1.1296 + } 1.1297 + 1.1298 + void fHint(GLenum target, GLenum mode) { 1.1299 + BEFORE_GL_CALL; 1.1300 + mSymbols.fHint(target, mode); 1.1301 + AFTER_GL_CALL; 1.1302 + } 1.1303 + 1.1304 + realGLboolean fIsBuffer(GLuint buffer) { 1.1305 + BEFORE_GL_CALL; 1.1306 + realGLboolean retval = mSymbols.fIsBuffer(buffer); 1.1307 + AFTER_GL_CALL; 1.1308 + return retval; 1.1309 + } 1.1310 + 1.1311 + realGLboolean fIsEnabled(GLenum capability) { 1.1312 + BEFORE_GL_CALL; 1.1313 + realGLboolean retval = mSymbols.fIsEnabled(capability); 1.1314 + AFTER_GL_CALL; 1.1315 + return retval; 1.1316 + } 1.1317 + 1.1318 + realGLboolean fIsProgram(GLuint program) { 1.1319 + BEFORE_GL_CALL; 1.1320 + realGLboolean retval = mSymbols.fIsProgram(program); 1.1321 + AFTER_GL_CALL; 1.1322 + return retval; 1.1323 + } 1.1324 + 1.1325 + realGLboolean fIsShader(GLuint shader) { 1.1326 + BEFORE_GL_CALL; 1.1327 + realGLboolean retval = mSymbols.fIsShader(shader); 1.1328 + AFTER_GL_CALL; 1.1329 + return retval; 1.1330 + } 1.1331 + 1.1332 + realGLboolean fIsTexture(GLuint texture) { 1.1333 + BEFORE_GL_CALL; 1.1334 + realGLboolean retval = mSymbols.fIsTexture(texture); 1.1335 + AFTER_GL_CALL; 1.1336 + return retval; 1.1337 + } 1.1338 + 1.1339 + void fLineWidth(GLfloat width) { 1.1340 + BEFORE_GL_CALL; 1.1341 + mSymbols.fLineWidth(width); 1.1342 + AFTER_GL_CALL; 1.1343 + } 1.1344 + 1.1345 + void fLinkProgram(GLuint program) { 1.1346 + BEFORE_GL_CALL; 1.1347 + mSymbols.fLinkProgram(program); 1.1348 + AFTER_GL_CALL; 1.1349 + } 1.1350 + 1.1351 + void fObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar* label) { 1.1352 + BEFORE_GL_CALL; 1.1353 + ASSERT_SYMBOL_PRESENT(fObjectLabel); 1.1354 + mSymbols.fObjectLabel(identifier, name, length, label); 1.1355 + AFTER_GL_CALL; 1.1356 + } 1.1357 + 1.1358 + void fObjectPtrLabel(const GLvoid* ptr, GLsizei length, const GLchar* label) { 1.1359 + BEFORE_GL_CALL; 1.1360 + ASSERT_SYMBOL_PRESENT(fObjectPtrLabel); 1.1361 + mSymbols.fObjectPtrLabel(ptr, length, label); 1.1362 + AFTER_GL_CALL; 1.1363 + } 1.1364 + 1.1365 + void fLoadIdentity() { 1.1366 + BEFORE_GL_CALL; 1.1367 + mSymbols.fLoadIdentity(); 1.1368 + AFTER_GL_CALL; 1.1369 + } 1.1370 + 1.1371 + void fLoadMatrixf(const GLfloat *matrix) { 1.1372 + BEFORE_GL_CALL; 1.1373 + mSymbols.fLoadMatrixf(matrix); 1.1374 + AFTER_GL_CALL; 1.1375 + } 1.1376 + 1.1377 + void fMatrixMode(GLenum mode) { 1.1378 + BEFORE_GL_CALL; 1.1379 + mSymbols.fMatrixMode(mode); 1.1380 + AFTER_GL_CALL; 1.1381 + } 1.1382 + 1.1383 + void fPixelStorei(GLenum pname, GLint param) { 1.1384 + BEFORE_GL_CALL; 1.1385 + mSymbols.fPixelStorei(pname, param); 1.1386 + AFTER_GL_CALL; 1.1387 + } 1.1388 + 1.1389 + void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid *pointer) { 1.1390 + BEFORE_GL_CALL; 1.1391 + mSymbols.fTextureRangeAPPLE(target, length, pointer); 1.1392 + AFTER_GL_CALL; 1.1393 + } 1.1394 + 1.1395 + void fPointParameterf(GLenum pname, GLfloat param) { 1.1396 + BEFORE_GL_CALL; 1.1397 + mSymbols.fPointParameterf(pname, param); 1.1398 + AFTER_GL_CALL; 1.1399 + } 1.1400 + 1.1401 + void fPolygonOffset(GLfloat factor, GLfloat bias) { 1.1402 + BEFORE_GL_CALL; 1.1403 + mSymbols.fPolygonOffset(factor, bias); 1.1404 + AFTER_GL_CALL; 1.1405 + } 1.1406 + 1.1407 + void fPopDebugGroup() { 1.1408 + BEFORE_GL_CALL; 1.1409 + ASSERT_SYMBOL_PRESENT(fPopDebugGroup); 1.1410 + mSymbols.fPopDebugGroup(); 1.1411 + AFTER_GL_CALL; 1.1412 + } 1.1413 + 1.1414 + void fPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar* message) { 1.1415 + BEFORE_GL_CALL; 1.1416 + ASSERT_SYMBOL_PRESENT(fPushDebugGroup); 1.1417 + mSymbols.fPushDebugGroup(source, id, length, message); 1.1418 + AFTER_GL_CALL; 1.1419 + } 1.1420 + 1.1421 + void fReadBuffer(GLenum mode) { 1.1422 + BEFORE_GL_CALL; 1.1423 + mSymbols.fReadBuffer(mode); 1.1424 + AFTER_GL_CALL; 1.1425 + } 1.1426 + 1.1427 +private: 1.1428 + void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { 1.1429 + BEFORE_GL_CALL; 1.1430 + mSymbols.fReadPixels(x, y, width, height, format, type, pixels); 1.1431 + AFTER_GL_CALL; 1.1432 + } 1.1433 + 1.1434 +public: 1.1435 + void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { 1.1436 + BeforeGLReadCall(); 1.1437 + 1.1438 + bool didReadPixels = false; 1.1439 + if (mScreen) { 1.1440 + didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels); 1.1441 + } 1.1442 + 1.1443 + if (!didReadPixels) { 1.1444 + raw_fReadPixels(x, y, width, height, format, type, pixels); 1.1445 + } 1.1446 + 1.1447 + AfterGLReadCall(); 1.1448 + } 1.1449 + 1.1450 +public: 1.1451 + void fSampleCoverage(GLclampf value, realGLboolean invert) { 1.1452 + BEFORE_GL_CALL; 1.1453 + mSymbols.fSampleCoverage(value, invert); 1.1454 + AFTER_GL_CALL; 1.1455 + } 1.1456 + 1.1457 + void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) { 1.1458 + if (mScissorRect[0] == x && 1.1459 + mScissorRect[1] == y && 1.1460 + mScissorRect[2] == width && 1.1461 + mScissorRect[3] == height) 1.1462 + { 1.1463 + return; 1.1464 + } 1.1465 + mScissorRect[0] = x; 1.1466 + mScissorRect[1] = y; 1.1467 + mScissorRect[2] = width; 1.1468 + mScissorRect[3] = height; 1.1469 + BEFORE_GL_CALL; 1.1470 + mSymbols.fScissor(x, y, width, height); 1.1471 + AFTER_GL_CALL; 1.1472 + } 1.1473 + 1.1474 + void fStencilFunc(GLenum func, GLint ref, GLuint mask) { 1.1475 + BEFORE_GL_CALL; 1.1476 + mSymbols.fStencilFunc(func, ref, mask); 1.1477 + AFTER_GL_CALL; 1.1478 + } 1.1479 + 1.1480 + void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) { 1.1481 + BEFORE_GL_CALL; 1.1482 + mSymbols.fStencilFuncSeparate(frontfunc, backfunc, ref, mask); 1.1483 + AFTER_GL_CALL; 1.1484 + } 1.1485 + 1.1486 + void fStencilMask(GLuint mask) { 1.1487 + BEFORE_GL_CALL; 1.1488 + mSymbols.fStencilMask(mask); 1.1489 + AFTER_GL_CALL; 1.1490 + } 1.1491 + 1.1492 + void fStencilMaskSeparate(GLenum face, GLuint mask) { 1.1493 + BEFORE_GL_CALL; 1.1494 + mSymbols.fStencilMaskSeparate(face, mask); 1.1495 + AFTER_GL_CALL; 1.1496 + } 1.1497 + 1.1498 + void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { 1.1499 + BEFORE_GL_CALL; 1.1500 + mSymbols.fStencilOp(fail, zfail, zpass); 1.1501 + AFTER_GL_CALL; 1.1502 + } 1.1503 + 1.1504 + void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { 1.1505 + BEFORE_GL_CALL; 1.1506 + mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass); 1.1507 + AFTER_GL_CALL; 1.1508 + } 1.1509 + 1.1510 + void fTexGeni(GLenum coord, GLenum pname, GLint param) { 1.1511 + BEFORE_GL_CALL; 1.1512 + mSymbols.fTexGeni(coord, pname, param); 1.1513 + AFTER_GL_CALL; 1.1514 + } 1.1515 + 1.1516 + void fTexGenf(GLenum coord, GLenum pname, GLfloat param) { 1.1517 + BEFORE_GL_CALL; 1.1518 + mSymbols.fTexGenf(coord, pname, param); 1.1519 + AFTER_GL_CALL; 1.1520 + } 1.1521 + 1.1522 + void fTexGenfv(GLenum coord, GLenum pname, const GLfloat *params) { 1.1523 + BEFORE_GL_CALL; 1.1524 + mSymbols.fTexGenfv(coord, pname, params); 1.1525 + AFTER_GL_CALL; 1.1526 + } 1.1527 + 1.1528 +private: 1.1529 + void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { 1.1530 + BEFORE_GL_CALL; 1.1531 + mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); 1.1532 + AFTER_GL_CALL; 1.1533 + } 1.1534 + 1.1535 +public: 1.1536 + void fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { 1.1537 + if (!IsTextureSizeSafeToPassToDriver(target, width, height)) { 1.1538 + // pass wrong values to cause the GL to generate GL_INVALID_VALUE. 1.1539 + // See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver. 1.1540 + level = -1; 1.1541 + width = -1; 1.1542 + height = -1; 1.1543 + border = -1; 1.1544 + } 1.1545 + raw_fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); 1.1546 + } 1.1547 + 1.1548 + void fTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { 1.1549 + BEFORE_GL_CALL; 1.1550 + mSymbols.fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); 1.1551 + AFTER_GL_CALL; 1.1552 + } 1.1553 + 1.1554 + void fUniform1f(GLint location, GLfloat v0) { 1.1555 + BEFORE_GL_CALL; 1.1556 + mSymbols.fUniform1f(location, v0); 1.1557 + AFTER_GL_CALL; 1.1558 + } 1.1559 + 1.1560 + void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) { 1.1561 + BEFORE_GL_CALL; 1.1562 + mSymbols.fUniform1fv(location, count, value); 1.1563 + AFTER_GL_CALL; 1.1564 + } 1.1565 + 1.1566 + void fUniform1i(GLint location, GLint v0) { 1.1567 + BEFORE_GL_CALL; 1.1568 + mSymbols.fUniform1i(location, v0); 1.1569 + AFTER_GL_CALL; 1.1570 + } 1.1571 + 1.1572 + void fUniform1iv(GLint location, GLsizei count, const GLint* value) { 1.1573 + BEFORE_GL_CALL; 1.1574 + mSymbols.fUniform1iv(location, count, value); 1.1575 + AFTER_GL_CALL; 1.1576 + } 1.1577 + 1.1578 + void fUniform2f(GLint location, GLfloat v0, GLfloat v1) { 1.1579 + BEFORE_GL_CALL; 1.1580 + mSymbols.fUniform2f(location, v0, v1); 1.1581 + AFTER_GL_CALL; 1.1582 + } 1.1583 + 1.1584 + void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) { 1.1585 + BEFORE_GL_CALL; 1.1586 + mSymbols.fUniform2fv(location, count, value); 1.1587 + AFTER_GL_CALL; 1.1588 + } 1.1589 + 1.1590 + void fUniform2i(GLint location, GLint v0, GLint v1) { 1.1591 + BEFORE_GL_CALL; 1.1592 + mSymbols.fUniform2i(location, v0, v1); 1.1593 + AFTER_GL_CALL; 1.1594 + } 1.1595 + 1.1596 + void fUniform2iv(GLint location, GLsizei count, const GLint* value) { 1.1597 + BEFORE_GL_CALL; 1.1598 + mSymbols.fUniform2iv(location, count, value); 1.1599 + AFTER_GL_CALL; 1.1600 + } 1.1601 + 1.1602 + void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { 1.1603 + BEFORE_GL_CALL; 1.1604 + mSymbols.fUniform3f(location, v0, v1, v2); 1.1605 + AFTER_GL_CALL; 1.1606 + } 1.1607 + 1.1608 + void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) { 1.1609 + BEFORE_GL_CALL; 1.1610 + mSymbols.fUniform3fv(location, count, value); 1.1611 + AFTER_GL_CALL; 1.1612 + } 1.1613 + 1.1614 + void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) { 1.1615 + BEFORE_GL_CALL; 1.1616 + mSymbols.fUniform3i(location, v0, v1, v2); 1.1617 + AFTER_GL_CALL; 1.1618 + } 1.1619 + 1.1620 + void fUniform3iv(GLint location, GLsizei count, const GLint* value) { 1.1621 + BEFORE_GL_CALL; 1.1622 + mSymbols.fUniform3iv(location, count, value); 1.1623 + AFTER_GL_CALL; 1.1624 + } 1.1625 + 1.1626 + void fUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { 1.1627 + BEFORE_GL_CALL; 1.1628 + mSymbols.fUniform4f(location, v0, v1, v2, v3); 1.1629 + AFTER_GL_CALL; 1.1630 + } 1.1631 + 1.1632 + void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) { 1.1633 + BEFORE_GL_CALL; 1.1634 + mSymbols.fUniform4fv(location, count, value); 1.1635 + AFTER_GL_CALL; 1.1636 + } 1.1637 + 1.1638 + void fUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { 1.1639 + BEFORE_GL_CALL; 1.1640 + mSymbols.fUniform4i(location, v0, v1, v2, v3); 1.1641 + AFTER_GL_CALL; 1.1642 + } 1.1643 + 1.1644 + void fUniform4iv(GLint location, GLsizei count, const GLint* value) { 1.1645 + BEFORE_GL_CALL; 1.1646 + mSymbols.fUniform4iv(location, count, value); 1.1647 + AFTER_GL_CALL; 1.1648 + } 1.1649 + 1.1650 + void fUniformMatrix2fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { 1.1651 + BEFORE_GL_CALL; 1.1652 + mSymbols.fUniformMatrix2fv(location, count, transpose, value); 1.1653 + AFTER_GL_CALL; 1.1654 + } 1.1655 + 1.1656 + void fUniformMatrix3fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { 1.1657 + BEFORE_GL_CALL; 1.1658 + mSymbols.fUniformMatrix3fv(location, count, transpose, value); 1.1659 + AFTER_GL_CALL; 1.1660 + } 1.1661 + 1.1662 + void fUniformMatrix4fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { 1.1663 + BEFORE_GL_CALL; 1.1664 + mSymbols.fUniformMatrix4fv(location, count, transpose, value); 1.1665 + AFTER_GL_CALL; 1.1666 + } 1.1667 + 1.1668 + void fUseProgram(GLuint program) { 1.1669 + BEFORE_GL_CALL; 1.1670 + mSymbols.fUseProgram(program); 1.1671 + AFTER_GL_CALL; 1.1672 + } 1.1673 + 1.1674 + void fValidateProgram(GLuint program) { 1.1675 + BEFORE_GL_CALL; 1.1676 + mSymbols.fValidateProgram(program); 1.1677 + AFTER_GL_CALL; 1.1678 + } 1.1679 + 1.1680 + void fVertexAttribPointer(GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer) { 1.1681 + BEFORE_GL_CALL; 1.1682 + mSymbols.fVertexAttribPointer(index, size, type, normalized, stride, pointer); 1.1683 + AFTER_GL_CALL; 1.1684 + } 1.1685 + 1.1686 + void fVertexAttrib1f(GLuint index, GLfloat x) { 1.1687 + BEFORE_GL_CALL; 1.1688 + mSymbols.fVertexAttrib1f(index, x); 1.1689 + AFTER_GL_CALL; 1.1690 + } 1.1691 + 1.1692 + void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) { 1.1693 + BEFORE_GL_CALL; 1.1694 + mSymbols.fVertexAttrib2f(index, x, y); 1.1695 + AFTER_GL_CALL; 1.1696 + } 1.1697 + 1.1698 + void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) { 1.1699 + BEFORE_GL_CALL; 1.1700 + mSymbols.fVertexAttrib3f(index, x, y, z); 1.1701 + AFTER_GL_CALL; 1.1702 + } 1.1703 + 1.1704 + void fVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { 1.1705 + BEFORE_GL_CALL; 1.1706 + mSymbols.fVertexAttrib4f(index, x, y, z, w); 1.1707 + AFTER_GL_CALL; 1.1708 + } 1.1709 + 1.1710 + void fVertexAttrib1fv(GLuint index, const GLfloat* v) { 1.1711 + BEFORE_GL_CALL; 1.1712 + mSymbols.fVertexAttrib1fv(index, v); 1.1713 + AFTER_GL_CALL; 1.1714 + } 1.1715 + 1.1716 + void fVertexAttrib2fv(GLuint index, const GLfloat* v) { 1.1717 + BEFORE_GL_CALL; 1.1718 + mSymbols.fVertexAttrib2fv(index, v); 1.1719 + AFTER_GL_CALL; 1.1720 + } 1.1721 + 1.1722 + void fVertexAttrib3fv(GLuint index, const GLfloat* v) { 1.1723 + BEFORE_GL_CALL; 1.1724 + mSymbols.fVertexAttrib3fv(index, v); 1.1725 + AFTER_GL_CALL; 1.1726 + } 1.1727 + 1.1728 + void fVertexAttrib4fv(GLuint index, const GLfloat* v) { 1.1729 + BEFORE_GL_CALL; 1.1730 + mSymbols.fVertexAttrib4fv(index, v); 1.1731 + AFTER_GL_CALL; 1.1732 + } 1.1733 + 1.1734 + void fVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { 1.1735 + BEFORE_GL_CALL; 1.1736 + mSymbols.fVertexPointer(size, type, stride, pointer); 1.1737 + AFTER_GL_CALL; 1.1738 + } 1.1739 + 1.1740 + void fCompileShader(GLuint shader) { 1.1741 + BEFORE_GL_CALL; 1.1742 + mSymbols.fCompileShader(shader); 1.1743 + AFTER_GL_CALL; 1.1744 + } 1.1745 + 1.1746 +private: 1.1747 + void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { 1.1748 + BEFORE_GL_CALL; 1.1749 + mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height, border); 1.1750 + AFTER_GL_CALL; 1.1751 + } 1.1752 + 1.1753 + void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { 1.1754 + BEFORE_GL_CALL; 1.1755 + mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 1.1756 + AFTER_GL_CALL; 1.1757 + } 1.1758 + 1.1759 +public: 1.1760 + void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) { 1.1761 + BEFORE_GL_CALL; 1.1762 + mSymbols.fGetShaderiv(shader, pname, param); 1.1763 + AFTER_GL_CALL; 1.1764 + } 1.1765 + 1.1766 + void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { 1.1767 + BEFORE_GL_CALL; 1.1768 + mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog); 1.1769 + AFTER_GL_CALL; 1.1770 + } 1.1771 + 1.1772 +private: 1.1773 + void raw_fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { 1.1774 + MOZ_ASSERT(IsGLES()); 1.1775 + 1.1776 + BEFORE_GL_CALL; 1.1777 + ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat); 1.1778 + mSymbols.fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); 1.1779 + AFTER_GL_CALL; 1.1780 + } 1.1781 + 1.1782 +public: 1.1783 + void fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { 1.1784 + if (IsGLES()) { 1.1785 + raw_fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); 1.1786 + } else { 1.1787 + // Fall back to automatic values because almost all desktop hardware supports the OpenGL standard precisions. 1.1788 + GetShaderPrecisionFormatNonES2(shadertype, precisiontype, range, precision); 1.1789 + } 1.1790 + } 1.1791 + 1.1792 + void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source) { 1.1793 + BEFORE_GL_CALL; 1.1794 + mSymbols.fGetShaderSource(obj, maxLength, length, source); 1.1795 + AFTER_GL_CALL; 1.1796 + } 1.1797 + 1.1798 + void fShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) { 1.1799 + BEFORE_GL_CALL; 1.1800 + mSymbols.fShaderSource(shader, count, strings, lengths); 1.1801 + AFTER_GL_CALL; 1.1802 + } 1.1803 + 1.1804 +private: 1.1805 + void raw_fBindFramebuffer(GLenum target, GLuint framebuffer) { 1.1806 + BEFORE_GL_CALL; 1.1807 + mSymbols.fBindFramebuffer(target, framebuffer); 1.1808 + AFTER_GL_CALL; 1.1809 + } 1.1810 + 1.1811 +public: 1.1812 + void fBindRenderbuffer(GLenum target, GLuint renderbuffer) { 1.1813 + BEFORE_GL_CALL; 1.1814 + mSymbols.fBindRenderbuffer(target, renderbuffer); 1.1815 + AFTER_GL_CALL; 1.1816 + } 1.1817 + 1.1818 + GLenum fCheckFramebufferStatus(GLenum target) { 1.1819 + BEFORE_GL_CALL; 1.1820 + GLenum retval = mSymbols.fCheckFramebufferStatus(target); 1.1821 + AFTER_GL_CALL; 1.1822 + return retval; 1.1823 + } 1.1824 + 1.1825 + void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer) { 1.1826 + BEFORE_GL_CALL; 1.1827 + mSymbols.fFramebufferRenderbuffer(target, attachmentPoint, renderbufferTarget, renderbuffer); 1.1828 + AFTER_GL_CALL; 1.1829 + } 1.1830 + 1.1831 + void fFramebufferTexture2D(GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level) { 1.1832 + BEFORE_GL_CALL; 1.1833 + mSymbols.fFramebufferTexture2D(target, attachmentPoint, textureTarget, texture, level); 1.1834 + AFTER_GL_CALL; 1.1835 + } 1.1836 + 1.1837 + void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* value) { 1.1838 + BEFORE_GL_CALL; 1.1839 + mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname, value); 1.1840 + AFTER_GL_CALL; 1.1841 + } 1.1842 + 1.1843 + void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) { 1.1844 + BEFORE_GL_CALL; 1.1845 + mSymbols.fGetRenderbufferParameteriv(target, pname, value); 1.1846 + AFTER_GL_CALL; 1.1847 + } 1.1848 + 1.1849 + realGLboolean fIsFramebuffer (GLuint framebuffer) { 1.1850 + BEFORE_GL_CALL; 1.1851 + realGLboolean retval = mSymbols.fIsFramebuffer(framebuffer); 1.1852 + AFTER_GL_CALL; 1.1853 + return retval; 1.1854 + } 1.1855 + 1.1856 +public: 1.1857 + realGLboolean fIsRenderbuffer (GLuint renderbuffer) { 1.1858 + BEFORE_GL_CALL; 1.1859 + realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer); 1.1860 + AFTER_GL_CALL; 1.1861 + return retval; 1.1862 + } 1.1863 + 1.1864 + void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { 1.1865 + BEFORE_GL_CALL; 1.1866 + mSymbols.fRenderbufferStorage(target, internalFormat, width, height); 1.1867 + AFTER_GL_CALL; 1.1868 + } 1.1869 + 1.1870 +private: 1.1871 + void raw_fDepthRange(GLclampf a, GLclampf b) { 1.1872 + MOZ_ASSERT(!IsGLES()); 1.1873 + 1.1874 + BEFORE_GL_CALL; 1.1875 + ASSERT_SYMBOL_PRESENT(fDepthRange); 1.1876 + mSymbols.fDepthRange(a, b); 1.1877 + AFTER_GL_CALL; 1.1878 + } 1.1879 + 1.1880 + void raw_fDepthRangef(GLclampf a, GLclampf b) { 1.1881 + MOZ_ASSERT(IsGLES()); 1.1882 + 1.1883 + BEFORE_GL_CALL; 1.1884 + ASSERT_SYMBOL_PRESENT(fDepthRangef); 1.1885 + mSymbols.fDepthRangef(a, b); 1.1886 + AFTER_GL_CALL; 1.1887 + } 1.1888 + 1.1889 + void raw_fClearDepth(GLclampf v) { 1.1890 + MOZ_ASSERT(!IsGLES()); 1.1891 + 1.1892 + BEFORE_GL_CALL; 1.1893 + ASSERT_SYMBOL_PRESENT(fClearDepth); 1.1894 + mSymbols.fClearDepth(v); 1.1895 + AFTER_GL_CALL; 1.1896 + } 1.1897 + 1.1898 + void raw_fClearDepthf(GLclampf v) { 1.1899 + MOZ_ASSERT(IsGLES()); 1.1900 + 1.1901 + BEFORE_GL_CALL; 1.1902 + ASSERT_SYMBOL_PRESENT(fClearDepthf); 1.1903 + mSymbols.fClearDepthf(v); 1.1904 + AFTER_GL_CALL; 1.1905 + } 1.1906 + 1.1907 +public: 1.1908 + void fDepthRange(GLclampf a, GLclampf b) { 1.1909 + if (IsGLES()) { 1.1910 + raw_fDepthRangef(a, b); 1.1911 + } else { 1.1912 + raw_fDepthRange(a, b); 1.1913 + } 1.1914 + } 1.1915 + 1.1916 + void fClearDepth(GLclampf v) { 1.1917 + if (IsGLES()) { 1.1918 + raw_fClearDepthf(v); 1.1919 + } else { 1.1920 + raw_fClearDepth(v); 1.1921 + } 1.1922 + } 1.1923 + 1.1924 + void* fMapBuffer(GLenum target, GLenum access) { 1.1925 + BEFORE_GL_CALL; 1.1926 + ASSERT_SYMBOL_PRESENT(fMapBuffer); 1.1927 + void *ret = mSymbols.fMapBuffer(target, access); 1.1928 + AFTER_GL_CALL; 1.1929 + return ret; 1.1930 + } 1.1931 + 1.1932 + realGLboolean fUnmapBuffer(GLenum target) { 1.1933 + BEFORE_GL_CALL; 1.1934 + ASSERT_SYMBOL_PRESENT(fUnmapBuffer); 1.1935 + realGLboolean ret = mSymbols.fUnmapBuffer(target); 1.1936 + AFTER_GL_CALL; 1.1937 + return ret; 1.1938 + } 1.1939 + 1.1940 + 1.1941 +private: 1.1942 + GLuint raw_fCreateProgram() { 1.1943 + BEFORE_GL_CALL; 1.1944 + GLuint ret = mSymbols.fCreateProgram(); 1.1945 + AFTER_GL_CALL; 1.1946 + return ret; 1.1947 + } 1.1948 + 1.1949 + GLuint raw_fCreateShader(GLenum t) { 1.1950 + BEFORE_GL_CALL; 1.1951 + GLuint ret = mSymbols.fCreateShader(t); 1.1952 + AFTER_GL_CALL; 1.1953 + return ret; 1.1954 + } 1.1955 + 1.1956 + void raw_fGenBuffers(GLsizei n, GLuint* names) { 1.1957 + BEFORE_GL_CALL; 1.1958 + mSymbols.fGenBuffers(n, names); 1.1959 + AFTER_GL_CALL; 1.1960 + } 1.1961 + 1.1962 + void raw_fGenFramebuffers(GLsizei n, GLuint* names) { 1.1963 + BEFORE_GL_CALL; 1.1964 + mSymbols.fGenFramebuffers(n, names); 1.1965 + AFTER_GL_CALL; 1.1966 + } 1.1967 + 1.1968 + void raw_fGenRenderbuffers(GLsizei n, GLuint* names) { 1.1969 + BEFORE_GL_CALL; 1.1970 + mSymbols.fGenRenderbuffers(n, names); 1.1971 + AFTER_GL_CALL; 1.1972 + } 1.1973 + 1.1974 + void raw_fGenTextures(GLsizei n, GLuint* names) { 1.1975 + BEFORE_GL_CALL; 1.1976 + mSymbols.fGenTextures(n, names); 1.1977 + AFTER_GL_CALL; 1.1978 + } 1.1979 + 1.1980 +public: 1.1981 + GLuint fCreateProgram() { 1.1982 + GLuint ret = raw_fCreateProgram(); 1.1983 + TRACKING_CONTEXT(CreatedProgram(this, ret)); 1.1984 + return ret; 1.1985 + } 1.1986 + 1.1987 + GLuint fCreateShader(GLenum t) { 1.1988 + GLuint ret = raw_fCreateShader(t); 1.1989 + TRACKING_CONTEXT(CreatedShader(this, ret)); 1.1990 + return ret; 1.1991 + } 1.1992 + 1.1993 + void fGenBuffers(GLsizei n, GLuint* names) { 1.1994 + raw_fGenBuffers(n, names); 1.1995 + TRACKING_CONTEXT(CreatedBuffers(this, n, names)); 1.1996 + } 1.1997 + 1.1998 + void fGenFramebuffers(GLsizei n, GLuint* names) { 1.1999 + raw_fGenFramebuffers(n, names); 1.2000 + TRACKING_CONTEXT(CreatedFramebuffers(this, n, names)); 1.2001 + } 1.2002 + 1.2003 + void fGenRenderbuffers(GLsizei n, GLuint* names) { 1.2004 + raw_fGenRenderbuffers(n, names); 1.2005 + TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names)); 1.2006 + } 1.2007 + 1.2008 + void fGenTextures(GLsizei n, GLuint* names) { 1.2009 + raw_fGenTextures(n, names); 1.2010 + TRACKING_CONTEXT(CreatedTextures(this, n, names)); 1.2011 + } 1.2012 + 1.2013 +private: 1.2014 + void raw_fDeleteProgram(GLuint program) { 1.2015 + BEFORE_GL_CALL; 1.2016 + mSymbols.fDeleteProgram(program); 1.2017 + AFTER_GL_CALL; 1.2018 + } 1.2019 + 1.2020 + void raw_fDeleteShader(GLuint shader) { 1.2021 + BEFORE_GL_CALL; 1.2022 + mSymbols.fDeleteShader(shader); 1.2023 + AFTER_GL_CALL; 1.2024 + } 1.2025 + 1.2026 + void raw_fDeleteBuffers(GLsizei n, const GLuint* names) { 1.2027 + BEFORE_GL_CALL; 1.2028 + mSymbols.fDeleteBuffers(n, names); 1.2029 + AFTER_GL_CALL; 1.2030 + } 1.2031 + 1.2032 + void raw_fDeleteFramebuffers(GLsizei n, const GLuint* names) { 1.2033 + BEFORE_GL_CALL; 1.2034 + mSymbols.fDeleteFramebuffers(n, names); 1.2035 + AFTER_GL_CALL; 1.2036 + } 1.2037 + 1.2038 + void raw_fDeleteRenderbuffers(GLsizei n, const GLuint* names) { 1.2039 + BEFORE_GL_CALL; 1.2040 + mSymbols.fDeleteRenderbuffers(n, names); 1.2041 + AFTER_GL_CALL; 1.2042 + } 1.2043 + 1.2044 + void raw_fDeleteTextures(GLsizei n, const GLuint* names) { 1.2045 + BEFORE_GL_CALL; 1.2046 + mSymbols.fDeleteTextures(n, names); 1.2047 + AFTER_GL_CALL; 1.2048 + } 1.2049 + 1.2050 +public: 1.2051 + 1.2052 + void fDeleteProgram(GLuint program) { 1.2053 + raw_fDeleteProgram(program); 1.2054 + TRACKING_CONTEXT(DeletedProgram(this, program)); 1.2055 + } 1.2056 + 1.2057 + void fDeleteShader(GLuint shader) { 1.2058 + raw_fDeleteShader(shader); 1.2059 + TRACKING_CONTEXT(DeletedShader(this, shader)); 1.2060 + } 1.2061 + 1.2062 + void fDeleteBuffers(GLsizei n, const GLuint* names) { 1.2063 + raw_fDeleteBuffers(n, names); 1.2064 + TRACKING_CONTEXT(DeletedBuffers(this, n, names)); 1.2065 + } 1.2066 + 1.2067 + void fDeleteFramebuffers(GLsizei n, const GLuint* names) { 1.2068 + if (mScreen) { 1.2069 + // Notify mScreen which framebuffers we're deleting. 1.2070 + // Otherwise, we will get framebuffer binding mispredictions. 1.2071 + for (int i = 0; i < n; i++) { 1.2072 + mScreen->DeletingFB(names[i]); 1.2073 + } 1.2074 + } 1.2075 + 1.2076 + if (n == 1 && *names == 0) { 1.2077 + // Deleting framebuffer 0 causes hangs on the DROID. See bug 623228. 1.2078 + } else { 1.2079 + raw_fDeleteFramebuffers(n, names); 1.2080 + } 1.2081 + TRACKING_CONTEXT(DeletedFramebuffers(this, n, names)); 1.2082 + } 1.2083 + 1.2084 + void fDeleteRenderbuffers(GLsizei n, const GLuint* names) { 1.2085 + raw_fDeleteRenderbuffers(n, names); 1.2086 + TRACKING_CONTEXT(DeletedRenderbuffers(this, n, names)); 1.2087 + } 1.2088 + 1.2089 + void fDeleteTextures(GLsizei n, const GLuint* names) { 1.2090 + raw_fDeleteTextures(n, names); 1.2091 + TRACKING_CONTEXT(DeletedTextures(this, n, names)); 1.2092 + } 1.2093 + 1.2094 + GLenum fGetGraphicsResetStatus() { 1.2095 + MOZ_ASSERT(mHasRobustness); 1.2096 + 1.2097 + BEFORE_GL_CALL; 1.2098 + ASSERT_SYMBOL_PRESENT(fGetGraphicsResetStatus); 1.2099 + GLenum ret = mSymbols.fGetGraphicsResetStatus(); 1.2100 + AFTER_GL_CALL; 1.2101 + return ret; 1.2102 + } 1.2103 + 1.2104 + 1.2105 +// ----------------------------------------------------------------------------- 1.2106 +// Extension ARB_sync (GL) 1.2107 +public: 1.2108 + GLsync fFenceSync(GLenum condition, GLbitfield flags) { 1.2109 + BEFORE_GL_CALL; 1.2110 + ASSERT_SYMBOL_PRESENT(fFenceSync); 1.2111 + GLsync ret = mSymbols.fFenceSync(condition, flags); 1.2112 + AFTER_GL_CALL; 1.2113 + return ret; 1.2114 + } 1.2115 + 1.2116 + realGLboolean fIsSync(GLsync sync) { 1.2117 + BEFORE_GL_CALL; 1.2118 + ASSERT_SYMBOL_PRESENT(fIsSync); 1.2119 + realGLboolean ret = mSymbols.fIsSync(sync); 1.2120 + AFTER_GL_CALL; 1.2121 + return ret; 1.2122 + } 1.2123 + 1.2124 + void fDeleteSync(GLsync sync) { 1.2125 + BEFORE_GL_CALL; 1.2126 + ASSERT_SYMBOL_PRESENT(fDeleteSync); 1.2127 + mSymbols.fDeleteSync(sync); 1.2128 + AFTER_GL_CALL; 1.2129 + } 1.2130 + 1.2131 + GLenum fClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { 1.2132 + BEFORE_GL_CALL; 1.2133 + ASSERT_SYMBOL_PRESENT(fClientWaitSync); 1.2134 + GLenum ret = mSymbols.fClientWaitSync(sync, flags, timeout); 1.2135 + AFTER_GL_CALL; 1.2136 + return ret; 1.2137 + } 1.2138 + 1.2139 + void fWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { 1.2140 + BEFORE_GL_CALL; 1.2141 + ASSERT_SYMBOL_PRESENT(fWaitSync); 1.2142 + mSymbols.fWaitSync(sync, flags, timeout); 1.2143 + AFTER_GL_CALL; 1.2144 + } 1.2145 + 1.2146 + void fGetInteger64v(GLenum pname, GLint64 *params) { 1.2147 + BEFORE_GL_CALL; 1.2148 + ASSERT_SYMBOL_PRESENT(fGetInteger64v); 1.2149 + mSymbols.fGetInteger64v(pname, params); 1.2150 + AFTER_GL_CALL; 1.2151 + } 1.2152 + 1.2153 + void fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) { 1.2154 + BEFORE_GL_CALL; 1.2155 + ASSERT_SYMBOL_PRESENT(fGetSynciv); 1.2156 + mSymbols.fGetSynciv(sync, pname, bufSize, length, values); 1.2157 + AFTER_GL_CALL; 1.2158 + } 1.2159 + 1.2160 + 1.2161 +// ----------------------------------------------------------------------------- 1.2162 +// Extension OES_EGL_image (GLES) 1.2163 +public: 1.2164 + void fEGLImageTargetTexture2D(GLenum target, GLeglImage image) { 1.2165 + BEFORE_GL_CALL; 1.2166 + ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D); 1.2167 + mSymbols.fEGLImageTargetTexture2D(target, image); 1.2168 + AFTER_GL_CALL; 1.2169 + } 1.2170 + 1.2171 + void fEGLImageTargetRenderbufferStorage(GLenum target, GLeglImage image) 1.2172 + { 1.2173 + BEFORE_GL_CALL; 1.2174 + ASSERT_SYMBOL_PRESENT(fEGLImageTargetRenderbufferStorage); 1.2175 + mSymbols.fEGLImageTargetRenderbufferStorage(target, image); 1.2176 + AFTER_GL_CALL; 1.2177 + } 1.2178 + 1.2179 + 1.2180 +// ----------------------------------------------------------------------------- 1.2181 +// Package XXX_bind_buffer_offset 1.2182 +public: 1.2183 + void fBindBufferOffset(GLenum target, GLuint index, GLuint buffer, GLintptr offset) 1.2184 + { 1.2185 + BEFORE_GL_CALL; 1.2186 + ASSERT_SYMBOL_PRESENT(fBindBufferOffset); 1.2187 + mSymbols.fBindBufferOffset(target, index, buffer, offset); 1.2188 + AFTER_GL_CALL; 1.2189 + } 1.2190 + 1.2191 + 1.2192 +// ----------------------------------------------------------------------------- 1.2193 +// Package XXX_draw_buffers 1.2194 +public: 1.2195 + void fDrawBuffers(GLsizei n, const GLenum* bufs) { 1.2196 + BEFORE_GL_CALL; 1.2197 + mSymbols.fDrawBuffers(n, bufs); 1.2198 + AFTER_GL_CALL; 1.2199 + } 1.2200 + 1.2201 + 1.2202 +// ----------------------------------------------------------------------------- 1.2203 +// Package XXX_draw_instanced 1.2204 +public: 1.2205 + void fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) 1.2206 + { 1.2207 + BeforeGLDrawCall(); 1.2208 + raw_fDrawArraysInstanced(mode, first, count, primcount); 1.2209 + AfterGLDrawCall(); 1.2210 + } 1.2211 + 1.2212 + void fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei primcount) 1.2213 + { 1.2214 + BeforeGLDrawCall(); 1.2215 + raw_fDrawElementsInstanced(mode, count, type, indices, primcount); 1.2216 + AfterGLDrawCall(); 1.2217 + } 1.2218 + 1.2219 +private: 1.2220 + void raw_fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) 1.2221 + { 1.2222 + BEFORE_GL_CALL; 1.2223 + ASSERT_SYMBOL_PRESENT(fDrawArraysInstanced); 1.2224 + mSymbols.fDrawArraysInstanced(mode, first, count, primcount); 1.2225 + AFTER_GL_CALL; 1.2226 + } 1.2227 + 1.2228 + void raw_fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei primcount) 1.2229 + { 1.2230 + BEFORE_GL_CALL; 1.2231 + ASSERT_SYMBOL_PRESENT(fDrawElementsInstanced); 1.2232 + mSymbols.fDrawElementsInstanced(mode, count, type, indices, primcount); 1.2233 + AFTER_GL_CALL; 1.2234 + } 1.2235 + 1.2236 +// ----------------------------------------------------------------------------- 1.2237 +// Feature draw_range_elements 1.2238 +public: 1.2239 + void fDrawRangeElements(GLenum mode, GLuint start, GLuint end, 1.2240 + GLsizei count, GLenum type, const GLvoid* indices) 1.2241 + { 1.2242 + BeforeGLDrawCall(); 1.2243 + raw_fDrawRangeElements(mode, start, end, count, type, indices); 1.2244 + AfterGLDrawCall(); 1.2245 + } 1.2246 + 1.2247 +private: 1.2248 + void raw_fDrawRangeElements(GLenum mode, GLuint start, GLuint end, 1.2249 + GLsizei count, GLenum type, const GLvoid* indices) 1.2250 + { 1.2251 + BEFORE_GL_CALL; 1.2252 + ASSERT_SYMBOL_PRESENT(fDrawRangeElements); 1.2253 + mSymbols.fDrawRangeElements(mode, start, end, count, type, indices); 1.2254 + AFTER_GL_CALL; 1.2255 + } 1.2256 + 1.2257 +// ----------------------------------------------------------------------------- 1.2258 +// Package XXX_framebuffer_blit 1.2259 +public: 1.2260 + // Draw/Read 1.2261 + void fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { 1.2262 + BeforeGLDrawCall(); 1.2263 + BeforeGLReadCall(); 1.2264 + raw_fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 1.2265 + AfterGLReadCall(); 1.2266 + AfterGLDrawCall(); 1.2267 + } 1.2268 + 1.2269 + 1.2270 +private: 1.2271 + void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { 1.2272 + BEFORE_GL_CALL; 1.2273 + ASSERT_SYMBOL_PRESENT(fBlitFramebuffer); 1.2274 + mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 1.2275 + AFTER_GL_CALL; 1.2276 + } 1.2277 + 1.2278 + 1.2279 +// ----------------------------------------------------------------------------- 1.2280 +// Package XXX_framebuffer_multisample 1.2281 +public: 1.2282 + void fRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) { 1.2283 + BEFORE_GL_CALL; 1.2284 + ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample); 1.2285 + mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat, width, height); 1.2286 + AFTER_GL_CALL; 1.2287 + } 1.2288 + 1.2289 + 1.2290 +// ----------------------------------------------------------------------------- 1.2291 +// Package XXX_instanced_arrays 1.2292 +public: 1.2293 + void fVertexAttribDivisor(GLuint index, GLuint divisor) 1.2294 + { 1.2295 + BEFORE_GL_CALL; 1.2296 + ASSERT_SYMBOL_PRESENT(fVertexAttribDivisor); 1.2297 + mSymbols.fVertexAttribDivisor(index, divisor); 1.2298 + AFTER_GL_CALL; 1.2299 + } 1.2300 + 1.2301 + 1.2302 +// ----------------------------------------------------------------------------- 1.2303 +// Package XXX_query_objects 1.2304 +/** 1.2305 + * XXX_query_objects: 1.2306 + * - provide all followed entry points 1.2307 + * 1.2308 + * XXX_occlusion_query2: 1.2309 + * - depends on XXX_query_objects 1.2310 + * - provide ANY_SAMPLES_PASSED 1.2311 + * 1.2312 + * XXX_occlusion_query_boolean: 1.2313 + * - depends on XXX_occlusion_query2 1.2314 + * - provide ANY_SAMPLES_PASSED_CONSERVATIVE 1.2315 + */ 1.2316 +public: 1.2317 + void fDeleteQueries(GLsizei n, const GLuint* names) { 1.2318 + BEFORE_GL_CALL; 1.2319 + ASSERT_SYMBOL_PRESENT(fDeleteQueries); 1.2320 + mSymbols.fDeleteQueries(n, names); 1.2321 + AFTER_GL_CALL; 1.2322 + TRACKING_CONTEXT(DeletedQueries(this, n, names)); 1.2323 + } 1.2324 + 1.2325 + void fGenQueries(GLsizei n, GLuint* names) { 1.2326 + BEFORE_GL_CALL; 1.2327 + ASSERT_SYMBOL_PRESENT(fGenQueries); 1.2328 + mSymbols.fGenQueries(n, names); 1.2329 + AFTER_GL_CALL; 1.2330 + TRACKING_CONTEXT(CreatedQueries(this, n, names)); 1.2331 + } 1.2332 + 1.2333 + void fGetQueryiv(GLenum target, GLenum pname, GLint* params) { 1.2334 + BEFORE_GL_CALL; 1.2335 + ASSERT_SYMBOL_PRESENT(fGetQueryiv); 1.2336 + mSymbols.fGetQueryiv(target, pname, params); 1.2337 + AFTER_GL_CALL; 1.2338 + } 1.2339 + 1.2340 + void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) { 1.2341 + BEFORE_GL_CALL; 1.2342 + ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv); 1.2343 + mSymbols.fGetQueryObjectuiv(id, pname, params); 1.2344 + AFTER_GL_CALL; 1.2345 + } 1.2346 + 1.2347 + realGLboolean fIsQuery(GLuint query) { 1.2348 + BEFORE_GL_CALL; 1.2349 + ASSERT_SYMBOL_PRESENT(fIsQuery); 1.2350 + realGLboolean retval = mSymbols.fIsQuery(query); 1.2351 + AFTER_GL_CALL; 1.2352 + return retval; 1.2353 + } 1.2354 + 1.2355 + 1.2356 +// ----------------------------------------------------------------------------- 1.2357 +// Package XXX_get_query_object_iv 1.2358 +/** 1.2359 + * XXX_get_query_object_iv: 1.2360 + * - depends on XXX_query_objects 1.2361 + * - provide the followed entry point 1.2362 + * 1.2363 + * XXX_occlusion_query: 1.2364 + * - depends on XXX_get_query_object_iv 1.2365 + * - provide LOCAL_GL_SAMPLES_PASSED 1.2366 + */ 1.2367 +public: 1.2368 + void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) { 1.2369 + BEFORE_GL_CALL; 1.2370 + ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv); 1.2371 + mSymbols.fGetQueryObjectiv(id, pname, params); 1.2372 + AFTER_GL_CALL; 1.2373 + } 1.2374 + 1.2375 + 1.2376 +// ----------------------------------------------------------------------------- 1.2377 +// Package XXX_transform_feedback 1.2378 +public: 1.2379 + void fBindBufferBase(GLenum target, GLuint index, GLuint buffer) 1.2380 + { 1.2381 + BEFORE_GL_CALL; 1.2382 + ASSERT_SYMBOL_PRESENT(fBindBufferBase); 1.2383 + mSymbols.fBindBufferBase(target, index, buffer); 1.2384 + AFTER_GL_CALL; 1.2385 + } 1.2386 + 1.2387 + void fBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) 1.2388 + { 1.2389 + BEFORE_GL_CALL; 1.2390 + ASSERT_SYMBOL_PRESENT(fBindBufferRange); 1.2391 + mSymbols.fBindBufferRange(target, index, buffer, offset, size); 1.2392 + AFTER_GL_CALL; 1.2393 + } 1.2394 + 1.2395 + void fBeginTransformFeedback(GLenum primitiveMode) 1.2396 + { 1.2397 + BEFORE_GL_CALL; 1.2398 + ASSERT_SYMBOL_PRESENT(fBeginTransformFeedback); 1.2399 + mSymbols.fBeginTransformFeedback(primitiveMode); 1.2400 + AFTER_GL_CALL; 1.2401 + } 1.2402 + 1.2403 + void fEndTransformFeedback() 1.2404 + { 1.2405 + BEFORE_GL_CALL; 1.2406 + ASSERT_SYMBOL_PRESENT(fEndTransformFeedback); 1.2407 + mSymbols.fEndTransformFeedback(); 1.2408 + AFTER_GL_CALL; 1.2409 + } 1.2410 + 1.2411 + void fTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) 1.2412 + { 1.2413 + BEFORE_GL_CALL; 1.2414 + ASSERT_SYMBOL_PRESENT(fTransformFeedbackVaryings); 1.2415 + mSymbols.fTransformFeedbackVaryings(program, count, varyings, bufferMode); 1.2416 + AFTER_GL_CALL; 1.2417 + } 1.2418 + 1.2419 + void fGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) 1.2420 + { 1.2421 + BEFORE_GL_CALL; 1.2422 + ASSERT_SYMBOL_PRESENT(fGetTransformFeedbackVarying); 1.2423 + mSymbols.fGetTransformFeedbackVarying(program, index, bufSize, length, size, type, name); 1.2424 + AFTER_GL_CALL; 1.2425 + } 1.2426 + 1.2427 + void fGetIntegeri_v(GLenum param, GLuint index, GLint* values) 1.2428 + { 1.2429 + BEFORE_GL_CALL; 1.2430 + ASSERT_SYMBOL_PRESENT(fGetIntegeri_v); 1.2431 + mSymbols.fGetIntegeri_v(param, index, values); 1.2432 + AFTER_GL_CALL; 1.2433 + } 1.2434 + 1.2435 + 1.2436 +// ----------------------------------------------------------------------------- 1.2437 +// Package XXX_vertex_array_object 1.2438 +public: 1.2439 + void fBindVertexArray(GLuint array) 1.2440 + { 1.2441 + BEFORE_GL_CALL; 1.2442 + ASSERT_SYMBOL_PRESENT(fBindVertexArray); 1.2443 + mSymbols.fBindVertexArray(array); 1.2444 + AFTER_GL_CALL; 1.2445 + } 1.2446 + 1.2447 + void fDeleteVertexArrays(GLsizei n, const GLuint *arrays) 1.2448 + { 1.2449 + BEFORE_GL_CALL; 1.2450 + ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays); 1.2451 + mSymbols.fDeleteVertexArrays(n, arrays); 1.2452 + AFTER_GL_CALL; 1.2453 + } 1.2454 + 1.2455 + void fGenVertexArrays(GLsizei n, GLuint *arrays) 1.2456 + { 1.2457 + BEFORE_GL_CALL; 1.2458 + ASSERT_SYMBOL_PRESENT(fGenVertexArrays); 1.2459 + mSymbols.fGenVertexArrays(n, arrays); 1.2460 + AFTER_GL_CALL; 1.2461 + } 1.2462 + 1.2463 + realGLboolean fIsVertexArray(GLuint array) 1.2464 + { 1.2465 + BEFORE_GL_CALL; 1.2466 + ASSERT_SYMBOL_PRESENT(fIsVertexArray); 1.2467 + realGLboolean ret = mSymbols.fIsVertexArray(array); 1.2468 + AFTER_GL_CALL; 1.2469 + return ret; 1.2470 + } 1.2471 + 1.2472 + 1.2473 +// ----------------------------------------------------------------------------- 1.2474 +// Constructor 1.2475 +public: 1.2476 + 1.2477 + typedef struct gfx::SurfaceCaps SurfaceCaps; 1.2478 + 1.2479 + 1.2480 +protected: 1.2481 + GLContext(const SurfaceCaps& caps, 1.2482 + GLContext* sharedContext = nullptr, 1.2483 + bool isOffscreen = false); 1.2484 + 1.2485 + 1.2486 +// ----------------------------------------------------------------------------- 1.2487 +// Destructor 1.2488 +public: 1.2489 + virtual ~GLContext(); 1.2490 + 1.2491 + 1.2492 +// ----------------------------------------------------------------------------- 1.2493 +// Everything that isn't standard GL APIs 1.2494 +protected: 1.2495 + typedef class gfx::SharedSurface SharedSurface; 1.2496 + typedef gfx::SharedSurfaceType SharedSurfaceType; 1.2497 + typedef gfx::SurfaceFormat SurfaceFormat; 1.2498 + 1.2499 + virtual bool MakeCurrentImpl(bool aForce) = 0; 1.2500 + 1.2501 +public: 1.2502 +#ifdef MOZ_ENABLE_GL_TRACKING 1.2503 + static void StaticInit() { 1.2504 + PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr); 1.2505 + } 1.2506 +#endif 1.2507 + 1.2508 + bool MakeCurrent(bool aForce = false) { 1.2509 + if (IsDestroyed()) { 1.2510 + return false; 1.2511 + } 1.2512 +#ifdef MOZ_ENABLE_GL_TRACKING 1.2513 + PR_SetThreadPrivate(sCurrentGLContextTLS, this); 1.2514 + 1.2515 + // XXX this assertion is disabled because it's triggering on Mac; 1.2516 + // we need to figure out why and reenable it. 1.2517 +#if 0 1.2518 + // IsOwningThreadCurrent is a bit of a misnomer; 1.2519 + // the "owning thread" is the creation thread, 1.2520 + // and the only thread that can own this. We don't 1.2521 + // support contexts used on multiple threads. 1.2522 + NS_ASSERTION(IsOwningThreadCurrent(), 1.2523 + "MakeCurrent() called on different thread than this context was created on!"); 1.2524 +#endif 1.2525 +#endif 1.2526 + return MakeCurrentImpl(aForce); 1.2527 + } 1.2528 + 1.2529 + virtual bool Init() = 0; 1.2530 + 1.2531 + virtual bool SetupLookupFunction() = 0; 1.2532 + 1.2533 + virtual void ReleaseSurface() {} 1.2534 + 1.2535 + // Mark this context as destroyed. This will nullptr out all 1.2536 + // the GL function pointers! 1.2537 + void MarkDestroyed(); 1.2538 + 1.2539 + bool IsDestroyed() { 1.2540 + // MarkDestroyed will mark all these as null. 1.2541 + return mSymbols.fUseProgram == nullptr; 1.2542 + } 1.2543 + 1.2544 + GLContext *GetSharedContext() { return mSharedContext; } 1.2545 + 1.2546 + /** 1.2547 + * Returns true if the thread on which this context was created is the currently 1.2548 + * executing thread. 1.2549 + */ 1.2550 + bool IsOwningThreadCurrent(); 1.2551 + void DispatchToOwningThread(nsIRunnable *event); 1.2552 + 1.2553 + static void PlatformStartup(); 1.2554 + 1.2555 +public: 1.2556 + /** 1.2557 + * If this context wraps a double-buffered target, swap the back 1.2558 + * and front buffers. It should be assumed that after a swap, the 1.2559 + * contents of the new back buffer are undefined. 1.2560 + */ 1.2561 + virtual bool SwapBuffers() { return false; } 1.2562 + 1.2563 + /** 1.2564 + * Defines a two-dimensional texture image for context target surface 1.2565 + */ 1.2566 + virtual bool BindTexImage() { return false; } 1.2567 + /* 1.2568 + * Releases a color buffer that is being used as a texture 1.2569 + */ 1.2570 + virtual bool ReleaseTexImage() { return false; } 1.2571 + 1.2572 + // Before reads from offscreen texture 1.2573 + void GuaranteeResolve(); 1.2574 + 1.2575 + /* 1.2576 + * Resize the current offscreen buffer. Returns true on success. 1.2577 + * If it returns false, the context should be treated as unusable 1.2578 + * and should be recreated. After the resize, the viewport is not 1.2579 + * changed; glViewport should be called as appropriate. 1.2580 + * 1.2581 + * Only valid if IsOffscreen() returns true. 1.2582 + */ 1.2583 + bool ResizeOffscreen(const gfx::IntSize& size) { 1.2584 + return ResizeScreenBuffer(size); 1.2585 + } 1.2586 + 1.2587 + /* 1.2588 + * Return size of this offscreen context. 1.2589 + * 1.2590 + * Only valid if IsOffscreen() returns true. 1.2591 + */ 1.2592 + const gfx::IntSize& OffscreenSize() const; 1.2593 + 1.2594 + void BindFB(GLuint fb) { 1.2595 + fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb); 1.2596 + MOZ_ASSERT(!fb || fIsFramebuffer(fb)); 1.2597 + } 1.2598 + 1.2599 + void BindDrawFB(GLuint fb) { 1.2600 + fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, fb); 1.2601 + } 1.2602 + 1.2603 + void BindReadFB(GLuint fb) { 1.2604 + fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, fb); 1.2605 + } 1.2606 + 1.2607 + GLuint GetDrawFB() { 1.2608 + if (mScreen) 1.2609 + return mScreen->GetDrawFB(); 1.2610 + 1.2611 + GLuint ret = 0; 1.2612 + GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret); 1.2613 + return ret; 1.2614 + } 1.2615 + 1.2616 + GLuint GetReadFB() { 1.2617 + if (mScreen) 1.2618 + return mScreen->GetReadFB(); 1.2619 + 1.2620 + GLenum bindEnum = IsSupported(GLFeature::framebuffer_blit) 1.2621 + ? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT 1.2622 + : LOCAL_GL_FRAMEBUFFER_BINDING; 1.2623 + 1.2624 + GLuint ret = 0; 1.2625 + GetUIntegerv(bindEnum, &ret); 1.2626 + return ret; 1.2627 + } 1.2628 + 1.2629 + GLuint GetFB() { 1.2630 + if (mScreen) { 1.2631 + // This has a very important extra assert that checks that we're 1.2632 + // not accidentally ignoring a situation where the draw and read 1.2633 + // FBs differ. 1.2634 + return mScreen->GetFB(); 1.2635 + } 1.2636 + 1.2637 + GLuint ret = 0; 1.2638 + GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret); 1.2639 + return ret; 1.2640 + } 1.2641 + 1.2642 +private: 1.2643 + void GetShaderPrecisionFormatNonES2(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { 1.2644 + switch (precisiontype) { 1.2645 + case LOCAL_GL_LOW_FLOAT: 1.2646 + case LOCAL_GL_MEDIUM_FLOAT: 1.2647 + case LOCAL_GL_HIGH_FLOAT: 1.2648 + // Assume IEEE 754 precision 1.2649 + range[0] = 127; 1.2650 + range[1] = 127; 1.2651 + *precision = 23; 1.2652 + break; 1.2653 + case LOCAL_GL_LOW_INT: 1.2654 + case LOCAL_GL_MEDIUM_INT: 1.2655 + case LOCAL_GL_HIGH_INT: 1.2656 + // Some (most) hardware only supports single-precision floating-point numbers, 1.2657 + // which can accurately represent integers up to +/-16777216 1.2658 + range[0] = 24; 1.2659 + range[1] = 24; 1.2660 + *precision = 0; 1.2661 + break; 1.2662 + } 1.2663 + } 1.2664 + 1.2665 +public: 1.2666 + 1.2667 + void ForceDirtyScreen(); 1.2668 + void CleanDirtyScreen(); 1.2669 + 1.2670 + virtual GLenum GetPreferredARGB32Format() const { return LOCAL_GL_RGBA; } 1.2671 + 1.2672 + virtual bool RenewSurface() { return false; } 1.2673 + 1.2674 + // Shared code for GL extensions and GLX extensions. 1.2675 + static bool ListHasExtension(const GLubyte *extensions, 1.2676 + const char *extension); 1.2677 + 1.2678 + GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; } 1.2679 + 1.2680 +public: 1.2681 + /** 1.2682 + * Context reset constants. 1.2683 + * These are used to determine who is guilty when a context reset 1.2684 + * happens. 1.2685 + */ 1.2686 + enum ContextResetARB { 1.2687 + CONTEXT_NO_ERROR = 0, 1.2688 + CONTEXT_GUILTY_CONTEXT_RESET_ARB = 0x8253, 1.2689 + CONTEXT_INNOCENT_CONTEXT_RESET_ARB = 0x8254, 1.2690 + CONTEXT_UNKNOWN_CONTEXT_RESET_ARB = 0x8255 1.2691 + }; 1.2692 + 1.2693 +public: 1.2694 + std::map<GLuint, SharedSurface_GL*> mFBOMapping; 1.2695 + 1.2696 + enum { 1.2697 + DebugEnabled = 1 << 0, 1.2698 + DebugTrace = 1 << 1, 1.2699 + DebugAbortOnError = 1 << 2 1.2700 + }; 1.2701 + 1.2702 + static uint32_t sDebugMode; 1.2703 + 1.2704 + static uint32_t DebugMode() { 1.2705 +#ifdef DEBUG 1.2706 + return sDebugMode; 1.2707 +#else 1.2708 + return 0; 1.2709 +#endif 1.2710 + } 1.2711 + 1.2712 +protected: 1.2713 + nsRefPtr<GLContext> mSharedContext; 1.2714 + 1.2715 + // The thread on which this context was created. 1.2716 + nsCOMPtr<nsIThread> mOwningThread; 1.2717 + 1.2718 + GLContextSymbols mSymbols; 1.2719 + 1.2720 +#ifdef DEBUG 1.2721 + // GLDebugMode will check that we don't send call 1.2722 + // to a GLContext that isn't current on the current 1.2723 + // thread. 1.2724 + // Store the current context when binding to thread local 1.2725 + // storage to support DebugMode on an arbitrary thread. 1.2726 + static unsigned sCurrentGLContextTLS; 1.2727 +#endif 1.2728 + 1.2729 + ScopedDeletePtr<GLBlitHelper> mBlitHelper; 1.2730 + ScopedDeletePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper; 1.2731 + ScopedDeletePtr<GLReadTexImageHelper> mReadTexImageHelper; 1.2732 + 1.2733 +public: 1.2734 + GLBlitHelper* BlitHelper(); 1.2735 + GLBlitTextureImageHelper* BlitTextureImageHelper(); 1.2736 + GLReadTexImageHelper* ReadTexImageHelper(); 1.2737 + 1.2738 + // Assumes shares are created by all sharing with the same global context. 1.2739 + bool SharesWith(const GLContext* other) const { 1.2740 + MOZ_ASSERT(!this->mSharedContext || !this->mSharedContext->mSharedContext); 1.2741 + MOZ_ASSERT(!other->mSharedContext || !other->mSharedContext->mSharedContext); 1.2742 + MOZ_ASSERT(!this->mSharedContext || 1.2743 + !other->mSharedContext || 1.2744 + this->mSharedContext == other->mSharedContext); 1.2745 + 1.2746 + const GLContext* thisShared = this->mSharedContext ? this->mSharedContext 1.2747 + : this; 1.2748 + const GLContext* otherShared = other->mSharedContext ? other->mSharedContext 1.2749 + : other; 1.2750 + 1.2751 + return thisShared == otherShared; 1.2752 + } 1.2753 + 1.2754 + bool InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps) { 1.2755 + if (!CreateScreenBuffer(size, caps)) 1.2756 + return false; 1.2757 + 1.2758 + MakeCurrent(); 1.2759 + fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0); 1.2760 + fScissor(0, 0, size.width, size.height); 1.2761 + fViewport(0, 0, size.width, size.height); 1.2762 + 1.2763 + mCaps = mScreen->Caps(); 1.2764 + if (mCaps.any) 1.2765 + DetermineCaps(); 1.2766 + 1.2767 + UpdateGLFormats(mCaps); 1.2768 + UpdatePixelFormat(); 1.2769 + 1.2770 + return true; 1.2771 + } 1.2772 + 1.2773 +protected: 1.2774 + // Note that it does -not- clear the resized buffers. 1.2775 + bool CreateScreenBuffer(const gfx::IntSize& size, const SurfaceCaps& caps) { 1.2776 + if (!IsOffscreenSizeAllowed(size)) 1.2777 + return false; 1.2778 + 1.2779 + SurfaceCaps tryCaps = caps; 1.2780 + if (tryCaps.antialias) { 1.2781 + // AA path 1.2782 + if (CreateScreenBufferImpl(size, tryCaps)) 1.2783 + return true; 1.2784 + 1.2785 + NS_WARNING("CreateScreenBuffer failed to initialize an AA context! Falling back to no AA..."); 1.2786 + tryCaps.antialias = false; 1.2787 + } 1.2788 + MOZ_ASSERT(!tryCaps.antialias); 1.2789 + 1.2790 + if (CreateScreenBufferImpl(size, tryCaps)) 1.2791 + return true; 1.2792 + 1.2793 + NS_WARNING("CreateScreenBuffer failed to initialize non-AA context!"); 1.2794 + return false; 1.2795 + } 1.2796 + 1.2797 + bool CreateScreenBufferImpl(const gfx::IntSize& size, 1.2798 + const SurfaceCaps& caps); 1.2799 + 1.2800 +public: 1.2801 + bool ResizeScreenBuffer(const gfx::IntSize& size); 1.2802 + 1.2803 +protected: 1.2804 + SurfaceCaps mCaps; 1.2805 + nsAutoPtr<GLFormats> mGLFormats; 1.2806 + nsAutoPtr<PixelBufferFormat> mPixelFormat; 1.2807 + 1.2808 +public: 1.2809 + void DetermineCaps(); 1.2810 + const SurfaceCaps& Caps() const { 1.2811 + return mCaps; 1.2812 + } 1.2813 + 1.2814 + // Only varies based on bpp16 and alpha. 1.2815 + GLFormats ChooseGLFormats(const SurfaceCaps& caps) const; 1.2816 + void UpdateGLFormats(const SurfaceCaps& caps) { 1.2817 + mGLFormats = new GLFormats(ChooseGLFormats(caps)); 1.2818 + } 1.2819 + 1.2820 + const GLFormats& GetGLFormats() const { 1.2821 + MOZ_ASSERT(mGLFormats); 1.2822 + return *mGLFormats; 1.2823 + } 1.2824 + 1.2825 + PixelBufferFormat QueryPixelFormat(); 1.2826 + void UpdatePixelFormat(); 1.2827 + 1.2828 + const PixelBufferFormat& GetPixelFormat() const { 1.2829 + MOZ_ASSERT(mPixelFormat); 1.2830 + return *mPixelFormat; 1.2831 + } 1.2832 + 1.2833 + bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr); 1.2834 + 1.2835 + // Does not check completeness. 1.2836 + void AttachBuffersToFB(GLuint colorTex, GLuint colorRB, 1.2837 + GLuint depthRB, GLuint stencilRB, 1.2838 + GLuint fb, GLenum target = LOCAL_GL_TEXTURE_2D); 1.2839 + 1.2840 + // Passing null is fine if the value you'd get is 0. 1.2841 + bool AssembleOffscreenFBs(const GLuint colorMSRB, 1.2842 + const GLuint depthRB, 1.2843 + const GLuint stencilRB, 1.2844 + const GLuint texture, 1.2845 + GLuint* drawFB, 1.2846 + GLuint* readFB); 1.2847 + 1.2848 +protected: 1.2849 + friend class GLScreenBuffer; 1.2850 + GLScreenBuffer* mScreen; 1.2851 + 1.2852 + void DestroyScreenBuffer(); 1.2853 + 1.2854 + SharedSurface_GL* mLockedSurface; 1.2855 + 1.2856 +public: 1.2857 + void LockSurface(SharedSurface_GL* surf) { 1.2858 + MOZ_ASSERT(!mLockedSurface); 1.2859 + mLockedSurface = surf; 1.2860 + } 1.2861 + 1.2862 + void UnlockSurface(SharedSurface_GL* surf) { 1.2863 + MOZ_ASSERT(mLockedSurface == surf); 1.2864 + mLockedSurface = nullptr; 1.2865 + } 1.2866 + 1.2867 + SharedSurface_GL* GetLockedSurface() const { 1.2868 + return mLockedSurface; 1.2869 + } 1.2870 + 1.2871 + bool IsOffscreen() const { 1.2872 + return mScreen; 1.2873 + } 1.2874 + 1.2875 + GLScreenBuffer* Screen() const { 1.2876 + return mScreen; 1.2877 + } 1.2878 + 1.2879 + bool PublishFrame(); 1.2880 + SharedSurface_GL* RequestFrame(); 1.2881 + 1.2882 + /* Clear to transparent black, with 0 depth and stencil, 1.2883 + * while preserving current ClearColor etc. values. 1.2884 + * Useful for resizing offscreen buffers. 1.2885 + */ 1.2886 + void ClearSafely(); 1.2887 + 1.2888 + bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; } 1.2889 + 1.2890 +protected: 1.2891 + nsRefPtr<TextureGarbageBin> mTexGarbageBin; 1.2892 + 1.2893 +public: 1.2894 + TextureGarbageBin* TexGarbageBin() { 1.2895 + MOZ_ASSERT(mTexGarbageBin); 1.2896 + return mTexGarbageBin; 1.2897 + } 1.2898 + 1.2899 + void EmptyTexGarbageBin(); 1.2900 + 1.2901 + bool IsOffscreenSizeAllowed(const gfx::IntSize& aSize) const; 1.2902 + 1.2903 +protected: 1.2904 + bool InitWithPrefix(const char *prefix, bool trygl); 1.2905 + 1.2906 + void InitExtensions(); 1.2907 + 1.2908 + GLint mViewportRect[4]; 1.2909 + GLint mScissorRect[4]; 1.2910 + 1.2911 + GLint mMaxTextureSize; 1.2912 + GLint mMaxCubeMapTextureSize; 1.2913 + GLint mMaxTextureImageSize; 1.2914 + GLint mMaxRenderbufferSize; 1.2915 + GLsizei mMaxSamples; 1.2916 + bool mNeedsTextureSizeChecks; 1.2917 + bool mWorkAroundDriverBugs; 1.2918 + 1.2919 + bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const { 1.2920 + if (mNeedsTextureSizeChecks) { 1.2921 + // some drivers incorrectly handle some large texture sizes that are below the 1.2922 + // max texture size that they report. So we check ourselves against our own values 1.2923 + // (mMax[CubeMap]TextureSize). 1.2924 + // see bug 737182 for Mac Intel 2D textures 1.2925 + // see bug 684882 for Mac Intel cube map textures 1.2926 + // see bug 814716 for Mesa Nouveau 1.2927 + GLsizei maxSize = target == LOCAL_GL_TEXTURE_CUBE_MAP || 1.2928 + (target >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X && 1.2929 + target <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) 1.2930 + ? mMaxCubeMapTextureSize 1.2931 + : mMaxTextureSize; 1.2932 + return width <= maxSize && height <= maxSize; 1.2933 + } 1.2934 + return true; 1.2935 + } 1.2936 + 1.2937 + 1.2938 +public: 1.2939 + 1.2940 + void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) { 1.2941 + if (mViewportRect[0] == x && 1.2942 + mViewportRect[1] == y && 1.2943 + mViewportRect[2] == width && 1.2944 + mViewportRect[3] == height) 1.2945 + { 1.2946 + return; 1.2947 + } 1.2948 + mViewportRect[0] = x; 1.2949 + mViewportRect[1] = y; 1.2950 + mViewportRect[2] = width; 1.2951 + mViewportRect[3] = height; 1.2952 + BEFORE_GL_CALL; 1.2953 + mSymbols.fViewport(x, y, width, height); 1.2954 + AFTER_GL_CALL; 1.2955 + } 1.2956 + 1.2957 +#undef ASSERT_SYMBOL_PRESENT 1.2958 + 1.2959 +#ifdef MOZ_ENABLE_GL_TRACKING 1.2960 + void CreatedProgram(GLContext *aOrigin, GLuint aName); 1.2961 + void CreatedShader(GLContext *aOrigin, GLuint aName); 1.2962 + void CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); 1.2963 + void CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); 1.2964 + void CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); 1.2965 + void CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); 1.2966 + void CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); 1.2967 + void DeletedProgram(GLContext *aOrigin, GLuint aName); 1.2968 + void DeletedShader(GLContext *aOrigin, GLuint aName); 1.2969 + void DeletedBuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); 1.2970 + void DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); 1.2971 + void DeletedTextures(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); 1.2972 + void DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); 1.2973 + void DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); 1.2974 + 1.2975 + void SharedContextDestroyed(GLContext *aChild); 1.2976 + void ReportOutstandingNames(); 1.2977 + 1.2978 + struct NamedResource { 1.2979 + NamedResource() 1.2980 + : origin(nullptr), name(0), originDeleted(false) 1.2981 + { } 1.2982 + 1.2983 + NamedResource(GLContext *aOrigin, GLuint aName) 1.2984 + : origin(aOrigin), name(aName), originDeleted(false) 1.2985 + { } 1.2986 + 1.2987 + GLContext *origin; 1.2988 + GLuint name; 1.2989 + bool originDeleted; 1.2990 + 1.2991 + // for sorting 1.2992 + bool operator<(const NamedResource& aOther) const { 1.2993 + if (intptr_t(origin) < intptr_t(aOther.origin)) 1.2994 + return true; 1.2995 + if (name < aOther.name) 1.2996 + return true; 1.2997 + return false; 1.2998 + } 1.2999 + bool operator==(const NamedResource& aOther) const { 1.3000 + return origin == aOther.origin && 1.3001 + name == aOther.name && 1.3002 + originDeleted == aOther.originDeleted; 1.3003 + } 1.3004 + }; 1.3005 + 1.3006 + nsTArray<NamedResource> mTrackedPrograms; 1.3007 + nsTArray<NamedResource> mTrackedShaders; 1.3008 + nsTArray<NamedResource> mTrackedTextures; 1.3009 + nsTArray<NamedResource> mTrackedFramebuffers; 1.3010 + nsTArray<NamedResource> mTrackedRenderbuffers; 1.3011 + nsTArray<NamedResource> mTrackedBuffers; 1.3012 + nsTArray<NamedResource> mTrackedQueries; 1.3013 +#endif 1.3014 +}; 1.3015 + 1.3016 +bool DoesStringMatch(const char* aString, const char *aWantedString); 1.3017 + 1.3018 + 1.3019 +} /* namespace gl */ 1.3020 +} /* namespace mozilla */ 1.3021 + 1.3022 +#endif /* GLCONTEXT_H_ */