Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=4 et sw=4 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef GLCONTEXT_H_ |
michael@0 | 8 | #define GLCONTEXT_H_ |
michael@0 | 9 | |
michael@0 | 10 | #include <stdio.h> |
michael@0 | 11 | #include <stdint.h> |
michael@0 | 12 | #include <ctype.h> |
michael@0 | 13 | #include <map> |
michael@0 | 14 | #include <bitset> |
michael@0 | 15 | |
michael@0 | 16 | #ifdef DEBUG |
michael@0 | 17 | #include <string.h> |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | #ifdef WIN32 |
michael@0 | 21 | #include <windows.h> |
michael@0 | 22 | #endif |
michael@0 | 23 | |
michael@0 | 24 | #ifdef GetClassName |
michael@0 | 25 | #undef GetClassName |
michael@0 | 26 | #endif |
michael@0 | 27 | |
michael@0 | 28 | #include "GLDefs.h" |
michael@0 | 29 | #include "GLLibraryLoader.h" |
michael@0 | 30 | #include "gfx3DMatrix.h" |
michael@0 | 31 | #include "nsISupportsImpl.h" |
michael@0 | 32 | #include "plstr.h" |
michael@0 | 33 | #include "nsDataHashtable.h" |
michael@0 | 34 | #include "nsHashKeys.h" |
michael@0 | 35 | #include "nsAutoPtr.h" |
michael@0 | 36 | #include "GLContextTypes.h" |
michael@0 | 37 | #include "GLTextureImage.h" |
michael@0 | 38 | #include "SurfaceTypes.h" |
michael@0 | 39 | #include "GLScreenBuffer.h" |
michael@0 | 40 | #include "GLContextSymbols.h" |
michael@0 | 41 | #include "mozilla/GenericRefCounted.h" |
michael@0 | 42 | #include "mozilla/Scoped.h" |
michael@0 | 43 | #include "gfx2DGlue.h" |
michael@0 | 44 | |
michael@0 | 45 | #ifdef DEBUG |
michael@0 | 46 | #define MOZ_ENABLE_GL_TRACKING 1 |
michael@0 | 47 | #endif |
michael@0 | 48 | |
michael@0 | 49 | class nsIntRegion; |
michael@0 | 50 | class nsIRunnable; |
michael@0 | 51 | class nsIThread; |
michael@0 | 52 | |
michael@0 | 53 | namespace android { |
michael@0 | 54 | class GraphicBuffer; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | namespace mozilla { |
michael@0 | 58 | namespace gfx { |
michael@0 | 59 | class SourceSurface; |
michael@0 | 60 | class DataSourceSurface; |
michael@0 | 61 | struct SurfaceCaps; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | namespace gl { |
michael@0 | 65 | class GLContext; |
michael@0 | 66 | class GLLibraryEGL; |
michael@0 | 67 | class GLScreenBuffer; |
michael@0 | 68 | class TextureGarbageBin; |
michael@0 | 69 | class GLBlitHelper; |
michael@0 | 70 | class GLBlitTextureImageHelper; |
michael@0 | 71 | class GLReadTexImageHelper; |
michael@0 | 72 | class SharedSurface_GL; |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | namespace layers { |
michael@0 | 76 | class ColorTextureLayerProgram; |
michael@0 | 77 | } |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | namespace mozilla { |
michael@0 | 81 | namespace gl { |
michael@0 | 82 | |
michael@0 | 83 | MOZ_BEGIN_ENUM_CLASS(GLFeature) |
michael@0 | 84 | bind_buffer_offset, |
michael@0 | 85 | blend_minmax, |
michael@0 | 86 | depth_texture, |
michael@0 | 87 | draw_buffers, |
michael@0 | 88 | draw_instanced, |
michael@0 | 89 | draw_range_elements, |
michael@0 | 90 | element_index_uint, |
michael@0 | 91 | ES2_compatibility, |
michael@0 | 92 | ES3_compatibility, |
michael@0 | 93 | frag_color_float, |
michael@0 | 94 | frag_depth, |
michael@0 | 95 | framebuffer_blit, |
michael@0 | 96 | framebuffer_multisample, |
michael@0 | 97 | framebuffer_object, |
michael@0 | 98 | get_query_object_iv, |
michael@0 | 99 | instanced_arrays, |
michael@0 | 100 | instanced_non_arrays, |
michael@0 | 101 | occlusion_query, |
michael@0 | 102 | occlusion_query_boolean, |
michael@0 | 103 | occlusion_query2, |
michael@0 | 104 | packed_depth_stencil, |
michael@0 | 105 | query_objects, |
michael@0 | 106 | renderbuffer_color_float, |
michael@0 | 107 | renderbuffer_color_half_float, |
michael@0 | 108 | robustness, |
michael@0 | 109 | sRGB, |
michael@0 | 110 | standard_derivatives, |
michael@0 | 111 | texture_float, |
michael@0 | 112 | texture_float_linear, |
michael@0 | 113 | texture_half_float, |
michael@0 | 114 | texture_half_float_linear, |
michael@0 | 115 | texture_non_power_of_two, |
michael@0 | 116 | transform_feedback, |
michael@0 | 117 | vertex_array_object, |
michael@0 | 118 | EnumMax |
michael@0 | 119 | MOZ_END_ENUM_CLASS(GLFeature) |
michael@0 | 120 | |
michael@0 | 121 | MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t) |
michael@0 | 122 | Unknown = 0, |
michael@0 | 123 | OpenGL, // only for IsAtLeast's <profile> parameter |
michael@0 | 124 | OpenGLCore, |
michael@0 | 125 | OpenGLCompatibility, |
michael@0 | 126 | OpenGLES |
michael@0 | 127 | MOZ_END_ENUM_CLASS(ContextProfile) |
michael@0 | 128 | |
michael@0 | 129 | MOZ_BEGIN_ENUM_CLASS(GLVendor) |
michael@0 | 130 | Intel, |
michael@0 | 131 | NVIDIA, |
michael@0 | 132 | ATI, |
michael@0 | 133 | Qualcomm, |
michael@0 | 134 | Imagination, |
michael@0 | 135 | Nouveau, |
michael@0 | 136 | Vivante, |
michael@0 | 137 | VMware, |
michael@0 | 138 | Other |
michael@0 | 139 | MOZ_END_ENUM_CLASS(GLVendor) |
michael@0 | 140 | |
michael@0 | 141 | MOZ_BEGIN_ENUM_CLASS(GLRenderer) |
michael@0 | 142 | Adreno200, |
michael@0 | 143 | Adreno205, |
michael@0 | 144 | AdrenoTM205, |
michael@0 | 145 | AdrenoTM320, |
michael@0 | 146 | SGX530, |
michael@0 | 147 | SGX540, |
michael@0 | 148 | Tegra, |
michael@0 | 149 | AndroidEmulator, |
michael@0 | 150 | GalliumLlvmpipe, |
michael@0 | 151 | Other |
michael@0 | 152 | MOZ_END_ENUM_CLASS(GLRenderer) |
michael@0 | 153 | |
michael@0 | 154 | class GLContext |
michael@0 | 155 | : public GLLibraryLoader |
michael@0 | 156 | , public GenericAtomicRefCounted |
michael@0 | 157 | { |
michael@0 | 158 | // ----------------------------------------------------------------------------- |
michael@0 | 159 | // basic enums |
michael@0 | 160 | public: |
michael@0 | 161 | |
michael@0 | 162 | // ----------------------------------------------------------------------------- |
michael@0 | 163 | // basic getters |
michael@0 | 164 | public: |
michael@0 | 165 | |
michael@0 | 166 | /** |
michael@0 | 167 | * Returns true if the context is using ANGLE. This should only be overridden |
michael@0 | 168 | * for an ANGLE implementation. |
michael@0 | 169 | */ |
michael@0 | 170 | virtual bool IsANGLE() const { |
michael@0 | 171 | return false; |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | /** |
michael@0 | 175 | * Return true if we are running on a OpenGL core profile context |
michael@0 | 176 | */ |
michael@0 | 177 | inline bool IsCoreProfile() const { |
michael@0 | 178 | MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); |
michael@0 | 179 | |
michael@0 | 180 | return mProfile == ContextProfile::OpenGLCore; |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Return true if we are running on a OpenGL compatibility profile context |
michael@0 | 185 | * (legacy profile 2.1 on Max OS X) |
michael@0 | 186 | */ |
michael@0 | 187 | inline bool IsCompatibilityProfile() const { |
michael@0 | 188 | MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); |
michael@0 | 189 | |
michael@0 | 190 | return mProfile == ContextProfile::OpenGLCompatibility; |
michael@0 | 191 | } |
michael@0 | 192 | |
michael@0 | 193 | /** |
michael@0 | 194 | * Return true if the context is a true OpenGL ES context or an ANGLE context |
michael@0 | 195 | */ |
michael@0 | 196 | inline bool IsGLES() const { |
michael@0 | 197 | MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); |
michael@0 | 198 | |
michael@0 | 199 | return mProfile == ContextProfile::OpenGLES; |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | static const char* GetProfileName(ContextProfile profile) |
michael@0 | 203 | { |
michael@0 | 204 | switch (profile) |
michael@0 | 205 | { |
michael@0 | 206 | case ContextProfile::OpenGL: |
michael@0 | 207 | return "OpenGL"; |
michael@0 | 208 | case ContextProfile::OpenGLCore: |
michael@0 | 209 | return "OpenGL Core"; |
michael@0 | 210 | case ContextProfile::OpenGLCompatibility: |
michael@0 | 211 | return "OpenGL Compatibility"; |
michael@0 | 212 | case ContextProfile::OpenGLES: |
michael@0 | 213 | return "OpenGL ES"; |
michael@0 | 214 | default: |
michael@0 | 215 | break; |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | MOZ_ASSERT(profile != ContextProfile::Unknown, "unknown context profile"); |
michael@0 | 219 | return "OpenGL unknown profile"; |
michael@0 | 220 | } |
michael@0 | 221 | |
michael@0 | 222 | /** |
michael@0 | 223 | * Return true if we are running on a OpenGL core profile context |
michael@0 | 224 | */ |
michael@0 | 225 | const char* ProfileString() const { |
michael@0 | 226 | return GetProfileName(mProfile); |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | /** |
michael@0 | 230 | * Return true if the context is compatible with given parameters |
michael@0 | 231 | * |
michael@0 | 232 | * IsAtLeast(ContextProfile::OpenGL, N) is exactly same as |
michael@0 | 233 | * IsAtLeast(ContextProfile::OpenGLCore, N) || IsAtLeast(ContextProfile::OpenGLCompatibility, N) |
michael@0 | 234 | */ |
michael@0 | 235 | inline bool IsAtLeast(ContextProfile profile, unsigned int version) const |
michael@0 | 236 | { |
michael@0 | 237 | MOZ_ASSERT(profile != ContextProfile::Unknown, "IsAtLeast: bad <profile> parameter"); |
michael@0 | 238 | MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile"); |
michael@0 | 239 | MOZ_ASSERT(mVersion != 0, "unknown context version"); |
michael@0 | 240 | |
michael@0 | 241 | if (version > mVersion) { |
michael@0 | 242 | return false; |
michael@0 | 243 | } |
michael@0 | 244 | |
michael@0 | 245 | if (profile == ContextProfile::OpenGL) { |
michael@0 | 246 | return profile == ContextProfile::OpenGLCore || |
michael@0 | 247 | profile == ContextProfile::OpenGLCompatibility; |
michael@0 | 248 | } |
michael@0 | 249 | |
michael@0 | 250 | return profile == mProfile; |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | /** |
michael@0 | 254 | * Return the version of the context. |
michael@0 | 255 | * Example : |
michael@0 | 256 | * If this a OpenGL 2.1, that will return 210 |
michael@0 | 257 | */ |
michael@0 | 258 | inline unsigned int Version() const { |
michael@0 | 259 | return mVersion; |
michael@0 | 260 | } |
michael@0 | 261 | |
michael@0 | 262 | const char* VersionString() const { |
michael@0 | 263 | return mVersionString.get(); |
michael@0 | 264 | } |
michael@0 | 265 | |
michael@0 | 266 | GLVendor Vendor() const { |
michael@0 | 267 | return mVendor; |
michael@0 | 268 | } |
michael@0 | 269 | |
michael@0 | 270 | GLRenderer Renderer() const { |
michael@0 | 271 | return mRenderer; |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | bool IsContextLost() const { |
michael@0 | 275 | return mContextLost; |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * If this context is double-buffered, returns TRUE. |
michael@0 | 280 | */ |
michael@0 | 281 | virtual bool IsDoubleBuffered() const { |
michael@0 | 282 | return false; |
michael@0 | 283 | } |
michael@0 | 284 | |
michael@0 | 285 | virtual GLContextType GetContextType() const = 0; |
michael@0 | 286 | |
michael@0 | 287 | virtual bool IsCurrent() = 0; |
michael@0 | 288 | |
michael@0 | 289 | protected: |
michael@0 | 290 | |
michael@0 | 291 | bool mInitialized; |
michael@0 | 292 | bool mIsOffscreen; |
michael@0 | 293 | bool mIsGlobalSharedContext; |
michael@0 | 294 | bool mContextLost; |
michael@0 | 295 | |
michael@0 | 296 | /** |
michael@0 | 297 | * mVersion store the OpenGL's version, multiplied by 100. For example, if |
michael@0 | 298 | * the context is an OpenGL 2.1 context, mVersion value will be 210. |
michael@0 | 299 | */ |
michael@0 | 300 | unsigned int mVersion; |
michael@0 | 301 | nsCString mVersionString; |
michael@0 | 302 | ContextProfile mProfile; |
michael@0 | 303 | |
michael@0 | 304 | GLVendor mVendor; |
michael@0 | 305 | GLRenderer mRenderer; |
michael@0 | 306 | |
michael@0 | 307 | inline void SetProfileVersion(ContextProfile profile, unsigned int version) { |
michael@0 | 308 | MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before initialization!"); |
michael@0 | 309 | MOZ_ASSERT(profile != ContextProfile::Unknown && profile != ContextProfile::OpenGL, "Invalid `profile` for SetProfileVersion"); |
michael@0 | 310 | MOZ_ASSERT(version >= 100, "Invalid `version` for SetProfileVersion"); |
michael@0 | 311 | |
michael@0 | 312 | mVersion = version; |
michael@0 | 313 | mProfile = profile; |
michael@0 | 314 | } |
michael@0 | 315 | |
michael@0 | 316 | |
michael@0 | 317 | // ----------------------------------------------------------------------------- |
michael@0 | 318 | // Extensions management |
michael@0 | 319 | /** |
michael@0 | 320 | * This mechanism is designed to know if an extension is supported. In the long |
michael@0 | 321 | * term, we would like to only use the extension group queries XXX_* to have |
michael@0 | 322 | * full compatibility with context version and profiles (especialy the core that |
michael@0 | 323 | * officialy don't bring any extensions). |
michael@0 | 324 | */ |
michael@0 | 325 | public: |
michael@0 | 326 | |
michael@0 | 327 | /** |
michael@0 | 328 | * Known GL extensions that can be queried by |
michael@0 | 329 | * IsExtensionSupported. The results of this are cached, and as |
michael@0 | 330 | * such it's safe to use this even in performance critical code. |
michael@0 | 331 | * If you add to this array, remember to add to the string names |
michael@0 | 332 | * in GLContext.cpp. |
michael@0 | 333 | */ |
michael@0 | 334 | enum GLExtensions { |
michael@0 | 335 | EXT_framebuffer_object, |
michael@0 | 336 | ARB_framebuffer_object, |
michael@0 | 337 | ARB_texture_rectangle, |
michael@0 | 338 | EXT_bgra, |
michael@0 | 339 | EXT_texture_format_BGRA8888, |
michael@0 | 340 | OES_depth24, |
michael@0 | 341 | OES_depth32, |
michael@0 | 342 | OES_stencil8, |
michael@0 | 343 | OES_texture_npot, |
michael@0 | 344 | ARB_depth_texture, |
michael@0 | 345 | OES_depth_texture, |
michael@0 | 346 | OES_packed_depth_stencil, |
michael@0 | 347 | IMG_read_format, |
michael@0 | 348 | EXT_read_format_bgra, |
michael@0 | 349 | APPLE_client_storage, |
michael@0 | 350 | APPLE_texture_range, |
michael@0 | 351 | ARB_texture_non_power_of_two, |
michael@0 | 352 | ARB_pixel_buffer_object, |
michael@0 | 353 | ARB_ES2_compatibility, |
michael@0 | 354 | ARB_ES3_compatibility, |
michael@0 | 355 | OES_texture_float, |
michael@0 | 356 | OES_texture_float_linear, |
michael@0 | 357 | ARB_texture_float, |
michael@0 | 358 | OES_texture_half_float, |
michael@0 | 359 | OES_texture_half_float_linear, |
michael@0 | 360 | NV_half_float, |
michael@0 | 361 | EXT_color_buffer_float, |
michael@0 | 362 | EXT_color_buffer_half_float, |
michael@0 | 363 | ARB_color_buffer_float, |
michael@0 | 364 | EXT_unpack_subimage, |
michael@0 | 365 | OES_standard_derivatives, |
michael@0 | 366 | EXT_texture_filter_anisotropic, |
michael@0 | 367 | EXT_texture_compression_s3tc, |
michael@0 | 368 | EXT_texture_compression_dxt1, |
michael@0 | 369 | ANGLE_texture_compression_dxt3, |
michael@0 | 370 | ANGLE_texture_compression_dxt5, |
michael@0 | 371 | AMD_compressed_ATC_texture, |
michael@0 | 372 | IMG_texture_compression_pvrtc, |
michael@0 | 373 | EXT_framebuffer_blit, |
michael@0 | 374 | ANGLE_framebuffer_blit, |
michael@0 | 375 | EXT_framebuffer_multisample, |
michael@0 | 376 | ANGLE_framebuffer_multisample, |
michael@0 | 377 | OES_rgb8_rgba8, |
michael@0 | 378 | ARB_robustness, |
michael@0 | 379 | EXT_robustness, |
michael@0 | 380 | ARB_sync, |
michael@0 | 381 | OES_EGL_image, |
michael@0 | 382 | OES_EGL_sync, |
michael@0 | 383 | OES_EGL_image_external, |
michael@0 | 384 | EXT_packed_depth_stencil, |
michael@0 | 385 | OES_element_index_uint, |
michael@0 | 386 | OES_vertex_array_object, |
michael@0 | 387 | ARB_vertex_array_object, |
michael@0 | 388 | APPLE_vertex_array_object, |
michael@0 | 389 | ARB_draw_buffers, |
michael@0 | 390 | EXT_draw_buffers, |
michael@0 | 391 | EXT_gpu_shader4, |
michael@0 | 392 | EXT_blend_minmax, |
michael@0 | 393 | ARB_draw_instanced, |
michael@0 | 394 | EXT_draw_instanced, |
michael@0 | 395 | NV_draw_instanced, |
michael@0 | 396 | ARB_instanced_arrays, |
michael@0 | 397 | NV_instanced_arrays, |
michael@0 | 398 | ANGLE_instanced_arrays, |
michael@0 | 399 | EXT_occlusion_query_boolean, |
michael@0 | 400 | ARB_occlusion_query2, |
michael@0 | 401 | EXT_transform_feedback, |
michael@0 | 402 | NV_transform_feedback, |
michael@0 | 403 | ANGLE_depth_texture, |
michael@0 | 404 | EXT_sRGB, |
michael@0 | 405 | EXT_texture_sRGB, |
michael@0 | 406 | ARB_framebuffer_sRGB, |
michael@0 | 407 | EXT_framebuffer_sRGB, |
michael@0 | 408 | KHR_debug, |
michael@0 | 409 | ARB_half_float_pixel, |
michael@0 | 410 | EXT_frag_depth, |
michael@0 | 411 | OES_compressed_ETC1_RGB8_texture, |
michael@0 | 412 | EXT_draw_range_elements, |
michael@0 | 413 | Extensions_Max, |
michael@0 | 414 | Extensions_End |
michael@0 | 415 | }; |
michael@0 | 416 | |
michael@0 | 417 | bool IsExtensionSupported(GLExtensions aKnownExtension) const { |
michael@0 | 418 | return mAvailableExtensions[aKnownExtension]; |
michael@0 | 419 | } |
michael@0 | 420 | |
michael@0 | 421 | void MarkExtensionUnsupported(GLExtensions aKnownExtension) { |
michael@0 | 422 | mAvailableExtensions[aKnownExtension] = 0; |
michael@0 | 423 | } |
michael@0 | 424 | |
michael@0 | 425 | void MarkExtensionSupported(GLExtensions aKnownExtension) { |
michael@0 | 426 | mAvailableExtensions[aKnownExtension] = 1; |
michael@0 | 427 | } |
michael@0 | 428 | |
michael@0 | 429 | |
michael@0 | 430 | public: |
michael@0 | 431 | |
michael@0 | 432 | template<size_t N> |
michael@0 | 433 | static void InitializeExtensionsBitSet(std::bitset<N>& extensionsBitset, const char* extStr, const char** extList, bool verbose = false) |
michael@0 | 434 | { |
michael@0 | 435 | char* exts = ::strdup(extStr); |
michael@0 | 436 | |
michael@0 | 437 | if (verbose) |
michael@0 | 438 | printf_stderr("Extensions: %s\n", exts); |
michael@0 | 439 | |
michael@0 | 440 | char* cur = exts; |
michael@0 | 441 | bool done = false; |
michael@0 | 442 | while (!done) { |
michael@0 | 443 | char* space = strchr(cur, ' '); |
michael@0 | 444 | if (space) { |
michael@0 | 445 | *space = '\0'; |
michael@0 | 446 | } else { |
michael@0 | 447 | done = true; |
michael@0 | 448 | } |
michael@0 | 449 | |
michael@0 | 450 | for (int i = 0; extList[i]; ++i) { |
michael@0 | 451 | if (PL_strcasecmp(cur, extList[i]) == 0) { |
michael@0 | 452 | if (verbose) |
michael@0 | 453 | printf_stderr("Found extension %s\n", cur); |
michael@0 | 454 | extensionsBitset[i] = true; |
michael@0 | 455 | } |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | cur = space + 1; |
michael@0 | 459 | } |
michael@0 | 460 | |
michael@0 | 461 | free(exts); |
michael@0 | 462 | } |
michael@0 | 463 | |
michael@0 | 464 | |
michael@0 | 465 | protected: |
michael@0 | 466 | std::bitset<Extensions_Max> mAvailableExtensions; |
michael@0 | 467 | |
michael@0 | 468 | |
michael@0 | 469 | // ----------------------------------------------------------------------------- |
michael@0 | 470 | // Feature queries |
michael@0 | 471 | /* |
michael@0 | 472 | * This mecahnism introduces a new way to check if a OpenGL feature is |
michael@0 | 473 | * supported, regardless of whether it is supported by an extension or natively |
michael@0 | 474 | * by the context version/profile |
michael@0 | 475 | */ |
michael@0 | 476 | public: |
michael@0 | 477 | bool IsSupported(GLFeature feature) const { |
michael@0 | 478 | return mAvailableFeatures[size_t(feature)]; |
michael@0 | 479 | } |
michael@0 | 480 | |
michael@0 | 481 | static const char* GetFeatureName(GLFeature feature); |
michael@0 | 482 | |
michael@0 | 483 | |
michael@0 | 484 | private: |
michael@0 | 485 | std::bitset<size_t(GLFeature::EnumMax)> mAvailableFeatures; |
michael@0 | 486 | |
michael@0 | 487 | /** |
michael@0 | 488 | * Init features regarding OpenGL extension and context version and profile |
michael@0 | 489 | */ |
michael@0 | 490 | void InitFeatures(); |
michael@0 | 491 | |
michael@0 | 492 | /** |
michael@0 | 493 | * Mark the feature and associated extensions as unsupported |
michael@0 | 494 | */ |
michael@0 | 495 | void MarkUnsupported(GLFeature feature); |
michael@0 | 496 | |
michael@0 | 497 | // ----------------------------------------------------------------------------- |
michael@0 | 498 | // Robustness handling |
michael@0 | 499 | public: |
michael@0 | 500 | |
michael@0 | 501 | bool HasRobustness() const { |
michael@0 | 502 | return mHasRobustness; |
michael@0 | 503 | } |
michael@0 | 504 | |
michael@0 | 505 | /** |
michael@0 | 506 | * The derived class is expected to provide information on whether or not it |
michael@0 | 507 | * supports robustness. |
michael@0 | 508 | */ |
michael@0 | 509 | virtual bool SupportsRobustness() const = 0; |
michael@0 | 510 | |
michael@0 | 511 | |
michael@0 | 512 | private: |
michael@0 | 513 | bool mHasRobustness; |
michael@0 | 514 | |
michael@0 | 515 | |
michael@0 | 516 | // ----------------------------------------------------------------------------- |
michael@0 | 517 | // Error handling |
michael@0 | 518 | public: |
michael@0 | 519 | |
michael@0 | 520 | static const char* GLErrorToString(GLenum aError) |
michael@0 | 521 | { |
michael@0 | 522 | switch (aError) { |
michael@0 | 523 | case LOCAL_GL_INVALID_ENUM: |
michael@0 | 524 | return "GL_INVALID_ENUM"; |
michael@0 | 525 | case LOCAL_GL_INVALID_VALUE: |
michael@0 | 526 | return "GL_INVALID_VALUE"; |
michael@0 | 527 | case LOCAL_GL_INVALID_OPERATION: |
michael@0 | 528 | return "GL_INVALID_OPERATION"; |
michael@0 | 529 | case LOCAL_GL_STACK_OVERFLOW: |
michael@0 | 530 | return "GL_STACK_OVERFLOW"; |
michael@0 | 531 | case LOCAL_GL_STACK_UNDERFLOW: |
michael@0 | 532 | return "GL_STACK_UNDERFLOW"; |
michael@0 | 533 | case LOCAL_GL_OUT_OF_MEMORY: |
michael@0 | 534 | return "GL_OUT_OF_MEMORY"; |
michael@0 | 535 | case LOCAL_GL_TABLE_TOO_LARGE: |
michael@0 | 536 | return "GL_TABLE_TOO_LARGE"; |
michael@0 | 537 | case LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION: |
michael@0 | 538 | return "GL_INVALID_FRAMEBUFFER_OPERATION"; |
michael@0 | 539 | default: |
michael@0 | 540 | return ""; |
michael@0 | 541 | } |
michael@0 | 542 | } |
michael@0 | 543 | |
michael@0 | 544 | |
michael@0 | 545 | /** \returns the first GL error, and guarantees that all GL error flags are cleared, |
michael@0 | 546 | * i.e. that a subsequent GetError call will return NO_ERROR |
michael@0 | 547 | */ |
michael@0 | 548 | GLenum GetAndClearError() |
michael@0 | 549 | { |
michael@0 | 550 | // the first error is what we want to return |
michael@0 | 551 | GLenum error = fGetError(); |
michael@0 | 552 | |
michael@0 | 553 | if (error) { |
michael@0 | 554 | // clear all pending errors |
michael@0 | 555 | while(fGetError()) {} |
michael@0 | 556 | } |
michael@0 | 557 | |
michael@0 | 558 | return error; |
michael@0 | 559 | } |
michael@0 | 560 | |
michael@0 | 561 | |
michael@0 | 562 | /*** In GL debug mode, we completely override glGetError ***/ |
michael@0 | 563 | |
michael@0 | 564 | GLenum fGetError() |
michael@0 | 565 | { |
michael@0 | 566 | #ifdef DEBUG |
michael@0 | 567 | // debug mode ends up eating the error in AFTER_GL_CALL |
michael@0 | 568 | if (DebugMode()) { |
michael@0 | 569 | GLenum err = mGLError; |
michael@0 | 570 | mGLError = LOCAL_GL_NO_ERROR; |
michael@0 | 571 | return err; |
michael@0 | 572 | } |
michael@0 | 573 | #endif // DEBUG |
michael@0 | 574 | |
michael@0 | 575 | return mSymbols.fGetError(); |
michael@0 | 576 | } |
michael@0 | 577 | |
michael@0 | 578 | |
michael@0 | 579 | #ifdef DEBUG |
michael@0 | 580 | private: |
michael@0 | 581 | |
michael@0 | 582 | GLenum mGLError; |
michael@0 | 583 | #endif // DEBUG |
michael@0 | 584 | |
michael@0 | 585 | |
michael@0 | 586 | // ----------------------------------------------------------------------------- |
michael@0 | 587 | // MOZ_GL_DEBUG implementation |
michael@0 | 588 | private: |
michael@0 | 589 | |
michael@0 | 590 | #undef BEFORE_GL_CALL |
michael@0 | 591 | #undef AFTER_GL_CALL |
michael@0 | 592 | |
michael@0 | 593 | #ifdef MOZ_ENABLE_GL_TRACKING |
michael@0 | 594 | |
michael@0 | 595 | #ifndef MOZ_FUNCTION_NAME |
michael@0 | 596 | # ifdef __GNUC__ |
michael@0 | 597 | # define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__ |
michael@0 | 598 | # elif defined(_MSC_VER) |
michael@0 | 599 | # define MOZ_FUNCTION_NAME __FUNCTION__ |
michael@0 | 600 | # else |
michael@0 | 601 | # define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name. |
michael@0 | 602 | # endif |
michael@0 | 603 | #endif |
michael@0 | 604 | |
michael@0 | 605 | void BeforeGLCall(const char* glFunction) |
michael@0 | 606 | { |
michael@0 | 607 | MOZ_ASSERT(IsCurrent()); |
michael@0 | 608 | if (DebugMode()) { |
michael@0 | 609 | GLContext *currentGLContext = nullptr; |
michael@0 | 610 | |
michael@0 | 611 | currentGLContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS); |
michael@0 | 612 | |
michael@0 | 613 | if (DebugMode() & DebugTrace) |
michael@0 | 614 | printf_stderr("[gl:%p] > %s\n", this, glFunction); |
michael@0 | 615 | if (this != currentGLContext) { |
michael@0 | 616 | printf_stderr("Fatal: %s called on non-current context %p. " |
michael@0 | 617 | "The current context for this thread is %p.\n", |
michael@0 | 618 | glFunction, this, currentGLContext); |
michael@0 | 619 | NS_ABORT(); |
michael@0 | 620 | } |
michael@0 | 621 | } |
michael@0 | 622 | } |
michael@0 | 623 | |
michael@0 | 624 | void AfterGLCall(const char* glFunction) |
michael@0 | 625 | { |
michael@0 | 626 | if (DebugMode()) { |
michael@0 | 627 | // calling fFinish() immediately after every GL call makes sure that if this GL command crashes, |
michael@0 | 628 | // the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces |
michael@0 | 629 | // tend to be meaningless |
michael@0 | 630 | mSymbols.fFinish(); |
michael@0 | 631 | mGLError = mSymbols.fGetError(); |
michael@0 | 632 | if (DebugMode() & DebugTrace) |
michael@0 | 633 | printf_stderr("[gl:%p] < %s [0x%04x]\n", this, glFunction, mGLError); |
michael@0 | 634 | if (mGLError != LOCAL_GL_NO_ERROR) { |
michael@0 | 635 | printf_stderr("GL ERROR: %s generated GL error %s(0x%04x)\n", |
michael@0 | 636 | glFunction, |
michael@0 | 637 | GLErrorToString(mGLError), |
michael@0 | 638 | mGLError); |
michael@0 | 639 | if (DebugMode() & DebugAbortOnError) |
michael@0 | 640 | NS_ABORT(); |
michael@0 | 641 | } |
michael@0 | 642 | } |
michael@0 | 643 | } |
michael@0 | 644 | |
michael@0 | 645 | GLContext *TrackingContext() |
michael@0 | 646 | { |
michael@0 | 647 | GLContext *tip = this; |
michael@0 | 648 | while (tip->mSharedContext) |
michael@0 | 649 | tip = tip->mSharedContext; |
michael@0 | 650 | return tip; |
michael@0 | 651 | } |
michael@0 | 652 | |
michael@0 | 653 | #define BEFORE_GL_CALL \ |
michael@0 | 654 | do { \ |
michael@0 | 655 | BeforeGLCall(MOZ_FUNCTION_NAME); \ |
michael@0 | 656 | } while (0) |
michael@0 | 657 | |
michael@0 | 658 | #define AFTER_GL_CALL \ |
michael@0 | 659 | do { \ |
michael@0 | 660 | AfterGLCall(MOZ_FUNCTION_NAME); \ |
michael@0 | 661 | } while (0) |
michael@0 | 662 | |
michael@0 | 663 | #define TRACKING_CONTEXT(a) \ |
michael@0 | 664 | do { \ |
michael@0 | 665 | TrackingContext()->a; \ |
michael@0 | 666 | } while (0) |
michael@0 | 667 | |
michael@0 | 668 | #else // ifdef DEBUG |
michael@0 | 669 | |
michael@0 | 670 | #define BEFORE_GL_CALL do { } while (0) |
michael@0 | 671 | #define AFTER_GL_CALL do { } while (0) |
michael@0 | 672 | #define TRACKING_CONTEXT(a) do {} while (0) |
michael@0 | 673 | |
michael@0 | 674 | #endif // ifdef DEBUG |
michael@0 | 675 | |
michael@0 | 676 | #define ASSERT_SYMBOL_PRESENT(func) \ |
michael@0 | 677 | do {\ |
michael@0 | 678 | MOZ_ASSERT(strstr(MOZ_FUNCTION_NAME, #func) != nullptr, "Mismatched symbol check.");\ |
michael@0 | 679 | if (MOZ_UNLIKELY(!mSymbols.func)) {\ |
michael@0 | 680 | printf_stderr("RUNTIME ASSERT: Uninitialized GL function: %s\n", #func);\ |
michael@0 | 681 | MOZ_CRASH();\ |
michael@0 | 682 | }\ |
michael@0 | 683 | } while (0) |
michael@0 | 684 | |
michael@0 | 685 | // Do whatever setup is necessary to draw to our offscreen FBO, if it's |
michael@0 | 686 | // bound. |
michael@0 | 687 | void BeforeGLDrawCall() { |
michael@0 | 688 | } |
michael@0 | 689 | |
michael@0 | 690 | // Do whatever tear-down is necessary after drawing to our offscreen FBO, |
michael@0 | 691 | // if it's bound. |
michael@0 | 692 | void AfterGLDrawCall() |
michael@0 | 693 | { |
michael@0 | 694 | if (mScreen) |
michael@0 | 695 | mScreen->AfterDrawCall(); |
michael@0 | 696 | } |
michael@0 | 697 | |
michael@0 | 698 | // Do whatever setup is necessary to read from our offscreen FBO, if it's |
michael@0 | 699 | // bound. |
michael@0 | 700 | void BeforeGLReadCall() |
michael@0 | 701 | { |
michael@0 | 702 | if (mScreen) |
michael@0 | 703 | mScreen->BeforeReadCall(); |
michael@0 | 704 | } |
michael@0 | 705 | |
michael@0 | 706 | // Do whatever tear-down is necessary after reading from our offscreen FBO, |
michael@0 | 707 | // if it's bound. |
michael@0 | 708 | void AfterGLReadCall() { |
michael@0 | 709 | } |
michael@0 | 710 | |
michael@0 | 711 | |
michael@0 | 712 | // ----------------------------------------------------------------------------- |
michael@0 | 713 | // GL official entry points |
michael@0 | 714 | public: |
michael@0 | 715 | |
michael@0 | 716 | void fActiveTexture(GLenum texture) { |
michael@0 | 717 | BEFORE_GL_CALL; |
michael@0 | 718 | mSymbols.fActiveTexture(texture); |
michael@0 | 719 | AFTER_GL_CALL; |
michael@0 | 720 | } |
michael@0 | 721 | |
michael@0 | 722 | void fAttachShader(GLuint program, GLuint shader) { |
michael@0 | 723 | BEFORE_GL_CALL; |
michael@0 | 724 | mSymbols.fAttachShader(program, shader); |
michael@0 | 725 | AFTER_GL_CALL; |
michael@0 | 726 | } |
michael@0 | 727 | |
michael@0 | 728 | void fBeginQuery(GLenum target, GLuint id) { |
michael@0 | 729 | BEFORE_GL_CALL; |
michael@0 | 730 | ASSERT_SYMBOL_PRESENT(fBeginQuery); |
michael@0 | 731 | mSymbols.fBeginQuery(target, id); |
michael@0 | 732 | AFTER_GL_CALL; |
michael@0 | 733 | } |
michael@0 | 734 | |
michael@0 | 735 | void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) { |
michael@0 | 736 | BEFORE_GL_CALL; |
michael@0 | 737 | mSymbols.fBindAttribLocation(program, index, name); |
michael@0 | 738 | AFTER_GL_CALL; |
michael@0 | 739 | } |
michael@0 | 740 | |
michael@0 | 741 | void fBindBuffer(GLenum target, GLuint buffer) { |
michael@0 | 742 | BEFORE_GL_CALL; |
michael@0 | 743 | mSymbols.fBindBuffer(target, buffer); |
michael@0 | 744 | AFTER_GL_CALL; |
michael@0 | 745 | } |
michael@0 | 746 | |
michael@0 | 747 | void fBindFramebuffer(GLenum target, GLuint framebuffer) { |
michael@0 | 748 | if (!mScreen) { |
michael@0 | 749 | raw_fBindFramebuffer(target, framebuffer); |
michael@0 | 750 | return; |
michael@0 | 751 | } |
michael@0 | 752 | |
michael@0 | 753 | switch (target) { |
michael@0 | 754 | case LOCAL_GL_DRAW_FRAMEBUFFER_EXT: |
michael@0 | 755 | mScreen->BindDrawFB(framebuffer); |
michael@0 | 756 | return; |
michael@0 | 757 | |
michael@0 | 758 | case LOCAL_GL_READ_FRAMEBUFFER_EXT: |
michael@0 | 759 | mScreen->BindReadFB(framebuffer); |
michael@0 | 760 | return; |
michael@0 | 761 | |
michael@0 | 762 | case LOCAL_GL_FRAMEBUFFER: |
michael@0 | 763 | mScreen->BindFB(framebuffer); |
michael@0 | 764 | return; |
michael@0 | 765 | |
michael@0 | 766 | default: |
michael@0 | 767 | // Nothing we care about, likely an error. |
michael@0 | 768 | break; |
michael@0 | 769 | } |
michael@0 | 770 | |
michael@0 | 771 | raw_fBindFramebuffer(target, framebuffer); |
michael@0 | 772 | } |
michael@0 | 773 | |
michael@0 | 774 | void fBindTexture(GLenum target, GLuint texture) { |
michael@0 | 775 | BEFORE_GL_CALL; |
michael@0 | 776 | mSymbols.fBindTexture(target, texture); |
michael@0 | 777 | AFTER_GL_CALL; |
michael@0 | 778 | } |
michael@0 | 779 | |
michael@0 | 780 | void fBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { |
michael@0 | 781 | BEFORE_GL_CALL; |
michael@0 | 782 | mSymbols.fBlendColor(red, green, blue, alpha); |
michael@0 | 783 | AFTER_GL_CALL; |
michael@0 | 784 | } |
michael@0 | 785 | |
michael@0 | 786 | void fBlendEquation(GLenum mode) { |
michael@0 | 787 | BEFORE_GL_CALL; |
michael@0 | 788 | mSymbols.fBlendEquation(mode); |
michael@0 | 789 | AFTER_GL_CALL; |
michael@0 | 790 | } |
michael@0 | 791 | |
michael@0 | 792 | void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { |
michael@0 | 793 | BEFORE_GL_CALL; |
michael@0 | 794 | mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha); |
michael@0 | 795 | AFTER_GL_CALL; |
michael@0 | 796 | } |
michael@0 | 797 | |
michael@0 | 798 | void fBlendFunc(GLenum sfactor, GLenum dfactor) { |
michael@0 | 799 | BEFORE_GL_CALL; |
michael@0 | 800 | mSymbols.fBlendFunc(sfactor, dfactor); |
michael@0 | 801 | AFTER_GL_CALL; |
michael@0 | 802 | } |
michael@0 | 803 | |
michael@0 | 804 | void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) { |
michael@0 | 805 | BEFORE_GL_CALL; |
michael@0 | 806 | mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); |
michael@0 | 807 | AFTER_GL_CALL; |
michael@0 | 808 | } |
michael@0 | 809 | |
michael@0 | 810 | private: |
michael@0 | 811 | void raw_fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) { |
michael@0 | 812 | BEFORE_GL_CALL; |
michael@0 | 813 | mSymbols.fBufferData(target, size, data, usage); |
michael@0 | 814 | AFTER_GL_CALL; |
michael@0 | 815 | } |
michael@0 | 816 | |
michael@0 | 817 | public: |
michael@0 | 818 | void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) { |
michael@0 | 819 | raw_fBufferData(target, size, data, usage); |
michael@0 | 820 | |
michael@0 | 821 | // bug 744888 |
michael@0 | 822 | if (WorkAroundDriverBugs() && |
michael@0 | 823 | !data && |
michael@0 | 824 | Vendor() == GLVendor::NVIDIA) |
michael@0 | 825 | { |
michael@0 | 826 | char c = 0; |
michael@0 | 827 | fBufferSubData(target, size-1, 1, &c); |
michael@0 | 828 | } |
michael@0 | 829 | } |
michael@0 | 830 | |
michael@0 | 831 | void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) { |
michael@0 | 832 | BEFORE_GL_CALL; |
michael@0 | 833 | mSymbols.fBufferSubData(target, offset, size, data); |
michael@0 | 834 | AFTER_GL_CALL; |
michael@0 | 835 | } |
michael@0 | 836 | |
michael@0 | 837 | private: |
michael@0 | 838 | void raw_fClear(GLbitfield mask) { |
michael@0 | 839 | BEFORE_GL_CALL; |
michael@0 | 840 | mSymbols.fClear(mask); |
michael@0 | 841 | AFTER_GL_CALL; |
michael@0 | 842 | } |
michael@0 | 843 | |
michael@0 | 844 | public: |
michael@0 | 845 | void fClear(GLbitfield mask) { |
michael@0 | 846 | BeforeGLDrawCall(); |
michael@0 | 847 | raw_fClear(mask); |
michael@0 | 848 | AfterGLDrawCall(); |
michael@0 | 849 | } |
michael@0 | 850 | |
michael@0 | 851 | void fClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) { |
michael@0 | 852 | BEFORE_GL_CALL; |
michael@0 | 853 | mSymbols.fClearColor(r, g, b, a); |
michael@0 | 854 | AFTER_GL_CALL; |
michael@0 | 855 | } |
michael@0 | 856 | |
michael@0 | 857 | void fClearStencil(GLint s) { |
michael@0 | 858 | BEFORE_GL_CALL; |
michael@0 | 859 | mSymbols.fClearStencil(s); |
michael@0 | 860 | AFTER_GL_CALL; |
michael@0 | 861 | } |
michael@0 | 862 | |
michael@0 | 863 | void fClientActiveTexture(GLenum texture) { |
michael@0 | 864 | BEFORE_GL_CALL; |
michael@0 | 865 | mSymbols.fClientActiveTexture(texture); |
michael@0 | 866 | AFTER_GL_CALL; |
michael@0 | 867 | } |
michael@0 | 868 | |
michael@0 | 869 | void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) { |
michael@0 | 870 | BEFORE_GL_CALL; |
michael@0 | 871 | mSymbols.fColorMask(red, green, blue, alpha); |
michael@0 | 872 | AFTER_GL_CALL; |
michael@0 | 873 | } |
michael@0 | 874 | |
michael@0 | 875 | void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) { |
michael@0 | 876 | BEFORE_GL_CALL; |
michael@0 | 877 | mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels); |
michael@0 | 878 | AFTER_GL_CALL; |
michael@0 | 879 | } |
michael@0 | 880 | |
michael@0 | 881 | void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels) { |
michael@0 | 882 | BEFORE_GL_CALL; |
michael@0 | 883 | mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pixels); |
michael@0 | 884 | AFTER_GL_CALL; |
michael@0 | 885 | } |
michael@0 | 886 | |
michael@0 | 887 | void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { |
michael@0 | 888 | if (!IsTextureSizeSafeToPassToDriver(target, width, height)) { |
michael@0 | 889 | // pass wrong values to cause the GL to generate GL_INVALID_VALUE. |
michael@0 | 890 | // See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver. |
michael@0 | 891 | level = -1; |
michael@0 | 892 | width = -1; |
michael@0 | 893 | height = -1; |
michael@0 | 894 | border = -1; |
michael@0 | 895 | } |
michael@0 | 896 | |
michael@0 | 897 | BeforeGLReadCall(); |
michael@0 | 898 | raw_fCopyTexImage2D(target, level, internalformat, |
michael@0 | 899 | x, y, width, height, border); |
michael@0 | 900 | AfterGLReadCall(); |
michael@0 | 901 | } |
michael@0 | 902 | |
michael@0 | 903 | void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { |
michael@0 | 904 | BeforeGLReadCall(); |
michael@0 | 905 | raw_fCopyTexSubImage2D(target, level, xoffset, yoffset, |
michael@0 | 906 | x, y, width, height); |
michael@0 | 907 | AfterGLReadCall(); |
michael@0 | 908 | } |
michael@0 | 909 | |
michael@0 | 910 | void fCullFace(GLenum mode) { |
michael@0 | 911 | BEFORE_GL_CALL; |
michael@0 | 912 | mSymbols.fCullFace(mode); |
michael@0 | 913 | AFTER_GL_CALL; |
michael@0 | 914 | } |
michael@0 | 915 | |
michael@0 | 916 | void fDebugMessageCallback(GLDEBUGPROC callback, const GLvoid* userParam) { |
michael@0 | 917 | BEFORE_GL_CALL; |
michael@0 | 918 | ASSERT_SYMBOL_PRESENT(fDebugMessageCallback); |
michael@0 | 919 | mSymbols.fDebugMessageCallback(callback, userParam); |
michael@0 | 920 | AFTER_GL_CALL; |
michael@0 | 921 | } |
michael@0 | 922 | |
michael@0 | 923 | void fDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, realGLboolean enabled) { |
michael@0 | 924 | BEFORE_GL_CALL; |
michael@0 | 925 | ASSERT_SYMBOL_PRESENT(fDebugMessageControl); |
michael@0 | 926 | mSymbols.fDebugMessageControl(source, type, severity, count, ids, enabled); |
michael@0 | 927 | AFTER_GL_CALL; |
michael@0 | 928 | } |
michael@0 | 929 | |
michael@0 | 930 | void fDebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf) { |
michael@0 | 931 | BEFORE_GL_CALL; |
michael@0 | 932 | ASSERT_SYMBOL_PRESENT(fDebugMessageInsert); |
michael@0 | 933 | mSymbols.fDebugMessageInsert(source, type, id, severity, length, buf); |
michael@0 | 934 | AFTER_GL_CALL; |
michael@0 | 935 | } |
michael@0 | 936 | |
michael@0 | 937 | void fDetachShader(GLuint program, GLuint shader) { |
michael@0 | 938 | BEFORE_GL_CALL; |
michael@0 | 939 | mSymbols.fDetachShader(program, shader); |
michael@0 | 940 | AFTER_GL_CALL; |
michael@0 | 941 | } |
michael@0 | 942 | |
michael@0 | 943 | void fDepthFunc(GLenum func) { |
michael@0 | 944 | BEFORE_GL_CALL; |
michael@0 | 945 | mSymbols.fDepthFunc(func); |
michael@0 | 946 | AFTER_GL_CALL; |
michael@0 | 947 | } |
michael@0 | 948 | |
michael@0 | 949 | void fDepthMask(realGLboolean flag) { |
michael@0 | 950 | BEFORE_GL_CALL; |
michael@0 | 951 | mSymbols.fDepthMask(flag); |
michael@0 | 952 | AFTER_GL_CALL; |
michael@0 | 953 | } |
michael@0 | 954 | |
michael@0 | 955 | void fDisable(GLenum capability) { |
michael@0 | 956 | BEFORE_GL_CALL; |
michael@0 | 957 | mSymbols.fDisable(capability); |
michael@0 | 958 | AFTER_GL_CALL; |
michael@0 | 959 | } |
michael@0 | 960 | |
michael@0 | 961 | void fDisableClientState(GLenum capability) { |
michael@0 | 962 | BEFORE_GL_CALL; |
michael@0 | 963 | mSymbols.fDisableClientState(capability); |
michael@0 | 964 | AFTER_GL_CALL; |
michael@0 | 965 | } |
michael@0 | 966 | |
michael@0 | 967 | void fDisableVertexAttribArray(GLuint index) { |
michael@0 | 968 | BEFORE_GL_CALL; |
michael@0 | 969 | mSymbols.fDisableVertexAttribArray(index); |
michael@0 | 970 | AFTER_GL_CALL; |
michael@0 | 971 | } |
michael@0 | 972 | |
michael@0 | 973 | void fDrawBuffer(GLenum mode) { |
michael@0 | 974 | BEFORE_GL_CALL; |
michael@0 | 975 | mSymbols.fDrawBuffer(mode); |
michael@0 | 976 | AFTER_GL_CALL; |
michael@0 | 977 | } |
michael@0 | 978 | |
michael@0 | 979 | private: |
michael@0 | 980 | void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) { |
michael@0 | 981 | BEFORE_GL_CALL; |
michael@0 | 982 | mSymbols.fDrawArrays(mode, first, count); |
michael@0 | 983 | AFTER_GL_CALL; |
michael@0 | 984 | } |
michael@0 | 985 | |
michael@0 | 986 | void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { |
michael@0 | 987 | BEFORE_GL_CALL; |
michael@0 | 988 | mSymbols.fDrawElements(mode, count, type, indices); |
michael@0 | 989 | AFTER_GL_CALL; |
michael@0 | 990 | } |
michael@0 | 991 | |
michael@0 | 992 | public: |
michael@0 | 993 | void fDrawArrays(GLenum mode, GLint first, GLsizei count) { |
michael@0 | 994 | BeforeGLDrawCall(); |
michael@0 | 995 | raw_fDrawArrays(mode, first, count); |
michael@0 | 996 | AfterGLDrawCall(); |
michael@0 | 997 | } |
michael@0 | 998 | |
michael@0 | 999 | void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { |
michael@0 | 1000 | BeforeGLDrawCall(); |
michael@0 | 1001 | raw_fDrawElements(mode, count, type, indices); |
michael@0 | 1002 | AfterGLDrawCall(); |
michael@0 | 1003 | } |
michael@0 | 1004 | |
michael@0 | 1005 | void fEnable(GLenum capability) { |
michael@0 | 1006 | BEFORE_GL_CALL; |
michael@0 | 1007 | mSymbols.fEnable(capability); |
michael@0 | 1008 | AFTER_GL_CALL; |
michael@0 | 1009 | } |
michael@0 | 1010 | |
michael@0 | 1011 | void fEnableClientState(GLenum capability) { |
michael@0 | 1012 | BEFORE_GL_CALL; |
michael@0 | 1013 | mSymbols.fEnableClientState(capability); |
michael@0 | 1014 | AFTER_GL_CALL; |
michael@0 | 1015 | } |
michael@0 | 1016 | |
michael@0 | 1017 | void fEnableVertexAttribArray(GLuint index) { |
michael@0 | 1018 | BEFORE_GL_CALL; |
michael@0 | 1019 | mSymbols.fEnableVertexAttribArray(index); |
michael@0 | 1020 | AFTER_GL_CALL; |
michael@0 | 1021 | } |
michael@0 | 1022 | |
michael@0 | 1023 | void fEndQuery(GLenum target) { |
michael@0 | 1024 | BEFORE_GL_CALL; |
michael@0 | 1025 | ASSERT_SYMBOL_PRESENT(fEndQuery); |
michael@0 | 1026 | mSymbols.fEndQuery(target); |
michael@0 | 1027 | AFTER_GL_CALL; |
michael@0 | 1028 | } |
michael@0 | 1029 | |
michael@0 | 1030 | void fFinish() { |
michael@0 | 1031 | BEFORE_GL_CALL; |
michael@0 | 1032 | mSymbols.fFinish(); |
michael@0 | 1033 | AFTER_GL_CALL; |
michael@0 | 1034 | } |
michael@0 | 1035 | |
michael@0 | 1036 | void fFlush() { |
michael@0 | 1037 | BEFORE_GL_CALL; |
michael@0 | 1038 | mSymbols.fFlush(); |
michael@0 | 1039 | AFTER_GL_CALL; |
michael@0 | 1040 | } |
michael@0 | 1041 | |
michael@0 | 1042 | void fFrontFace(GLenum face) { |
michael@0 | 1043 | BEFORE_GL_CALL; |
michael@0 | 1044 | mSymbols.fFrontFace(face); |
michael@0 | 1045 | AFTER_GL_CALL; |
michael@0 | 1046 | } |
michael@0 | 1047 | |
michael@0 | 1048 | void fGetActiveAttrib(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { |
michael@0 | 1049 | BEFORE_GL_CALL; |
michael@0 | 1050 | mSymbols.fGetActiveAttrib(program, index, maxLength, length, size, type, name); |
michael@0 | 1051 | AFTER_GL_CALL; |
michael@0 | 1052 | } |
michael@0 | 1053 | |
michael@0 | 1054 | void fGetActiveUniform(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { |
michael@0 | 1055 | BEFORE_GL_CALL; |
michael@0 | 1056 | mSymbols.fGetActiveUniform(program, index, maxLength, length, size, type, name); |
michael@0 | 1057 | AFTER_GL_CALL; |
michael@0 | 1058 | } |
michael@0 | 1059 | |
michael@0 | 1060 | void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) { |
michael@0 | 1061 | BEFORE_GL_CALL; |
michael@0 | 1062 | mSymbols.fGetAttachedShaders(program, maxCount, count, shaders); |
michael@0 | 1063 | AFTER_GL_CALL; |
michael@0 | 1064 | } |
michael@0 | 1065 | |
michael@0 | 1066 | GLint fGetAttribLocation(GLuint program, const GLchar* name) { |
michael@0 | 1067 | BEFORE_GL_CALL; |
michael@0 | 1068 | GLint retval = mSymbols.fGetAttribLocation(program, name); |
michael@0 | 1069 | AFTER_GL_CALL; |
michael@0 | 1070 | return retval; |
michael@0 | 1071 | } |
michael@0 | 1072 | |
michael@0 | 1073 | private: |
michael@0 | 1074 | void raw_fGetIntegerv(GLenum pname, GLint *params) { |
michael@0 | 1075 | BEFORE_GL_CALL; |
michael@0 | 1076 | mSymbols.fGetIntegerv(pname, params); |
michael@0 | 1077 | AFTER_GL_CALL; |
michael@0 | 1078 | } |
michael@0 | 1079 | |
michael@0 | 1080 | public: |
michael@0 | 1081 | |
michael@0 | 1082 | void fGetIntegerv(GLenum pname, GLint *params) { |
michael@0 | 1083 | switch (pname) |
michael@0 | 1084 | { |
michael@0 | 1085 | // LOCAL_GL_FRAMEBUFFER_BINDING is equal to |
michael@0 | 1086 | // LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, |
michael@0 | 1087 | // so we don't need two cases. |
michael@0 | 1088 | case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT: |
michael@0 | 1089 | if (mScreen) { |
michael@0 | 1090 | *params = mScreen->GetDrawFB(); |
michael@0 | 1091 | } else { |
michael@0 | 1092 | raw_fGetIntegerv(pname, params); |
michael@0 | 1093 | } |
michael@0 | 1094 | break; |
michael@0 | 1095 | |
michael@0 | 1096 | case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT: |
michael@0 | 1097 | if (mScreen) { |
michael@0 | 1098 | *params = mScreen->GetReadFB(); |
michael@0 | 1099 | } else { |
michael@0 | 1100 | raw_fGetIntegerv(pname, params); |
michael@0 | 1101 | } |
michael@0 | 1102 | break; |
michael@0 | 1103 | |
michael@0 | 1104 | case LOCAL_GL_MAX_TEXTURE_SIZE: |
michael@0 | 1105 | MOZ_ASSERT(mMaxTextureSize>0); |
michael@0 | 1106 | *params = mMaxTextureSize; |
michael@0 | 1107 | break; |
michael@0 | 1108 | |
michael@0 | 1109 | case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
michael@0 | 1110 | MOZ_ASSERT(mMaxCubeMapTextureSize>0); |
michael@0 | 1111 | *params = mMaxCubeMapTextureSize; |
michael@0 | 1112 | break; |
michael@0 | 1113 | |
michael@0 | 1114 | case LOCAL_GL_MAX_RENDERBUFFER_SIZE: |
michael@0 | 1115 | MOZ_ASSERT(mMaxRenderbufferSize>0); |
michael@0 | 1116 | *params = mMaxRenderbufferSize; |
michael@0 | 1117 | break; |
michael@0 | 1118 | |
michael@0 | 1119 | case LOCAL_GL_VIEWPORT: |
michael@0 | 1120 | for (size_t i = 0; i < 4; i++) { |
michael@0 | 1121 | params[i] = mViewportRect[i]; |
michael@0 | 1122 | } |
michael@0 | 1123 | break; |
michael@0 | 1124 | |
michael@0 | 1125 | case LOCAL_GL_SCISSOR_BOX: |
michael@0 | 1126 | for (size_t i = 0; i < 4; i++) { |
michael@0 | 1127 | params[i] = mScissorRect[i]; |
michael@0 | 1128 | } |
michael@0 | 1129 | break; |
michael@0 | 1130 | |
michael@0 | 1131 | default: |
michael@0 | 1132 | raw_fGetIntegerv(pname, params); |
michael@0 | 1133 | break; |
michael@0 | 1134 | } |
michael@0 | 1135 | } |
michael@0 | 1136 | |
michael@0 | 1137 | void GetUIntegerv(GLenum pname, GLuint *params) { |
michael@0 | 1138 | fGetIntegerv(pname, reinterpret_cast<GLint*>(params)); |
michael@0 | 1139 | } |
michael@0 | 1140 | |
michael@0 | 1141 | void fGetFloatv(GLenum pname, GLfloat *params) { |
michael@0 | 1142 | BEFORE_GL_CALL; |
michael@0 | 1143 | mSymbols.fGetFloatv(pname, params); |
michael@0 | 1144 | AFTER_GL_CALL; |
michael@0 | 1145 | } |
michael@0 | 1146 | |
michael@0 | 1147 | void fGetBooleanv(GLenum pname, realGLboolean *params) { |
michael@0 | 1148 | BEFORE_GL_CALL; |
michael@0 | 1149 | mSymbols.fGetBooleanv(pname, params); |
michael@0 | 1150 | AFTER_GL_CALL; |
michael@0 | 1151 | } |
michael@0 | 1152 | |
michael@0 | 1153 | void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { |
michael@0 | 1154 | BEFORE_GL_CALL; |
michael@0 | 1155 | mSymbols.fGetBufferParameteriv(target, pname, params); |
michael@0 | 1156 | AFTER_GL_CALL; |
michael@0 | 1157 | } |
michael@0 | 1158 | |
michael@0 | 1159 | GLuint fGetDebugMessageLog(GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog) { |
michael@0 | 1160 | BEFORE_GL_CALL; |
michael@0 | 1161 | ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog); |
michael@0 | 1162 | GLuint ret = mSymbols.fGetDebugMessageLog(count, bufsize, sources, types, ids, severities, lengths, messageLog); |
michael@0 | 1163 | AFTER_GL_CALL; |
michael@0 | 1164 | return ret; |
michael@0 | 1165 | } |
michael@0 | 1166 | |
michael@0 | 1167 | void fGetPointerv(GLenum pname, GLvoid** params) { |
michael@0 | 1168 | BEFORE_GL_CALL; |
michael@0 | 1169 | ASSERT_SYMBOL_PRESENT(fGetPointerv); |
michael@0 | 1170 | mSymbols.fGetPointerv(pname, params); |
michael@0 | 1171 | AFTER_GL_CALL; |
michael@0 | 1172 | } |
michael@0 | 1173 | |
michael@0 | 1174 | void fGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label) { |
michael@0 | 1175 | BEFORE_GL_CALL; |
michael@0 | 1176 | ASSERT_SYMBOL_PRESENT(fGetObjectLabel); |
michael@0 | 1177 | mSymbols.fGetObjectLabel(identifier, name, bufSize, length, label); |
michael@0 | 1178 | AFTER_GL_CALL; |
michael@0 | 1179 | } |
michael@0 | 1180 | |
michael@0 | 1181 | void fGetObjectPtrLabel(const GLvoid* ptr, GLsizei bufSize, GLsizei* length, GLchar* label) { |
michael@0 | 1182 | BEFORE_GL_CALL; |
michael@0 | 1183 | ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel); |
michael@0 | 1184 | mSymbols.fGetObjectPtrLabel(ptr, bufSize, length, label); |
michael@0 | 1185 | AFTER_GL_CALL; |
michael@0 | 1186 | } |
michael@0 | 1187 | |
michael@0 | 1188 | void fGenerateMipmap(GLenum target) { |
michael@0 | 1189 | BEFORE_GL_CALL; |
michael@0 | 1190 | mSymbols.fGenerateMipmap(target); |
michael@0 | 1191 | AFTER_GL_CALL; |
michael@0 | 1192 | } |
michael@0 | 1193 | |
michael@0 | 1194 | void fGetProgramiv(GLuint program, GLenum pname, GLint* param) { |
michael@0 | 1195 | BEFORE_GL_CALL; |
michael@0 | 1196 | mSymbols.fGetProgramiv(program, pname, param); |
michael@0 | 1197 | AFTER_GL_CALL; |
michael@0 | 1198 | } |
michael@0 | 1199 | |
michael@0 | 1200 | void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { |
michael@0 | 1201 | BEFORE_GL_CALL; |
michael@0 | 1202 | mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog); |
michael@0 | 1203 | AFTER_GL_CALL; |
michael@0 | 1204 | } |
michael@0 | 1205 | |
michael@0 | 1206 | void fTexParameteri(GLenum target, GLenum pname, GLint param) { |
michael@0 | 1207 | BEFORE_GL_CALL; |
michael@0 | 1208 | mSymbols.fTexParameteri(target, pname, param); |
michael@0 | 1209 | AFTER_GL_CALL; |
michael@0 | 1210 | } |
michael@0 | 1211 | |
michael@0 | 1212 | void fTexParameteriv(GLenum target, GLenum pname, const GLint* params) { |
michael@0 | 1213 | BEFORE_GL_CALL; |
michael@0 | 1214 | mSymbols.fTexParameteriv(target, pname, params); |
michael@0 | 1215 | AFTER_GL_CALL; |
michael@0 | 1216 | } |
michael@0 | 1217 | |
michael@0 | 1218 | void fTexParameterf(GLenum target, GLenum pname, GLfloat param) { |
michael@0 | 1219 | BEFORE_GL_CALL; |
michael@0 | 1220 | mSymbols.fTexParameterf(target, pname, param); |
michael@0 | 1221 | AFTER_GL_CALL; |
michael@0 | 1222 | } |
michael@0 | 1223 | |
michael@0 | 1224 | const GLubyte* fGetString(GLenum name) { |
michael@0 | 1225 | BEFORE_GL_CALL; |
michael@0 | 1226 | const GLubyte *result = mSymbols.fGetString(name); |
michael@0 | 1227 | AFTER_GL_CALL; |
michael@0 | 1228 | return result; |
michael@0 | 1229 | } |
michael@0 | 1230 | |
michael@0 | 1231 | void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *img) { |
michael@0 | 1232 | BEFORE_GL_CALL; |
michael@0 | 1233 | ASSERT_SYMBOL_PRESENT(fGetTexImage); |
michael@0 | 1234 | mSymbols.fGetTexImage(target, level, format, type, img); |
michael@0 | 1235 | AFTER_GL_CALL; |
michael@0 | 1236 | } |
michael@0 | 1237 | |
michael@0 | 1238 | void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) |
michael@0 | 1239 | { |
michael@0 | 1240 | BEFORE_GL_CALL; |
michael@0 | 1241 | ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv); |
michael@0 | 1242 | mSymbols.fGetTexLevelParameteriv(target, level, pname, params); |
michael@0 | 1243 | AFTER_GL_CALL; |
michael@0 | 1244 | } |
michael@0 | 1245 | |
michael@0 | 1246 | void fGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { |
michael@0 | 1247 | BEFORE_GL_CALL; |
michael@0 | 1248 | mSymbols.fGetTexParameterfv(target, pname, params); |
michael@0 | 1249 | AFTER_GL_CALL; |
michael@0 | 1250 | } |
michael@0 | 1251 | |
michael@0 | 1252 | void fGetTexParameteriv(GLenum target, GLenum pname, GLint* params) { |
michael@0 | 1253 | BEFORE_GL_CALL; |
michael@0 | 1254 | mSymbols.fGetTexParameteriv(target, pname, params); |
michael@0 | 1255 | AFTER_GL_CALL; |
michael@0 | 1256 | } |
michael@0 | 1257 | |
michael@0 | 1258 | void fGetUniformfv(GLuint program, GLint location, GLfloat* params) { |
michael@0 | 1259 | BEFORE_GL_CALL; |
michael@0 | 1260 | mSymbols.fGetUniformfv(program, location, params); |
michael@0 | 1261 | AFTER_GL_CALL; |
michael@0 | 1262 | } |
michael@0 | 1263 | |
michael@0 | 1264 | void fGetUniformiv(GLuint program, GLint location, GLint* params) { |
michael@0 | 1265 | BEFORE_GL_CALL; |
michael@0 | 1266 | mSymbols.fGetUniformiv(program, location, params); |
michael@0 | 1267 | AFTER_GL_CALL; |
michael@0 | 1268 | } |
michael@0 | 1269 | |
michael@0 | 1270 | GLint fGetUniformLocation (GLint programObj, const GLchar* name) { |
michael@0 | 1271 | BEFORE_GL_CALL; |
michael@0 | 1272 | GLint retval = mSymbols.fGetUniformLocation(programObj, name); |
michael@0 | 1273 | AFTER_GL_CALL; |
michael@0 | 1274 | return retval; |
michael@0 | 1275 | } |
michael@0 | 1276 | |
michael@0 | 1277 | void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) { |
michael@0 | 1278 | BEFORE_GL_CALL; |
michael@0 | 1279 | mSymbols.fGetVertexAttribfv(index, pname, retval); |
michael@0 | 1280 | AFTER_GL_CALL; |
michael@0 | 1281 | } |
michael@0 | 1282 | |
michael@0 | 1283 | void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) { |
michael@0 | 1284 | BEFORE_GL_CALL; |
michael@0 | 1285 | mSymbols.fGetVertexAttribiv(index, pname, retval); |
michael@0 | 1286 | AFTER_GL_CALL; |
michael@0 | 1287 | } |
michael@0 | 1288 | |
michael@0 | 1289 | void fGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** retval) { |
michael@0 | 1290 | BEFORE_GL_CALL; |
michael@0 | 1291 | mSymbols.fGetVertexAttribPointerv(index, pname, retval); |
michael@0 | 1292 | AFTER_GL_CALL; |
michael@0 | 1293 | } |
michael@0 | 1294 | |
michael@0 | 1295 | void fHint(GLenum target, GLenum mode) { |
michael@0 | 1296 | BEFORE_GL_CALL; |
michael@0 | 1297 | mSymbols.fHint(target, mode); |
michael@0 | 1298 | AFTER_GL_CALL; |
michael@0 | 1299 | } |
michael@0 | 1300 | |
michael@0 | 1301 | realGLboolean fIsBuffer(GLuint buffer) { |
michael@0 | 1302 | BEFORE_GL_CALL; |
michael@0 | 1303 | realGLboolean retval = mSymbols.fIsBuffer(buffer); |
michael@0 | 1304 | AFTER_GL_CALL; |
michael@0 | 1305 | return retval; |
michael@0 | 1306 | } |
michael@0 | 1307 | |
michael@0 | 1308 | realGLboolean fIsEnabled(GLenum capability) { |
michael@0 | 1309 | BEFORE_GL_CALL; |
michael@0 | 1310 | realGLboolean retval = mSymbols.fIsEnabled(capability); |
michael@0 | 1311 | AFTER_GL_CALL; |
michael@0 | 1312 | return retval; |
michael@0 | 1313 | } |
michael@0 | 1314 | |
michael@0 | 1315 | realGLboolean fIsProgram(GLuint program) { |
michael@0 | 1316 | BEFORE_GL_CALL; |
michael@0 | 1317 | realGLboolean retval = mSymbols.fIsProgram(program); |
michael@0 | 1318 | AFTER_GL_CALL; |
michael@0 | 1319 | return retval; |
michael@0 | 1320 | } |
michael@0 | 1321 | |
michael@0 | 1322 | realGLboolean fIsShader(GLuint shader) { |
michael@0 | 1323 | BEFORE_GL_CALL; |
michael@0 | 1324 | realGLboolean retval = mSymbols.fIsShader(shader); |
michael@0 | 1325 | AFTER_GL_CALL; |
michael@0 | 1326 | return retval; |
michael@0 | 1327 | } |
michael@0 | 1328 | |
michael@0 | 1329 | realGLboolean fIsTexture(GLuint texture) { |
michael@0 | 1330 | BEFORE_GL_CALL; |
michael@0 | 1331 | realGLboolean retval = mSymbols.fIsTexture(texture); |
michael@0 | 1332 | AFTER_GL_CALL; |
michael@0 | 1333 | return retval; |
michael@0 | 1334 | } |
michael@0 | 1335 | |
michael@0 | 1336 | void fLineWidth(GLfloat width) { |
michael@0 | 1337 | BEFORE_GL_CALL; |
michael@0 | 1338 | mSymbols.fLineWidth(width); |
michael@0 | 1339 | AFTER_GL_CALL; |
michael@0 | 1340 | } |
michael@0 | 1341 | |
michael@0 | 1342 | void fLinkProgram(GLuint program) { |
michael@0 | 1343 | BEFORE_GL_CALL; |
michael@0 | 1344 | mSymbols.fLinkProgram(program); |
michael@0 | 1345 | AFTER_GL_CALL; |
michael@0 | 1346 | } |
michael@0 | 1347 | |
michael@0 | 1348 | void fObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar* label) { |
michael@0 | 1349 | BEFORE_GL_CALL; |
michael@0 | 1350 | ASSERT_SYMBOL_PRESENT(fObjectLabel); |
michael@0 | 1351 | mSymbols.fObjectLabel(identifier, name, length, label); |
michael@0 | 1352 | AFTER_GL_CALL; |
michael@0 | 1353 | } |
michael@0 | 1354 | |
michael@0 | 1355 | void fObjectPtrLabel(const GLvoid* ptr, GLsizei length, const GLchar* label) { |
michael@0 | 1356 | BEFORE_GL_CALL; |
michael@0 | 1357 | ASSERT_SYMBOL_PRESENT(fObjectPtrLabel); |
michael@0 | 1358 | mSymbols.fObjectPtrLabel(ptr, length, label); |
michael@0 | 1359 | AFTER_GL_CALL; |
michael@0 | 1360 | } |
michael@0 | 1361 | |
michael@0 | 1362 | void fLoadIdentity() { |
michael@0 | 1363 | BEFORE_GL_CALL; |
michael@0 | 1364 | mSymbols.fLoadIdentity(); |
michael@0 | 1365 | AFTER_GL_CALL; |
michael@0 | 1366 | } |
michael@0 | 1367 | |
michael@0 | 1368 | void fLoadMatrixf(const GLfloat *matrix) { |
michael@0 | 1369 | BEFORE_GL_CALL; |
michael@0 | 1370 | mSymbols.fLoadMatrixf(matrix); |
michael@0 | 1371 | AFTER_GL_CALL; |
michael@0 | 1372 | } |
michael@0 | 1373 | |
michael@0 | 1374 | void fMatrixMode(GLenum mode) { |
michael@0 | 1375 | BEFORE_GL_CALL; |
michael@0 | 1376 | mSymbols.fMatrixMode(mode); |
michael@0 | 1377 | AFTER_GL_CALL; |
michael@0 | 1378 | } |
michael@0 | 1379 | |
michael@0 | 1380 | void fPixelStorei(GLenum pname, GLint param) { |
michael@0 | 1381 | BEFORE_GL_CALL; |
michael@0 | 1382 | mSymbols.fPixelStorei(pname, param); |
michael@0 | 1383 | AFTER_GL_CALL; |
michael@0 | 1384 | } |
michael@0 | 1385 | |
michael@0 | 1386 | void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid *pointer) { |
michael@0 | 1387 | BEFORE_GL_CALL; |
michael@0 | 1388 | mSymbols.fTextureRangeAPPLE(target, length, pointer); |
michael@0 | 1389 | AFTER_GL_CALL; |
michael@0 | 1390 | } |
michael@0 | 1391 | |
michael@0 | 1392 | void fPointParameterf(GLenum pname, GLfloat param) { |
michael@0 | 1393 | BEFORE_GL_CALL; |
michael@0 | 1394 | mSymbols.fPointParameterf(pname, param); |
michael@0 | 1395 | AFTER_GL_CALL; |
michael@0 | 1396 | } |
michael@0 | 1397 | |
michael@0 | 1398 | void fPolygonOffset(GLfloat factor, GLfloat bias) { |
michael@0 | 1399 | BEFORE_GL_CALL; |
michael@0 | 1400 | mSymbols.fPolygonOffset(factor, bias); |
michael@0 | 1401 | AFTER_GL_CALL; |
michael@0 | 1402 | } |
michael@0 | 1403 | |
michael@0 | 1404 | void fPopDebugGroup() { |
michael@0 | 1405 | BEFORE_GL_CALL; |
michael@0 | 1406 | ASSERT_SYMBOL_PRESENT(fPopDebugGroup); |
michael@0 | 1407 | mSymbols.fPopDebugGroup(); |
michael@0 | 1408 | AFTER_GL_CALL; |
michael@0 | 1409 | } |
michael@0 | 1410 | |
michael@0 | 1411 | void fPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar* message) { |
michael@0 | 1412 | BEFORE_GL_CALL; |
michael@0 | 1413 | ASSERT_SYMBOL_PRESENT(fPushDebugGroup); |
michael@0 | 1414 | mSymbols.fPushDebugGroup(source, id, length, message); |
michael@0 | 1415 | AFTER_GL_CALL; |
michael@0 | 1416 | } |
michael@0 | 1417 | |
michael@0 | 1418 | void fReadBuffer(GLenum mode) { |
michael@0 | 1419 | BEFORE_GL_CALL; |
michael@0 | 1420 | mSymbols.fReadBuffer(mode); |
michael@0 | 1421 | AFTER_GL_CALL; |
michael@0 | 1422 | } |
michael@0 | 1423 | |
michael@0 | 1424 | private: |
michael@0 | 1425 | void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { |
michael@0 | 1426 | BEFORE_GL_CALL; |
michael@0 | 1427 | mSymbols.fReadPixels(x, y, width, height, format, type, pixels); |
michael@0 | 1428 | AFTER_GL_CALL; |
michael@0 | 1429 | } |
michael@0 | 1430 | |
michael@0 | 1431 | public: |
michael@0 | 1432 | void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { |
michael@0 | 1433 | BeforeGLReadCall(); |
michael@0 | 1434 | |
michael@0 | 1435 | bool didReadPixels = false; |
michael@0 | 1436 | if (mScreen) { |
michael@0 | 1437 | didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels); |
michael@0 | 1438 | } |
michael@0 | 1439 | |
michael@0 | 1440 | if (!didReadPixels) { |
michael@0 | 1441 | raw_fReadPixels(x, y, width, height, format, type, pixels); |
michael@0 | 1442 | } |
michael@0 | 1443 | |
michael@0 | 1444 | AfterGLReadCall(); |
michael@0 | 1445 | } |
michael@0 | 1446 | |
michael@0 | 1447 | public: |
michael@0 | 1448 | void fSampleCoverage(GLclampf value, realGLboolean invert) { |
michael@0 | 1449 | BEFORE_GL_CALL; |
michael@0 | 1450 | mSymbols.fSampleCoverage(value, invert); |
michael@0 | 1451 | AFTER_GL_CALL; |
michael@0 | 1452 | } |
michael@0 | 1453 | |
michael@0 | 1454 | void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) { |
michael@0 | 1455 | if (mScissorRect[0] == x && |
michael@0 | 1456 | mScissorRect[1] == y && |
michael@0 | 1457 | mScissorRect[2] == width && |
michael@0 | 1458 | mScissorRect[3] == height) |
michael@0 | 1459 | { |
michael@0 | 1460 | return; |
michael@0 | 1461 | } |
michael@0 | 1462 | mScissorRect[0] = x; |
michael@0 | 1463 | mScissorRect[1] = y; |
michael@0 | 1464 | mScissorRect[2] = width; |
michael@0 | 1465 | mScissorRect[3] = height; |
michael@0 | 1466 | BEFORE_GL_CALL; |
michael@0 | 1467 | mSymbols.fScissor(x, y, width, height); |
michael@0 | 1468 | AFTER_GL_CALL; |
michael@0 | 1469 | } |
michael@0 | 1470 | |
michael@0 | 1471 | void fStencilFunc(GLenum func, GLint ref, GLuint mask) { |
michael@0 | 1472 | BEFORE_GL_CALL; |
michael@0 | 1473 | mSymbols.fStencilFunc(func, ref, mask); |
michael@0 | 1474 | AFTER_GL_CALL; |
michael@0 | 1475 | } |
michael@0 | 1476 | |
michael@0 | 1477 | void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) { |
michael@0 | 1478 | BEFORE_GL_CALL; |
michael@0 | 1479 | mSymbols.fStencilFuncSeparate(frontfunc, backfunc, ref, mask); |
michael@0 | 1480 | AFTER_GL_CALL; |
michael@0 | 1481 | } |
michael@0 | 1482 | |
michael@0 | 1483 | void fStencilMask(GLuint mask) { |
michael@0 | 1484 | BEFORE_GL_CALL; |
michael@0 | 1485 | mSymbols.fStencilMask(mask); |
michael@0 | 1486 | AFTER_GL_CALL; |
michael@0 | 1487 | } |
michael@0 | 1488 | |
michael@0 | 1489 | void fStencilMaskSeparate(GLenum face, GLuint mask) { |
michael@0 | 1490 | BEFORE_GL_CALL; |
michael@0 | 1491 | mSymbols.fStencilMaskSeparate(face, mask); |
michael@0 | 1492 | AFTER_GL_CALL; |
michael@0 | 1493 | } |
michael@0 | 1494 | |
michael@0 | 1495 | void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { |
michael@0 | 1496 | BEFORE_GL_CALL; |
michael@0 | 1497 | mSymbols.fStencilOp(fail, zfail, zpass); |
michael@0 | 1498 | AFTER_GL_CALL; |
michael@0 | 1499 | } |
michael@0 | 1500 | |
michael@0 | 1501 | void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { |
michael@0 | 1502 | BEFORE_GL_CALL; |
michael@0 | 1503 | mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass); |
michael@0 | 1504 | AFTER_GL_CALL; |
michael@0 | 1505 | } |
michael@0 | 1506 | |
michael@0 | 1507 | void fTexGeni(GLenum coord, GLenum pname, GLint param) { |
michael@0 | 1508 | BEFORE_GL_CALL; |
michael@0 | 1509 | mSymbols.fTexGeni(coord, pname, param); |
michael@0 | 1510 | AFTER_GL_CALL; |
michael@0 | 1511 | } |
michael@0 | 1512 | |
michael@0 | 1513 | void fTexGenf(GLenum coord, GLenum pname, GLfloat param) { |
michael@0 | 1514 | BEFORE_GL_CALL; |
michael@0 | 1515 | mSymbols.fTexGenf(coord, pname, param); |
michael@0 | 1516 | AFTER_GL_CALL; |
michael@0 | 1517 | } |
michael@0 | 1518 | |
michael@0 | 1519 | void fTexGenfv(GLenum coord, GLenum pname, const GLfloat *params) { |
michael@0 | 1520 | BEFORE_GL_CALL; |
michael@0 | 1521 | mSymbols.fTexGenfv(coord, pname, params); |
michael@0 | 1522 | AFTER_GL_CALL; |
michael@0 | 1523 | } |
michael@0 | 1524 | |
michael@0 | 1525 | private: |
michael@0 | 1526 | void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { |
michael@0 | 1527 | BEFORE_GL_CALL; |
michael@0 | 1528 | mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
michael@0 | 1529 | AFTER_GL_CALL; |
michael@0 | 1530 | } |
michael@0 | 1531 | |
michael@0 | 1532 | public: |
michael@0 | 1533 | void fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { |
michael@0 | 1534 | if (!IsTextureSizeSafeToPassToDriver(target, width, height)) { |
michael@0 | 1535 | // pass wrong values to cause the GL to generate GL_INVALID_VALUE. |
michael@0 | 1536 | // See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver. |
michael@0 | 1537 | level = -1; |
michael@0 | 1538 | width = -1; |
michael@0 | 1539 | height = -1; |
michael@0 | 1540 | border = -1; |
michael@0 | 1541 | } |
michael@0 | 1542 | raw_fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
michael@0 | 1543 | } |
michael@0 | 1544 | |
michael@0 | 1545 | void fTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { |
michael@0 | 1546 | BEFORE_GL_CALL; |
michael@0 | 1547 | mSymbols.fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
michael@0 | 1548 | AFTER_GL_CALL; |
michael@0 | 1549 | } |
michael@0 | 1550 | |
michael@0 | 1551 | void fUniform1f(GLint location, GLfloat v0) { |
michael@0 | 1552 | BEFORE_GL_CALL; |
michael@0 | 1553 | mSymbols.fUniform1f(location, v0); |
michael@0 | 1554 | AFTER_GL_CALL; |
michael@0 | 1555 | } |
michael@0 | 1556 | |
michael@0 | 1557 | void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) { |
michael@0 | 1558 | BEFORE_GL_CALL; |
michael@0 | 1559 | mSymbols.fUniform1fv(location, count, value); |
michael@0 | 1560 | AFTER_GL_CALL; |
michael@0 | 1561 | } |
michael@0 | 1562 | |
michael@0 | 1563 | void fUniform1i(GLint location, GLint v0) { |
michael@0 | 1564 | BEFORE_GL_CALL; |
michael@0 | 1565 | mSymbols.fUniform1i(location, v0); |
michael@0 | 1566 | AFTER_GL_CALL; |
michael@0 | 1567 | } |
michael@0 | 1568 | |
michael@0 | 1569 | void fUniform1iv(GLint location, GLsizei count, const GLint* value) { |
michael@0 | 1570 | BEFORE_GL_CALL; |
michael@0 | 1571 | mSymbols.fUniform1iv(location, count, value); |
michael@0 | 1572 | AFTER_GL_CALL; |
michael@0 | 1573 | } |
michael@0 | 1574 | |
michael@0 | 1575 | void fUniform2f(GLint location, GLfloat v0, GLfloat v1) { |
michael@0 | 1576 | BEFORE_GL_CALL; |
michael@0 | 1577 | mSymbols.fUniform2f(location, v0, v1); |
michael@0 | 1578 | AFTER_GL_CALL; |
michael@0 | 1579 | } |
michael@0 | 1580 | |
michael@0 | 1581 | void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) { |
michael@0 | 1582 | BEFORE_GL_CALL; |
michael@0 | 1583 | mSymbols.fUniform2fv(location, count, value); |
michael@0 | 1584 | AFTER_GL_CALL; |
michael@0 | 1585 | } |
michael@0 | 1586 | |
michael@0 | 1587 | void fUniform2i(GLint location, GLint v0, GLint v1) { |
michael@0 | 1588 | BEFORE_GL_CALL; |
michael@0 | 1589 | mSymbols.fUniform2i(location, v0, v1); |
michael@0 | 1590 | AFTER_GL_CALL; |
michael@0 | 1591 | } |
michael@0 | 1592 | |
michael@0 | 1593 | void fUniform2iv(GLint location, GLsizei count, const GLint* value) { |
michael@0 | 1594 | BEFORE_GL_CALL; |
michael@0 | 1595 | mSymbols.fUniform2iv(location, count, value); |
michael@0 | 1596 | AFTER_GL_CALL; |
michael@0 | 1597 | } |
michael@0 | 1598 | |
michael@0 | 1599 | void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { |
michael@0 | 1600 | BEFORE_GL_CALL; |
michael@0 | 1601 | mSymbols.fUniform3f(location, v0, v1, v2); |
michael@0 | 1602 | AFTER_GL_CALL; |
michael@0 | 1603 | } |
michael@0 | 1604 | |
michael@0 | 1605 | void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) { |
michael@0 | 1606 | BEFORE_GL_CALL; |
michael@0 | 1607 | mSymbols.fUniform3fv(location, count, value); |
michael@0 | 1608 | AFTER_GL_CALL; |
michael@0 | 1609 | } |
michael@0 | 1610 | |
michael@0 | 1611 | void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) { |
michael@0 | 1612 | BEFORE_GL_CALL; |
michael@0 | 1613 | mSymbols.fUniform3i(location, v0, v1, v2); |
michael@0 | 1614 | AFTER_GL_CALL; |
michael@0 | 1615 | } |
michael@0 | 1616 | |
michael@0 | 1617 | void fUniform3iv(GLint location, GLsizei count, const GLint* value) { |
michael@0 | 1618 | BEFORE_GL_CALL; |
michael@0 | 1619 | mSymbols.fUniform3iv(location, count, value); |
michael@0 | 1620 | AFTER_GL_CALL; |
michael@0 | 1621 | } |
michael@0 | 1622 | |
michael@0 | 1623 | void fUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { |
michael@0 | 1624 | BEFORE_GL_CALL; |
michael@0 | 1625 | mSymbols.fUniform4f(location, v0, v1, v2, v3); |
michael@0 | 1626 | AFTER_GL_CALL; |
michael@0 | 1627 | } |
michael@0 | 1628 | |
michael@0 | 1629 | void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) { |
michael@0 | 1630 | BEFORE_GL_CALL; |
michael@0 | 1631 | mSymbols.fUniform4fv(location, count, value); |
michael@0 | 1632 | AFTER_GL_CALL; |
michael@0 | 1633 | } |
michael@0 | 1634 | |
michael@0 | 1635 | void fUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { |
michael@0 | 1636 | BEFORE_GL_CALL; |
michael@0 | 1637 | mSymbols.fUniform4i(location, v0, v1, v2, v3); |
michael@0 | 1638 | AFTER_GL_CALL; |
michael@0 | 1639 | } |
michael@0 | 1640 | |
michael@0 | 1641 | void fUniform4iv(GLint location, GLsizei count, const GLint* value) { |
michael@0 | 1642 | BEFORE_GL_CALL; |
michael@0 | 1643 | mSymbols.fUniform4iv(location, count, value); |
michael@0 | 1644 | AFTER_GL_CALL; |
michael@0 | 1645 | } |
michael@0 | 1646 | |
michael@0 | 1647 | void fUniformMatrix2fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { |
michael@0 | 1648 | BEFORE_GL_CALL; |
michael@0 | 1649 | mSymbols.fUniformMatrix2fv(location, count, transpose, value); |
michael@0 | 1650 | AFTER_GL_CALL; |
michael@0 | 1651 | } |
michael@0 | 1652 | |
michael@0 | 1653 | void fUniformMatrix3fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { |
michael@0 | 1654 | BEFORE_GL_CALL; |
michael@0 | 1655 | mSymbols.fUniformMatrix3fv(location, count, transpose, value); |
michael@0 | 1656 | AFTER_GL_CALL; |
michael@0 | 1657 | } |
michael@0 | 1658 | |
michael@0 | 1659 | void fUniformMatrix4fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { |
michael@0 | 1660 | BEFORE_GL_CALL; |
michael@0 | 1661 | mSymbols.fUniformMatrix4fv(location, count, transpose, value); |
michael@0 | 1662 | AFTER_GL_CALL; |
michael@0 | 1663 | } |
michael@0 | 1664 | |
michael@0 | 1665 | void fUseProgram(GLuint program) { |
michael@0 | 1666 | BEFORE_GL_CALL; |
michael@0 | 1667 | mSymbols.fUseProgram(program); |
michael@0 | 1668 | AFTER_GL_CALL; |
michael@0 | 1669 | } |
michael@0 | 1670 | |
michael@0 | 1671 | void fValidateProgram(GLuint program) { |
michael@0 | 1672 | BEFORE_GL_CALL; |
michael@0 | 1673 | mSymbols.fValidateProgram(program); |
michael@0 | 1674 | AFTER_GL_CALL; |
michael@0 | 1675 | } |
michael@0 | 1676 | |
michael@0 | 1677 | void fVertexAttribPointer(GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer) { |
michael@0 | 1678 | BEFORE_GL_CALL; |
michael@0 | 1679 | mSymbols.fVertexAttribPointer(index, size, type, normalized, stride, pointer); |
michael@0 | 1680 | AFTER_GL_CALL; |
michael@0 | 1681 | } |
michael@0 | 1682 | |
michael@0 | 1683 | void fVertexAttrib1f(GLuint index, GLfloat x) { |
michael@0 | 1684 | BEFORE_GL_CALL; |
michael@0 | 1685 | mSymbols.fVertexAttrib1f(index, x); |
michael@0 | 1686 | AFTER_GL_CALL; |
michael@0 | 1687 | } |
michael@0 | 1688 | |
michael@0 | 1689 | void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) { |
michael@0 | 1690 | BEFORE_GL_CALL; |
michael@0 | 1691 | mSymbols.fVertexAttrib2f(index, x, y); |
michael@0 | 1692 | AFTER_GL_CALL; |
michael@0 | 1693 | } |
michael@0 | 1694 | |
michael@0 | 1695 | void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) { |
michael@0 | 1696 | BEFORE_GL_CALL; |
michael@0 | 1697 | mSymbols.fVertexAttrib3f(index, x, y, z); |
michael@0 | 1698 | AFTER_GL_CALL; |
michael@0 | 1699 | } |
michael@0 | 1700 | |
michael@0 | 1701 | void fVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { |
michael@0 | 1702 | BEFORE_GL_CALL; |
michael@0 | 1703 | mSymbols.fVertexAttrib4f(index, x, y, z, w); |
michael@0 | 1704 | AFTER_GL_CALL; |
michael@0 | 1705 | } |
michael@0 | 1706 | |
michael@0 | 1707 | void fVertexAttrib1fv(GLuint index, const GLfloat* v) { |
michael@0 | 1708 | BEFORE_GL_CALL; |
michael@0 | 1709 | mSymbols.fVertexAttrib1fv(index, v); |
michael@0 | 1710 | AFTER_GL_CALL; |
michael@0 | 1711 | } |
michael@0 | 1712 | |
michael@0 | 1713 | void fVertexAttrib2fv(GLuint index, const GLfloat* v) { |
michael@0 | 1714 | BEFORE_GL_CALL; |
michael@0 | 1715 | mSymbols.fVertexAttrib2fv(index, v); |
michael@0 | 1716 | AFTER_GL_CALL; |
michael@0 | 1717 | } |
michael@0 | 1718 | |
michael@0 | 1719 | void fVertexAttrib3fv(GLuint index, const GLfloat* v) { |
michael@0 | 1720 | BEFORE_GL_CALL; |
michael@0 | 1721 | mSymbols.fVertexAttrib3fv(index, v); |
michael@0 | 1722 | AFTER_GL_CALL; |
michael@0 | 1723 | } |
michael@0 | 1724 | |
michael@0 | 1725 | void fVertexAttrib4fv(GLuint index, const GLfloat* v) { |
michael@0 | 1726 | BEFORE_GL_CALL; |
michael@0 | 1727 | mSymbols.fVertexAttrib4fv(index, v); |
michael@0 | 1728 | AFTER_GL_CALL; |
michael@0 | 1729 | } |
michael@0 | 1730 | |
michael@0 | 1731 | void fVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { |
michael@0 | 1732 | BEFORE_GL_CALL; |
michael@0 | 1733 | mSymbols.fVertexPointer(size, type, stride, pointer); |
michael@0 | 1734 | AFTER_GL_CALL; |
michael@0 | 1735 | } |
michael@0 | 1736 | |
michael@0 | 1737 | void fCompileShader(GLuint shader) { |
michael@0 | 1738 | BEFORE_GL_CALL; |
michael@0 | 1739 | mSymbols.fCompileShader(shader); |
michael@0 | 1740 | AFTER_GL_CALL; |
michael@0 | 1741 | } |
michael@0 | 1742 | |
michael@0 | 1743 | private: |
michael@0 | 1744 | void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { |
michael@0 | 1745 | BEFORE_GL_CALL; |
michael@0 | 1746 | mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height, border); |
michael@0 | 1747 | AFTER_GL_CALL; |
michael@0 | 1748 | } |
michael@0 | 1749 | |
michael@0 | 1750 | void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { |
michael@0 | 1751 | BEFORE_GL_CALL; |
michael@0 | 1752 | mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); |
michael@0 | 1753 | AFTER_GL_CALL; |
michael@0 | 1754 | } |
michael@0 | 1755 | |
michael@0 | 1756 | public: |
michael@0 | 1757 | void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) { |
michael@0 | 1758 | BEFORE_GL_CALL; |
michael@0 | 1759 | mSymbols.fGetShaderiv(shader, pname, param); |
michael@0 | 1760 | AFTER_GL_CALL; |
michael@0 | 1761 | } |
michael@0 | 1762 | |
michael@0 | 1763 | void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { |
michael@0 | 1764 | BEFORE_GL_CALL; |
michael@0 | 1765 | mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog); |
michael@0 | 1766 | AFTER_GL_CALL; |
michael@0 | 1767 | } |
michael@0 | 1768 | |
michael@0 | 1769 | private: |
michael@0 | 1770 | void raw_fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
michael@0 | 1771 | MOZ_ASSERT(IsGLES()); |
michael@0 | 1772 | |
michael@0 | 1773 | BEFORE_GL_CALL; |
michael@0 | 1774 | ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat); |
michael@0 | 1775 | mSymbols.fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); |
michael@0 | 1776 | AFTER_GL_CALL; |
michael@0 | 1777 | } |
michael@0 | 1778 | |
michael@0 | 1779 | public: |
michael@0 | 1780 | void fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
michael@0 | 1781 | if (IsGLES()) { |
michael@0 | 1782 | raw_fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); |
michael@0 | 1783 | } else { |
michael@0 | 1784 | // Fall back to automatic values because almost all desktop hardware supports the OpenGL standard precisions. |
michael@0 | 1785 | GetShaderPrecisionFormatNonES2(shadertype, precisiontype, range, precision); |
michael@0 | 1786 | } |
michael@0 | 1787 | } |
michael@0 | 1788 | |
michael@0 | 1789 | void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source) { |
michael@0 | 1790 | BEFORE_GL_CALL; |
michael@0 | 1791 | mSymbols.fGetShaderSource(obj, maxLength, length, source); |
michael@0 | 1792 | AFTER_GL_CALL; |
michael@0 | 1793 | } |
michael@0 | 1794 | |
michael@0 | 1795 | void fShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) { |
michael@0 | 1796 | BEFORE_GL_CALL; |
michael@0 | 1797 | mSymbols.fShaderSource(shader, count, strings, lengths); |
michael@0 | 1798 | AFTER_GL_CALL; |
michael@0 | 1799 | } |
michael@0 | 1800 | |
michael@0 | 1801 | private: |
michael@0 | 1802 | void raw_fBindFramebuffer(GLenum target, GLuint framebuffer) { |
michael@0 | 1803 | BEFORE_GL_CALL; |
michael@0 | 1804 | mSymbols.fBindFramebuffer(target, framebuffer); |
michael@0 | 1805 | AFTER_GL_CALL; |
michael@0 | 1806 | } |
michael@0 | 1807 | |
michael@0 | 1808 | public: |
michael@0 | 1809 | void fBindRenderbuffer(GLenum target, GLuint renderbuffer) { |
michael@0 | 1810 | BEFORE_GL_CALL; |
michael@0 | 1811 | mSymbols.fBindRenderbuffer(target, renderbuffer); |
michael@0 | 1812 | AFTER_GL_CALL; |
michael@0 | 1813 | } |
michael@0 | 1814 | |
michael@0 | 1815 | GLenum fCheckFramebufferStatus(GLenum target) { |
michael@0 | 1816 | BEFORE_GL_CALL; |
michael@0 | 1817 | GLenum retval = mSymbols.fCheckFramebufferStatus(target); |
michael@0 | 1818 | AFTER_GL_CALL; |
michael@0 | 1819 | return retval; |
michael@0 | 1820 | } |
michael@0 | 1821 | |
michael@0 | 1822 | void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer) { |
michael@0 | 1823 | BEFORE_GL_CALL; |
michael@0 | 1824 | mSymbols.fFramebufferRenderbuffer(target, attachmentPoint, renderbufferTarget, renderbuffer); |
michael@0 | 1825 | AFTER_GL_CALL; |
michael@0 | 1826 | } |
michael@0 | 1827 | |
michael@0 | 1828 | void fFramebufferTexture2D(GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level) { |
michael@0 | 1829 | BEFORE_GL_CALL; |
michael@0 | 1830 | mSymbols.fFramebufferTexture2D(target, attachmentPoint, textureTarget, texture, level); |
michael@0 | 1831 | AFTER_GL_CALL; |
michael@0 | 1832 | } |
michael@0 | 1833 | |
michael@0 | 1834 | void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* value) { |
michael@0 | 1835 | BEFORE_GL_CALL; |
michael@0 | 1836 | mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname, value); |
michael@0 | 1837 | AFTER_GL_CALL; |
michael@0 | 1838 | } |
michael@0 | 1839 | |
michael@0 | 1840 | void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) { |
michael@0 | 1841 | BEFORE_GL_CALL; |
michael@0 | 1842 | mSymbols.fGetRenderbufferParameteriv(target, pname, value); |
michael@0 | 1843 | AFTER_GL_CALL; |
michael@0 | 1844 | } |
michael@0 | 1845 | |
michael@0 | 1846 | realGLboolean fIsFramebuffer (GLuint framebuffer) { |
michael@0 | 1847 | BEFORE_GL_CALL; |
michael@0 | 1848 | realGLboolean retval = mSymbols.fIsFramebuffer(framebuffer); |
michael@0 | 1849 | AFTER_GL_CALL; |
michael@0 | 1850 | return retval; |
michael@0 | 1851 | } |
michael@0 | 1852 | |
michael@0 | 1853 | public: |
michael@0 | 1854 | realGLboolean fIsRenderbuffer (GLuint renderbuffer) { |
michael@0 | 1855 | BEFORE_GL_CALL; |
michael@0 | 1856 | realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer); |
michael@0 | 1857 | AFTER_GL_CALL; |
michael@0 | 1858 | return retval; |
michael@0 | 1859 | } |
michael@0 | 1860 | |
michael@0 | 1861 | void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { |
michael@0 | 1862 | BEFORE_GL_CALL; |
michael@0 | 1863 | mSymbols.fRenderbufferStorage(target, internalFormat, width, height); |
michael@0 | 1864 | AFTER_GL_CALL; |
michael@0 | 1865 | } |
michael@0 | 1866 | |
michael@0 | 1867 | private: |
michael@0 | 1868 | void raw_fDepthRange(GLclampf a, GLclampf b) { |
michael@0 | 1869 | MOZ_ASSERT(!IsGLES()); |
michael@0 | 1870 | |
michael@0 | 1871 | BEFORE_GL_CALL; |
michael@0 | 1872 | ASSERT_SYMBOL_PRESENT(fDepthRange); |
michael@0 | 1873 | mSymbols.fDepthRange(a, b); |
michael@0 | 1874 | AFTER_GL_CALL; |
michael@0 | 1875 | } |
michael@0 | 1876 | |
michael@0 | 1877 | void raw_fDepthRangef(GLclampf a, GLclampf b) { |
michael@0 | 1878 | MOZ_ASSERT(IsGLES()); |
michael@0 | 1879 | |
michael@0 | 1880 | BEFORE_GL_CALL; |
michael@0 | 1881 | ASSERT_SYMBOL_PRESENT(fDepthRangef); |
michael@0 | 1882 | mSymbols.fDepthRangef(a, b); |
michael@0 | 1883 | AFTER_GL_CALL; |
michael@0 | 1884 | } |
michael@0 | 1885 | |
michael@0 | 1886 | void raw_fClearDepth(GLclampf v) { |
michael@0 | 1887 | MOZ_ASSERT(!IsGLES()); |
michael@0 | 1888 | |
michael@0 | 1889 | BEFORE_GL_CALL; |
michael@0 | 1890 | ASSERT_SYMBOL_PRESENT(fClearDepth); |
michael@0 | 1891 | mSymbols.fClearDepth(v); |
michael@0 | 1892 | AFTER_GL_CALL; |
michael@0 | 1893 | } |
michael@0 | 1894 | |
michael@0 | 1895 | void raw_fClearDepthf(GLclampf v) { |
michael@0 | 1896 | MOZ_ASSERT(IsGLES()); |
michael@0 | 1897 | |
michael@0 | 1898 | BEFORE_GL_CALL; |
michael@0 | 1899 | ASSERT_SYMBOL_PRESENT(fClearDepthf); |
michael@0 | 1900 | mSymbols.fClearDepthf(v); |
michael@0 | 1901 | AFTER_GL_CALL; |
michael@0 | 1902 | } |
michael@0 | 1903 | |
michael@0 | 1904 | public: |
michael@0 | 1905 | void fDepthRange(GLclampf a, GLclampf b) { |
michael@0 | 1906 | if (IsGLES()) { |
michael@0 | 1907 | raw_fDepthRangef(a, b); |
michael@0 | 1908 | } else { |
michael@0 | 1909 | raw_fDepthRange(a, b); |
michael@0 | 1910 | } |
michael@0 | 1911 | } |
michael@0 | 1912 | |
michael@0 | 1913 | void fClearDepth(GLclampf v) { |
michael@0 | 1914 | if (IsGLES()) { |
michael@0 | 1915 | raw_fClearDepthf(v); |
michael@0 | 1916 | } else { |
michael@0 | 1917 | raw_fClearDepth(v); |
michael@0 | 1918 | } |
michael@0 | 1919 | } |
michael@0 | 1920 | |
michael@0 | 1921 | void* fMapBuffer(GLenum target, GLenum access) { |
michael@0 | 1922 | BEFORE_GL_CALL; |
michael@0 | 1923 | ASSERT_SYMBOL_PRESENT(fMapBuffer); |
michael@0 | 1924 | void *ret = mSymbols.fMapBuffer(target, access); |
michael@0 | 1925 | AFTER_GL_CALL; |
michael@0 | 1926 | return ret; |
michael@0 | 1927 | } |
michael@0 | 1928 | |
michael@0 | 1929 | realGLboolean fUnmapBuffer(GLenum target) { |
michael@0 | 1930 | BEFORE_GL_CALL; |
michael@0 | 1931 | ASSERT_SYMBOL_PRESENT(fUnmapBuffer); |
michael@0 | 1932 | realGLboolean ret = mSymbols.fUnmapBuffer(target); |
michael@0 | 1933 | AFTER_GL_CALL; |
michael@0 | 1934 | return ret; |
michael@0 | 1935 | } |
michael@0 | 1936 | |
michael@0 | 1937 | |
michael@0 | 1938 | private: |
michael@0 | 1939 | GLuint raw_fCreateProgram() { |
michael@0 | 1940 | BEFORE_GL_CALL; |
michael@0 | 1941 | GLuint ret = mSymbols.fCreateProgram(); |
michael@0 | 1942 | AFTER_GL_CALL; |
michael@0 | 1943 | return ret; |
michael@0 | 1944 | } |
michael@0 | 1945 | |
michael@0 | 1946 | GLuint raw_fCreateShader(GLenum t) { |
michael@0 | 1947 | BEFORE_GL_CALL; |
michael@0 | 1948 | GLuint ret = mSymbols.fCreateShader(t); |
michael@0 | 1949 | AFTER_GL_CALL; |
michael@0 | 1950 | return ret; |
michael@0 | 1951 | } |
michael@0 | 1952 | |
michael@0 | 1953 | void raw_fGenBuffers(GLsizei n, GLuint* names) { |
michael@0 | 1954 | BEFORE_GL_CALL; |
michael@0 | 1955 | mSymbols.fGenBuffers(n, names); |
michael@0 | 1956 | AFTER_GL_CALL; |
michael@0 | 1957 | } |
michael@0 | 1958 | |
michael@0 | 1959 | void raw_fGenFramebuffers(GLsizei n, GLuint* names) { |
michael@0 | 1960 | BEFORE_GL_CALL; |
michael@0 | 1961 | mSymbols.fGenFramebuffers(n, names); |
michael@0 | 1962 | AFTER_GL_CALL; |
michael@0 | 1963 | } |
michael@0 | 1964 | |
michael@0 | 1965 | void raw_fGenRenderbuffers(GLsizei n, GLuint* names) { |
michael@0 | 1966 | BEFORE_GL_CALL; |
michael@0 | 1967 | mSymbols.fGenRenderbuffers(n, names); |
michael@0 | 1968 | AFTER_GL_CALL; |
michael@0 | 1969 | } |
michael@0 | 1970 | |
michael@0 | 1971 | void raw_fGenTextures(GLsizei n, GLuint* names) { |
michael@0 | 1972 | BEFORE_GL_CALL; |
michael@0 | 1973 | mSymbols.fGenTextures(n, names); |
michael@0 | 1974 | AFTER_GL_CALL; |
michael@0 | 1975 | } |
michael@0 | 1976 | |
michael@0 | 1977 | public: |
michael@0 | 1978 | GLuint fCreateProgram() { |
michael@0 | 1979 | GLuint ret = raw_fCreateProgram(); |
michael@0 | 1980 | TRACKING_CONTEXT(CreatedProgram(this, ret)); |
michael@0 | 1981 | return ret; |
michael@0 | 1982 | } |
michael@0 | 1983 | |
michael@0 | 1984 | GLuint fCreateShader(GLenum t) { |
michael@0 | 1985 | GLuint ret = raw_fCreateShader(t); |
michael@0 | 1986 | TRACKING_CONTEXT(CreatedShader(this, ret)); |
michael@0 | 1987 | return ret; |
michael@0 | 1988 | } |
michael@0 | 1989 | |
michael@0 | 1990 | void fGenBuffers(GLsizei n, GLuint* names) { |
michael@0 | 1991 | raw_fGenBuffers(n, names); |
michael@0 | 1992 | TRACKING_CONTEXT(CreatedBuffers(this, n, names)); |
michael@0 | 1993 | } |
michael@0 | 1994 | |
michael@0 | 1995 | void fGenFramebuffers(GLsizei n, GLuint* names) { |
michael@0 | 1996 | raw_fGenFramebuffers(n, names); |
michael@0 | 1997 | TRACKING_CONTEXT(CreatedFramebuffers(this, n, names)); |
michael@0 | 1998 | } |
michael@0 | 1999 | |
michael@0 | 2000 | void fGenRenderbuffers(GLsizei n, GLuint* names) { |
michael@0 | 2001 | raw_fGenRenderbuffers(n, names); |
michael@0 | 2002 | TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names)); |
michael@0 | 2003 | } |
michael@0 | 2004 | |
michael@0 | 2005 | void fGenTextures(GLsizei n, GLuint* names) { |
michael@0 | 2006 | raw_fGenTextures(n, names); |
michael@0 | 2007 | TRACKING_CONTEXT(CreatedTextures(this, n, names)); |
michael@0 | 2008 | } |
michael@0 | 2009 | |
michael@0 | 2010 | private: |
michael@0 | 2011 | void raw_fDeleteProgram(GLuint program) { |
michael@0 | 2012 | BEFORE_GL_CALL; |
michael@0 | 2013 | mSymbols.fDeleteProgram(program); |
michael@0 | 2014 | AFTER_GL_CALL; |
michael@0 | 2015 | } |
michael@0 | 2016 | |
michael@0 | 2017 | void raw_fDeleteShader(GLuint shader) { |
michael@0 | 2018 | BEFORE_GL_CALL; |
michael@0 | 2019 | mSymbols.fDeleteShader(shader); |
michael@0 | 2020 | AFTER_GL_CALL; |
michael@0 | 2021 | } |
michael@0 | 2022 | |
michael@0 | 2023 | void raw_fDeleteBuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2024 | BEFORE_GL_CALL; |
michael@0 | 2025 | mSymbols.fDeleteBuffers(n, names); |
michael@0 | 2026 | AFTER_GL_CALL; |
michael@0 | 2027 | } |
michael@0 | 2028 | |
michael@0 | 2029 | void raw_fDeleteFramebuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2030 | BEFORE_GL_CALL; |
michael@0 | 2031 | mSymbols.fDeleteFramebuffers(n, names); |
michael@0 | 2032 | AFTER_GL_CALL; |
michael@0 | 2033 | } |
michael@0 | 2034 | |
michael@0 | 2035 | void raw_fDeleteRenderbuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2036 | BEFORE_GL_CALL; |
michael@0 | 2037 | mSymbols.fDeleteRenderbuffers(n, names); |
michael@0 | 2038 | AFTER_GL_CALL; |
michael@0 | 2039 | } |
michael@0 | 2040 | |
michael@0 | 2041 | void raw_fDeleteTextures(GLsizei n, const GLuint* names) { |
michael@0 | 2042 | BEFORE_GL_CALL; |
michael@0 | 2043 | mSymbols.fDeleteTextures(n, names); |
michael@0 | 2044 | AFTER_GL_CALL; |
michael@0 | 2045 | } |
michael@0 | 2046 | |
michael@0 | 2047 | public: |
michael@0 | 2048 | |
michael@0 | 2049 | void fDeleteProgram(GLuint program) { |
michael@0 | 2050 | raw_fDeleteProgram(program); |
michael@0 | 2051 | TRACKING_CONTEXT(DeletedProgram(this, program)); |
michael@0 | 2052 | } |
michael@0 | 2053 | |
michael@0 | 2054 | void fDeleteShader(GLuint shader) { |
michael@0 | 2055 | raw_fDeleteShader(shader); |
michael@0 | 2056 | TRACKING_CONTEXT(DeletedShader(this, shader)); |
michael@0 | 2057 | } |
michael@0 | 2058 | |
michael@0 | 2059 | void fDeleteBuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2060 | raw_fDeleteBuffers(n, names); |
michael@0 | 2061 | TRACKING_CONTEXT(DeletedBuffers(this, n, names)); |
michael@0 | 2062 | } |
michael@0 | 2063 | |
michael@0 | 2064 | void fDeleteFramebuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2065 | if (mScreen) { |
michael@0 | 2066 | // Notify mScreen which framebuffers we're deleting. |
michael@0 | 2067 | // Otherwise, we will get framebuffer binding mispredictions. |
michael@0 | 2068 | for (int i = 0; i < n; i++) { |
michael@0 | 2069 | mScreen->DeletingFB(names[i]); |
michael@0 | 2070 | } |
michael@0 | 2071 | } |
michael@0 | 2072 | |
michael@0 | 2073 | if (n == 1 && *names == 0) { |
michael@0 | 2074 | // Deleting framebuffer 0 causes hangs on the DROID. See bug 623228. |
michael@0 | 2075 | } else { |
michael@0 | 2076 | raw_fDeleteFramebuffers(n, names); |
michael@0 | 2077 | } |
michael@0 | 2078 | TRACKING_CONTEXT(DeletedFramebuffers(this, n, names)); |
michael@0 | 2079 | } |
michael@0 | 2080 | |
michael@0 | 2081 | void fDeleteRenderbuffers(GLsizei n, const GLuint* names) { |
michael@0 | 2082 | raw_fDeleteRenderbuffers(n, names); |
michael@0 | 2083 | TRACKING_CONTEXT(DeletedRenderbuffers(this, n, names)); |
michael@0 | 2084 | } |
michael@0 | 2085 | |
michael@0 | 2086 | void fDeleteTextures(GLsizei n, const GLuint* names) { |
michael@0 | 2087 | raw_fDeleteTextures(n, names); |
michael@0 | 2088 | TRACKING_CONTEXT(DeletedTextures(this, n, names)); |
michael@0 | 2089 | } |
michael@0 | 2090 | |
michael@0 | 2091 | GLenum fGetGraphicsResetStatus() { |
michael@0 | 2092 | MOZ_ASSERT(mHasRobustness); |
michael@0 | 2093 | |
michael@0 | 2094 | BEFORE_GL_CALL; |
michael@0 | 2095 | ASSERT_SYMBOL_PRESENT(fGetGraphicsResetStatus); |
michael@0 | 2096 | GLenum ret = mSymbols.fGetGraphicsResetStatus(); |
michael@0 | 2097 | AFTER_GL_CALL; |
michael@0 | 2098 | return ret; |
michael@0 | 2099 | } |
michael@0 | 2100 | |
michael@0 | 2101 | |
michael@0 | 2102 | // ----------------------------------------------------------------------------- |
michael@0 | 2103 | // Extension ARB_sync (GL) |
michael@0 | 2104 | public: |
michael@0 | 2105 | GLsync fFenceSync(GLenum condition, GLbitfield flags) { |
michael@0 | 2106 | BEFORE_GL_CALL; |
michael@0 | 2107 | ASSERT_SYMBOL_PRESENT(fFenceSync); |
michael@0 | 2108 | GLsync ret = mSymbols.fFenceSync(condition, flags); |
michael@0 | 2109 | AFTER_GL_CALL; |
michael@0 | 2110 | return ret; |
michael@0 | 2111 | } |
michael@0 | 2112 | |
michael@0 | 2113 | realGLboolean fIsSync(GLsync sync) { |
michael@0 | 2114 | BEFORE_GL_CALL; |
michael@0 | 2115 | ASSERT_SYMBOL_PRESENT(fIsSync); |
michael@0 | 2116 | realGLboolean ret = mSymbols.fIsSync(sync); |
michael@0 | 2117 | AFTER_GL_CALL; |
michael@0 | 2118 | return ret; |
michael@0 | 2119 | } |
michael@0 | 2120 | |
michael@0 | 2121 | void fDeleteSync(GLsync sync) { |
michael@0 | 2122 | BEFORE_GL_CALL; |
michael@0 | 2123 | ASSERT_SYMBOL_PRESENT(fDeleteSync); |
michael@0 | 2124 | mSymbols.fDeleteSync(sync); |
michael@0 | 2125 | AFTER_GL_CALL; |
michael@0 | 2126 | } |
michael@0 | 2127 | |
michael@0 | 2128 | GLenum fClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { |
michael@0 | 2129 | BEFORE_GL_CALL; |
michael@0 | 2130 | ASSERT_SYMBOL_PRESENT(fClientWaitSync); |
michael@0 | 2131 | GLenum ret = mSymbols.fClientWaitSync(sync, flags, timeout); |
michael@0 | 2132 | AFTER_GL_CALL; |
michael@0 | 2133 | return ret; |
michael@0 | 2134 | } |
michael@0 | 2135 | |
michael@0 | 2136 | void fWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { |
michael@0 | 2137 | BEFORE_GL_CALL; |
michael@0 | 2138 | ASSERT_SYMBOL_PRESENT(fWaitSync); |
michael@0 | 2139 | mSymbols.fWaitSync(sync, flags, timeout); |
michael@0 | 2140 | AFTER_GL_CALL; |
michael@0 | 2141 | } |
michael@0 | 2142 | |
michael@0 | 2143 | void fGetInteger64v(GLenum pname, GLint64 *params) { |
michael@0 | 2144 | BEFORE_GL_CALL; |
michael@0 | 2145 | ASSERT_SYMBOL_PRESENT(fGetInteger64v); |
michael@0 | 2146 | mSymbols.fGetInteger64v(pname, params); |
michael@0 | 2147 | AFTER_GL_CALL; |
michael@0 | 2148 | } |
michael@0 | 2149 | |
michael@0 | 2150 | void fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) { |
michael@0 | 2151 | BEFORE_GL_CALL; |
michael@0 | 2152 | ASSERT_SYMBOL_PRESENT(fGetSynciv); |
michael@0 | 2153 | mSymbols.fGetSynciv(sync, pname, bufSize, length, values); |
michael@0 | 2154 | AFTER_GL_CALL; |
michael@0 | 2155 | } |
michael@0 | 2156 | |
michael@0 | 2157 | |
michael@0 | 2158 | // ----------------------------------------------------------------------------- |
michael@0 | 2159 | // Extension OES_EGL_image (GLES) |
michael@0 | 2160 | public: |
michael@0 | 2161 | void fEGLImageTargetTexture2D(GLenum target, GLeglImage image) { |
michael@0 | 2162 | BEFORE_GL_CALL; |
michael@0 | 2163 | ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D); |
michael@0 | 2164 | mSymbols.fEGLImageTargetTexture2D(target, image); |
michael@0 | 2165 | AFTER_GL_CALL; |
michael@0 | 2166 | } |
michael@0 | 2167 | |
michael@0 | 2168 | void fEGLImageTargetRenderbufferStorage(GLenum target, GLeglImage image) |
michael@0 | 2169 | { |
michael@0 | 2170 | BEFORE_GL_CALL; |
michael@0 | 2171 | ASSERT_SYMBOL_PRESENT(fEGLImageTargetRenderbufferStorage); |
michael@0 | 2172 | mSymbols.fEGLImageTargetRenderbufferStorage(target, image); |
michael@0 | 2173 | AFTER_GL_CALL; |
michael@0 | 2174 | } |
michael@0 | 2175 | |
michael@0 | 2176 | |
michael@0 | 2177 | // ----------------------------------------------------------------------------- |
michael@0 | 2178 | // Package XXX_bind_buffer_offset |
michael@0 | 2179 | public: |
michael@0 | 2180 | void fBindBufferOffset(GLenum target, GLuint index, GLuint buffer, GLintptr offset) |
michael@0 | 2181 | { |
michael@0 | 2182 | BEFORE_GL_CALL; |
michael@0 | 2183 | ASSERT_SYMBOL_PRESENT(fBindBufferOffset); |
michael@0 | 2184 | mSymbols.fBindBufferOffset(target, index, buffer, offset); |
michael@0 | 2185 | AFTER_GL_CALL; |
michael@0 | 2186 | } |
michael@0 | 2187 | |
michael@0 | 2188 | |
michael@0 | 2189 | // ----------------------------------------------------------------------------- |
michael@0 | 2190 | // Package XXX_draw_buffers |
michael@0 | 2191 | public: |
michael@0 | 2192 | void fDrawBuffers(GLsizei n, const GLenum* bufs) { |
michael@0 | 2193 | BEFORE_GL_CALL; |
michael@0 | 2194 | mSymbols.fDrawBuffers(n, bufs); |
michael@0 | 2195 | AFTER_GL_CALL; |
michael@0 | 2196 | } |
michael@0 | 2197 | |
michael@0 | 2198 | |
michael@0 | 2199 | // ----------------------------------------------------------------------------- |
michael@0 | 2200 | // Package XXX_draw_instanced |
michael@0 | 2201 | public: |
michael@0 | 2202 | void fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
michael@0 | 2203 | { |
michael@0 | 2204 | BeforeGLDrawCall(); |
michael@0 | 2205 | raw_fDrawArraysInstanced(mode, first, count, primcount); |
michael@0 | 2206 | AfterGLDrawCall(); |
michael@0 | 2207 | } |
michael@0 | 2208 | |
michael@0 | 2209 | void fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei primcount) |
michael@0 | 2210 | { |
michael@0 | 2211 | BeforeGLDrawCall(); |
michael@0 | 2212 | raw_fDrawElementsInstanced(mode, count, type, indices, primcount); |
michael@0 | 2213 | AfterGLDrawCall(); |
michael@0 | 2214 | } |
michael@0 | 2215 | |
michael@0 | 2216 | private: |
michael@0 | 2217 | void raw_fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
michael@0 | 2218 | { |
michael@0 | 2219 | BEFORE_GL_CALL; |
michael@0 | 2220 | ASSERT_SYMBOL_PRESENT(fDrawArraysInstanced); |
michael@0 | 2221 | mSymbols.fDrawArraysInstanced(mode, first, count, primcount); |
michael@0 | 2222 | AFTER_GL_CALL; |
michael@0 | 2223 | } |
michael@0 | 2224 | |
michael@0 | 2225 | void raw_fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei primcount) |
michael@0 | 2226 | { |
michael@0 | 2227 | BEFORE_GL_CALL; |
michael@0 | 2228 | ASSERT_SYMBOL_PRESENT(fDrawElementsInstanced); |
michael@0 | 2229 | mSymbols.fDrawElementsInstanced(mode, count, type, indices, primcount); |
michael@0 | 2230 | AFTER_GL_CALL; |
michael@0 | 2231 | } |
michael@0 | 2232 | |
michael@0 | 2233 | // ----------------------------------------------------------------------------- |
michael@0 | 2234 | // Feature draw_range_elements |
michael@0 | 2235 | public: |
michael@0 | 2236 | void fDrawRangeElements(GLenum mode, GLuint start, GLuint end, |
michael@0 | 2237 | GLsizei count, GLenum type, const GLvoid* indices) |
michael@0 | 2238 | { |
michael@0 | 2239 | BeforeGLDrawCall(); |
michael@0 | 2240 | raw_fDrawRangeElements(mode, start, end, count, type, indices); |
michael@0 | 2241 | AfterGLDrawCall(); |
michael@0 | 2242 | } |
michael@0 | 2243 | |
michael@0 | 2244 | private: |
michael@0 | 2245 | void raw_fDrawRangeElements(GLenum mode, GLuint start, GLuint end, |
michael@0 | 2246 | GLsizei count, GLenum type, const GLvoid* indices) |
michael@0 | 2247 | { |
michael@0 | 2248 | BEFORE_GL_CALL; |
michael@0 | 2249 | ASSERT_SYMBOL_PRESENT(fDrawRangeElements); |
michael@0 | 2250 | mSymbols.fDrawRangeElements(mode, start, end, count, type, indices); |
michael@0 | 2251 | AFTER_GL_CALL; |
michael@0 | 2252 | } |
michael@0 | 2253 | |
michael@0 | 2254 | // ----------------------------------------------------------------------------- |
michael@0 | 2255 | // Package XXX_framebuffer_blit |
michael@0 | 2256 | public: |
michael@0 | 2257 | // Draw/Read |
michael@0 | 2258 | void fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { |
michael@0 | 2259 | BeforeGLDrawCall(); |
michael@0 | 2260 | BeforeGLReadCall(); |
michael@0 | 2261 | raw_fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
michael@0 | 2262 | AfterGLReadCall(); |
michael@0 | 2263 | AfterGLDrawCall(); |
michael@0 | 2264 | } |
michael@0 | 2265 | |
michael@0 | 2266 | |
michael@0 | 2267 | private: |
michael@0 | 2268 | void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { |
michael@0 | 2269 | BEFORE_GL_CALL; |
michael@0 | 2270 | ASSERT_SYMBOL_PRESENT(fBlitFramebuffer); |
michael@0 | 2271 | mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
michael@0 | 2272 | AFTER_GL_CALL; |
michael@0 | 2273 | } |
michael@0 | 2274 | |
michael@0 | 2275 | |
michael@0 | 2276 | // ----------------------------------------------------------------------------- |
michael@0 | 2277 | // Package XXX_framebuffer_multisample |
michael@0 | 2278 | public: |
michael@0 | 2279 | void fRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) { |
michael@0 | 2280 | BEFORE_GL_CALL; |
michael@0 | 2281 | ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample); |
michael@0 | 2282 | mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat, width, height); |
michael@0 | 2283 | AFTER_GL_CALL; |
michael@0 | 2284 | } |
michael@0 | 2285 | |
michael@0 | 2286 | |
michael@0 | 2287 | // ----------------------------------------------------------------------------- |
michael@0 | 2288 | // Package XXX_instanced_arrays |
michael@0 | 2289 | public: |
michael@0 | 2290 | void fVertexAttribDivisor(GLuint index, GLuint divisor) |
michael@0 | 2291 | { |
michael@0 | 2292 | BEFORE_GL_CALL; |
michael@0 | 2293 | ASSERT_SYMBOL_PRESENT(fVertexAttribDivisor); |
michael@0 | 2294 | mSymbols.fVertexAttribDivisor(index, divisor); |
michael@0 | 2295 | AFTER_GL_CALL; |
michael@0 | 2296 | } |
michael@0 | 2297 | |
michael@0 | 2298 | |
michael@0 | 2299 | // ----------------------------------------------------------------------------- |
michael@0 | 2300 | // Package XXX_query_objects |
michael@0 | 2301 | /** |
michael@0 | 2302 | * XXX_query_objects: |
michael@0 | 2303 | * - provide all followed entry points |
michael@0 | 2304 | * |
michael@0 | 2305 | * XXX_occlusion_query2: |
michael@0 | 2306 | * - depends on XXX_query_objects |
michael@0 | 2307 | * - provide ANY_SAMPLES_PASSED |
michael@0 | 2308 | * |
michael@0 | 2309 | * XXX_occlusion_query_boolean: |
michael@0 | 2310 | * - depends on XXX_occlusion_query2 |
michael@0 | 2311 | * - provide ANY_SAMPLES_PASSED_CONSERVATIVE |
michael@0 | 2312 | */ |
michael@0 | 2313 | public: |
michael@0 | 2314 | void fDeleteQueries(GLsizei n, const GLuint* names) { |
michael@0 | 2315 | BEFORE_GL_CALL; |
michael@0 | 2316 | ASSERT_SYMBOL_PRESENT(fDeleteQueries); |
michael@0 | 2317 | mSymbols.fDeleteQueries(n, names); |
michael@0 | 2318 | AFTER_GL_CALL; |
michael@0 | 2319 | TRACKING_CONTEXT(DeletedQueries(this, n, names)); |
michael@0 | 2320 | } |
michael@0 | 2321 | |
michael@0 | 2322 | void fGenQueries(GLsizei n, GLuint* names) { |
michael@0 | 2323 | BEFORE_GL_CALL; |
michael@0 | 2324 | ASSERT_SYMBOL_PRESENT(fGenQueries); |
michael@0 | 2325 | mSymbols.fGenQueries(n, names); |
michael@0 | 2326 | AFTER_GL_CALL; |
michael@0 | 2327 | TRACKING_CONTEXT(CreatedQueries(this, n, names)); |
michael@0 | 2328 | } |
michael@0 | 2329 | |
michael@0 | 2330 | void fGetQueryiv(GLenum target, GLenum pname, GLint* params) { |
michael@0 | 2331 | BEFORE_GL_CALL; |
michael@0 | 2332 | ASSERT_SYMBOL_PRESENT(fGetQueryiv); |
michael@0 | 2333 | mSymbols.fGetQueryiv(target, pname, params); |
michael@0 | 2334 | AFTER_GL_CALL; |
michael@0 | 2335 | } |
michael@0 | 2336 | |
michael@0 | 2337 | void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) { |
michael@0 | 2338 | BEFORE_GL_CALL; |
michael@0 | 2339 | ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv); |
michael@0 | 2340 | mSymbols.fGetQueryObjectuiv(id, pname, params); |
michael@0 | 2341 | AFTER_GL_CALL; |
michael@0 | 2342 | } |
michael@0 | 2343 | |
michael@0 | 2344 | realGLboolean fIsQuery(GLuint query) { |
michael@0 | 2345 | BEFORE_GL_CALL; |
michael@0 | 2346 | ASSERT_SYMBOL_PRESENT(fIsQuery); |
michael@0 | 2347 | realGLboolean retval = mSymbols.fIsQuery(query); |
michael@0 | 2348 | AFTER_GL_CALL; |
michael@0 | 2349 | return retval; |
michael@0 | 2350 | } |
michael@0 | 2351 | |
michael@0 | 2352 | |
michael@0 | 2353 | // ----------------------------------------------------------------------------- |
michael@0 | 2354 | // Package XXX_get_query_object_iv |
michael@0 | 2355 | /** |
michael@0 | 2356 | * XXX_get_query_object_iv: |
michael@0 | 2357 | * - depends on XXX_query_objects |
michael@0 | 2358 | * - provide the followed entry point |
michael@0 | 2359 | * |
michael@0 | 2360 | * XXX_occlusion_query: |
michael@0 | 2361 | * - depends on XXX_get_query_object_iv |
michael@0 | 2362 | * - provide LOCAL_GL_SAMPLES_PASSED |
michael@0 | 2363 | */ |
michael@0 | 2364 | public: |
michael@0 | 2365 | void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) { |
michael@0 | 2366 | BEFORE_GL_CALL; |
michael@0 | 2367 | ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv); |
michael@0 | 2368 | mSymbols.fGetQueryObjectiv(id, pname, params); |
michael@0 | 2369 | AFTER_GL_CALL; |
michael@0 | 2370 | } |
michael@0 | 2371 | |
michael@0 | 2372 | |
michael@0 | 2373 | // ----------------------------------------------------------------------------- |
michael@0 | 2374 | // Package XXX_transform_feedback |
michael@0 | 2375 | public: |
michael@0 | 2376 | void fBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
michael@0 | 2377 | { |
michael@0 | 2378 | BEFORE_GL_CALL; |
michael@0 | 2379 | ASSERT_SYMBOL_PRESENT(fBindBufferBase); |
michael@0 | 2380 | mSymbols.fBindBufferBase(target, index, buffer); |
michael@0 | 2381 | AFTER_GL_CALL; |
michael@0 | 2382 | } |
michael@0 | 2383 | |
michael@0 | 2384 | void fBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
michael@0 | 2385 | { |
michael@0 | 2386 | BEFORE_GL_CALL; |
michael@0 | 2387 | ASSERT_SYMBOL_PRESENT(fBindBufferRange); |
michael@0 | 2388 | mSymbols.fBindBufferRange(target, index, buffer, offset, size); |
michael@0 | 2389 | AFTER_GL_CALL; |
michael@0 | 2390 | } |
michael@0 | 2391 | |
michael@0 | 2392 | void fBeginTransformFeedback(GLenum primitiveMode) |
michael@0 | 2393 | { |
michael@0 | 2394 | BEFORE_GL_CALL; |
michael@0 | 2395 | ASSERT_SYMBOL_PRESENT(fBeginTransformFeedback); |
michael@0 | 2396 | mSymbols.fBeginTransformFeedback(primitiveMode); |
michael@0 | 2397 | AFTER_GL_CALL; |
michael@0 | 2398 | } |
michael@0 | 2399 | |
michael@0 | 2400 | void fEndTransformFeedback() |
michael@0 | 2401 | { |
michael@0 | 2402 | BEFORE_GL_CALL; |
michael@0 | 2403 | ASSERT_SYMBOL_PRESENT(fEndTransformFeedback); |
michael@0 | 2404 | mSymbols.fEndTransformFeedback(); |
michael@0 | 2405 | AFTER_GL_CALL; |
michael@0 | 2406 | } |
michael@0 | 2407 | |
michael@0 | 2408 | void fTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
michael@0 | 2409 | { |
michael@0 | 2410 | BEFORE_GL_CALL; |
michael@0 | 2411 | ASSERT_SYMBOL_PRESENT(fTransformFeedbackVaryings); |
michael@0 | 2412 | mSymbols.fTransformFeedbackVaryings(program, count, varyings, bufferMode); |
michael@0 | 2413 | AFTER_GL_CALL; |
michael@0 | 2414 | } |
michael@0 | 2415 | |
michael@0 | 2416 | void fGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
michael@0 | 2417 | { |
michael@0 | 2418 | BEFORE_GL_CALL; |
michael@0 | 2419 | ASSERT_SYMBOL_PRESENT(fGetTransformFeedbackVarying); |
michael@0 | 2420 | mSymbols.fGetTransformFeedbackVarying(program, index, bufSize, length, size, type, name); |
michael@0 | 2421 | AFTER_GL_CALL; |
michael@0 | 2422 | } |
michael@0 | 2423 | |
michael@0 | 2424 | void fGetIntegeri_v(GLenum param, GLuint index, GLint* values) |
michael@0 | 2425 | { |
michael@0 | 2426 | BEFORE_GL_CALL; |
michael@0 | 2427 | ASSERT_SYMBOL_PRESENT(fGetIntegeri_v); |
michael@0 | 2428 | mSymbols.fGetIntegeri_v(param, index, values); |
michael@0 | 2429 | AFTER_GL_CALL; |
michael@0 | 2430 | } |
michael@0 | 2431 | |
michael@0 | 2432 | |
michael@0 | 2433 | // ----------------------------------------------------------------------------- |
michael@0 | 2434 | // Package XXX_vertex_array_object |
michael@0 | 2435 | public: |
michael@0 | 2436 | void fBindVertexArray(GLuint array) |
michael@0 | 2437 | { |
michael@0 | 2438 | BEFORE_GL_CALL; |
michael@0 | 2439 | ASSERT_SYMBOL_PRESENT(fBindVertexArray); |
michael@0 | 2440 | mSymbols.fBindVertexArray(array); |
michael@0 | 2441 | AFTER_GL_CALL; |
michael@0 | 2442 | } |
michael@0 | 2443 | |
michael@0 | 2444 | void fDeleteVertexArrays(GLsizei n, const GLuint *arrays) |
michael@0 | 2445 | { |
michael@0 | 2446 | BEFORE_GL_CALL; |
michael@0 | 2447 | ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays); |
michael@0 | 2448 | mSymbols.fDeleteVertexArrays(n, arrays); |
michael@0 | 2449 | AFTER_GL_CALL; |
michael@0 | 2450 | } |
michael@0 | 2451 | |
michael@0 | 2452 | void fGenVertexArrays(GLsizei n, GLuint *arrays) |
michael@0 | 2453 | { |
michael@0 | 2454 | BEFORE_GL_CALL; |
michael@0 | 2455 | ASSERT_SYMBOL_PRESENT(fGenVertexArrays); |
michael@0 | 2456 | mSymbols.fGenVertexArrays(n, arrays); |
michael@0 | 2457 | AFTER_GL_CALL; |
michael@0 | 2458 | } |
michael@0 | 2459 | |
michael@0 | 2460 | realGLboolean fIsVertexArray(GLuint array) |
michael@0 | 2461 | { |
michael@0 | 2462 | BEFORE_GL_CALL; |
michael@0 | 2463 | ASSERT_SYMBOL_PRESENT(fIsVertexArray); |
michael@0 | 2464 | realGLboolean ret = mSymbols.fIsVertexArray(array); |
michael@0 | 2465 | AFTER_GL_CALL; |
michael@0 | 2466 | return ret; |
michael@0 | 2467 | } |
michael@0 | 2468 | |
michael@0 | 2469 | |
michael@0 | 2470 | // ----------------------------------------------------------------------------- |
michael@0 | 2471 | // Constructor |
michael@0 | 2472 | public: |
michael@0 | 2473 | |
michael@0 | 2474 | typedef struct gfx::SurfaceCaps SurfaceCaps; |
michael@0 | 2475 | |
michael@0 | 2476 | |
michael@0 | 2477 | protected: |
michael@0 | 2478 | GLContext(const SurfaceCaps& caps, |
michael@0 | 2479 | GLContext* sharedContext = nullptr, |
michael@0 | 2480 | bool isOffscreen = false); |
michael@0 | 2481 | |
michael@0 | 2482 | |
michael@0 | 2483 | // ----------------------------------------------------------------------------- |
michael@0 | 2484 | // Destructor |
michael@0 | 2485 | public: |
michael@0 | 2486 | virtual ~GLContext(); |
michael@0 | 2487 | |
michael@0 | 2488 | |
michael@0 | 2489 | // ----------------------------------------------------------------------------- |
michael@0 | 2490 | // Everything that isn't standard GL APIs |
michael@0 | 2491 | protected: |
michael@0 | 2492 | typedef class gfx::SharedSurface SharedSurface; |
michael@0 | 2493 | typedef gfx::SharedSurfaceType SharedSurfaceType; |
michael@0 | 2494 | typedef gfx::SurfaceFormat SurfaceFormat; |
michael@0 | 2495 | |
michael@0 | 2496 | virtual bool MakeCurrentImpl(bool aForce) = 0; |
michael@0 | 2497 | |
michael@0 | 2498 | public: |
michael@0 | 2499 | #ifdef MOZ_ENABLE_GL_TRACKING |
michael@0 | 2500 | static void StaticInit() { |
michael@0 | 2501 | PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr); |
michael@0 | 2502 | } |
michael@0 | 2503 | #endif |
michael@0 | 2504 | |
michael@0 | 2505 | bool MakeCurrent(bool aForce = false) { |
michael@0 | 2506 | if (IsDestroyed()) { |
michael@0 | 2507 | return false; |
michael@0 | 2508 | } |
michael@0 | 2509 | #ifdef MOZ_ENABLE_GL_TRACKING |
michael@0 | 2510 | PR_SetThreadPrivate(sCurrentGLContextTLS, this); |
michael@0 | 2511 | |
michael@0 | 2512 | // XXX this assertion is disabled because it's triggering on Mac; |
michael@0 | 2513 | // we need to figure out why and reenable it. |
michael@0 | 2514 | #if 0 |
michael@0 | 2515 | // IsOwningThreadCurrent is a bit of a misnomer; |
michael@0 | 2516 | // the "owning thread" is the creation thread, |
michael@0 | 2517 | // and the only thread that can own this. We don't |
michael@0 | 2518 | // support contexts used on multiple threads. |
michael@0 | 2519 | NS_ASSERTION(IsOwningThreadCurrent(), |
michael@0 | 2520 | "MakeCurrent() called on different thread than this context was created on!"); |
michael@0 | 2521 | #endif |
michael@0 | 2522 | #endif |
michael@0 | 2523 | return MakeCurrentImpl(aForce); |
michael@0 | 2524 | } |
michael@0 | 2525 | |
michael@0 | 2526 | virtual bool Init() = 0; |
michael@0 | 2527 | |
michael@0 | 2528 | virtual bool SetupLookupFunction() = 0; |
michael@0 | 2529 | |
michael@0 | 2530 | virtual void ReleaseSurface() {} |
michael@0 | 2531 | |
michael@0 | 2532 | // Mark this context as destroyed. This will nullptr out all |
michael@0 | 2533 | // the GL function pointers! |
michael@0 | 2534 | void MarkDestroyed(); |
michael@0 | 2535 | |
michael@0 | 2536 | bool IsDestroyed() { |
michael@0 | 2537 | // MarkDestroyed will mark all these as null. |
michael@0 | 2538 | return mSymbols.fUseProgram == nullptr; |
michael@0 | 2539 | } |
michael@0 | 2540 | |
michael@0 | 2541 | GLContext *GetSharedContext() { return mSharedContext; } |
michael@0 | 2542 | |
michael@0 | 2543 | /** |
michael@0 | 2544 | * Returns true if the thread on which this context was created is the currently |
michael@0 | 2545 | * executing thread. |
michael@0 | 2546 | */ |
michael@0 | 2547 | bool IsOwningThreadCurrent(); |
michael@0 | 2548 | void DispatchToOwningThread(nsIRunnable *event); |
michael@0 | 2549 | |
michael@0 | 2550 | static void PlatformStartup(); |
michael@0 | 2551 | |
michael@0 | 2552 | public: |
michael@0 | 2553 | /** |
michael@0 | 2554 | * If this context wraps a double-buffered target, swap the back |
michael@0 | 2555 | * and front buffers. It should be assumed that after a swap, the |
michael@0 | 2556 | * contents of the new back buffer are undefined. |
michael@0 | 2557 | */ |
michael@0 | 2558 | virtual bool SwapBuffers() { return false; } |
michael@0 | 2559 | |
michael@0 | 2560 | /** |
michael@0 | 2561 | * Defines a two-dimensional texture image for context target surface |
michael@0 | 2562 | */ |
michael@0 | 2563 | virtual bool BindTexImage() { return false; } |
michael@0 | 2564 | /* |
michael@0 | 2565 | * Releases a color buffer that is being used as a texture |
michael@0 | 2566 | */ |
michael@0 | 2567 | virtual bool ReleaseTexImage() { return false; } |
michael@0 | 2568 | |
michael@0 | 2569 | // Before reads from offscreen texture |
michael@0 | 2570 | void GuaranteeResolve(); |
michael@0 | 2571 | |
michael@0 | 2572 | /* |
michael@0 | 2573 | * Resize the current offscreen buffer. Returns true on success. |
michael@0 | 2574 | * If it returns false, the context should be treated as unusable |
michael@0 | 2575 | * and should be recreated. After the resize, the viewport is not |
michael@0 | 2576 | * changed; glViewport should be called as appropriate. |
michael@0 | 2577 | * |
michael@0 | 2578 | * Only valid if IsOffscreen() returns true. |
michael@0 | 2579 | */ |
michael@0 | 2580 | bool ResizeOffscreen(const gfx::IntSize& size) { |
michael@0 | 2581 | return ResizeScreenBuffer(size); |
michael@0 | 2582 | } |
michael@0 | 2583 | |
michael@0 | 2584 | /* |
michael@0 | 2585 | * Return size of this offscreen context. |
michael@0 | 2586 | * |
michael@0 | 2587 | * Only valid if IsOffscreen() returns true. |
michael@0 | 2588 | */ |
michael@0 | 2589 | const gfx::IntSize& OffscreenSize() const; |
michael@0 | 2590 | |
michael@0 | 2591 | void BindFB(GLuint fb) { |
michael@0 | 2592 | fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb); |
michael@0 | 2593 | MOZ_ASSERT(!fb || fIsFramebuffer(fb)); |
michael@0 | 2594 | } |
michael@0 | 2595 | |
michael@0 | 2596 | void BindDrawFB(GLuint fb) { |
michael@0 | 2597 | fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, fb); |
michael@0 | 2598 | } |
michael@0 | 2599 | |
michael@0 | 2600 | void BindReadFB(GLuint fb) { |
michael@0 | 2601 | fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, fb); |
michael@0 | 2602 | } |
michael@0 | 2603 | |
michael@0 | 2604 | GLuint GetDrawFB() { |
michael@0 | 2605 | if (mScreen) |
michael@0 | 2606 | return mScreen->GetDrawFB(); |
michael@0 | 2607 | |
michael@0 | 2608 | GLuint ret = 0; |
michael@0 | 2609 | GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret); |
michael@0 | 2610 | return ret; |
michael@0 | 2611 | } |
michael@0 | 2612 | |
michael@0 | 2613 | GLuint GetReadFB() { |
michael@0 | 2614 | if (mScreen) |
michael@0 | 2615 | return mScreen->GetReadFB(); |
michael@0 | 2616 | |
michael@0 | 2617 | GLenum bindEnum = IsSupported(GLFeature::framebuffer_blit) |
michael@0 | 2618 | ? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT |
michael@0 | 2619 | : LOCAL_GL_FRAMEBUFFER_BINDING; |
michael@0 | 2620 | |
michael@0 | 2621 | GLuint ret = 0; |
michael@0 | 2622 | GetUIntegerv(bindEnum, &ret); |
michael@0 | 2623 | return ret; |
michael@0 | 2624 | } |
michael@0 | 2625 | |
michael@0 | 2626 | GLuint GetFB() { |
michael@0 | 2627 | if (mScreen) { |
michael@0 | 2628 | // This has a very important extra assert that checks that we're |
michael@0 | 2629 | // not accidentally ignoring a situation where the draw and read |
michael@0 | 2630 | // FBs differ. |
michael@0 | 2631 | return mScreen->GetFB(); |
michael@0 | 2632 | } |
michael@0 | 2633 | |
michael@0 | 2634 | GLuint ret = 0; |
michael@0 | 2635 | GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret); |
michael@0 | 2636 | return ret; |
michael@0 | 2637 | } |
michael@0 | 2638 | |
michael@0 | 2639 | private: |
michael@0 | 2640 | void GetShaderPrecisionFormatNonES2(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
michael@0 | 2641 | switch (precisiontype) { |
michael@0 | 2642 | case LOCAL_GL_LOW_FLOAT: |
michael@0 | 2643 | case LOCAL_GL_MEDIUM_FLOAT: |
michael@0 | 2644 | case LOCAL_GL_HIGH_FLOAT: |
michael@0 | 2645 | // Assume IEEE 754 precision |
michael@0 | 2646 | range[0] = 127; |
michael@0 | 2647 | range[1] = 127; |
michael@0 | 2648 | *precision = 23; |
michael@0 | 2649 | break; |
michael@0 | 2650 | case LOCAL_GL_LOW_INT: |
michael@0 | 2651 | case LOCAL_GL_MEDIUM_INT: |
michael@0 | 2652 | case LOCAL_GL_HIGH_INT: |
michael@0 | 2653 | // Some (most) hardware only supports single-precision floating-point numbers, |
michael@0 | 2654 | // which can accurately represent integers up to +/-16777216 |
michael@0 | 2655 | range[0] = 24; |
michael@0 | 2656 | range[1] = 24; |
michael@0 | 2657 | *precision = 0; |
michael@0 | 2658 | break; |
michael@0 | 2659 | } |
michael@0 | 2660 | } |
michael@0 | 2661 | |
michael@0 | 2662 | public: |
michael@0 | 2663 | |
michael@0 | 2664 | void ForceDirtyScreen(); |
michael@0 | 2665 | void CleanDirtyScreen(); |
michael@0 | 2666 | |
michael@0 | 2667 | virtual GLenum GetPreferredARGB32Format() const { return LOCAL_GL_RGBA; } |
michael@0 | 2668 | |
michael@0 | 2669 | virtual bool RenewSurface() { return false; } |
michael@0 | 2670 | |
michael@0 | 2671 | // Shared code for GL extensions and GLX extensions. |
michael@0 | 2672 | static bool ListHasExtension(const GLubyte *extensions, |
michael@0 | 2673 | const char *extension); |
michael@0 | 2674 | |
michael@0 | 2675 | GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; } |
michael@0 | 2676 | |
michael@0 | 2677 | public: |
michael@0 | 2678 | /** |
michael@0 | 2679 | * Context reset constants. |
michael@0 | 2680 | * These are used to determine who is guilty when a context reset |
michael@0 | 2681 | * happens. |
michael@0 | 2682 | */ |
michael@0 | 2683 | enum ContextResetARB { |
michael@0 | 2684 | CONTEXT_NO_ERROR = 0, |
michael@0 | 2685 | CONTEXT_GUILTY_CONTEXT_RESET_ARB = 0x8253, |
michael@0 | 2686 | CONTEXT_INNOCENT_CONTEXT_RESET_ARB = 0x8254, |
michael@0 | 2687 | CONTEXT_UNKNOWN_CONTEXT_RESET_ARB = 0x8255 |
michael@0 | 2688 | }; |
michael@0 | 2689 | |
michael@0 | 2690 | public: |
michael@0 | 2691 | std::map<GLuint, SharedSurface_GL*> mFBOMapping; |
michael@0 | 2692 | |
michael@0 | 2693 | enum { |
michael@0 | 2694 | DebugEnabled = 1 << 0, |
michael@0 | 2695 | DebugTrace = 1 << 1, |
michael@0 | 2696 | DebugAbortOnError = 1 << 2 |
michael@0 | 2697 | }; |
michael@0 | 2698 | |
michael@0 | 2699 | static uint32_t sDebugMode; |
michael@0 | 2700 | |
michael@0 | 2701 | static uint32_t DebugMode() { |
michael@0 | 2702 | #ifdef DEBUG |
michael@0 | 2703 | return sDebugMode; |
michael@0 | 2704 | #else |
michael@0 | 2705 | return 0; |
michael@0 | 2706 | #endif |
michael@0 | 2707 | } |
michael@0 | 2708 | |
michael@0 | 2709 | protected: |
michael@0 | 2710 | nsRefPtr<GLContext> mSharedContext; |
michael@0 | 2711 | |
michael@0 | 2712 | // The thread on which this context was created. |
michael@0 | 2713 | nsCOMPtr<nsIThread> mOwningThread; |
michael@0 | 2714 | |
michael@0 | 2715 | GLContextSymbols mSymbols; |
michael@0 | 2716 | |
michael@0 | 2717 | #ifdef DEBUG |
michael@0 | 2718 | // GLDebugMode will check that we don't send call |
michael@0 | 2719 | // to a GLContext that isn't current on the current |
michael@0 | 2720 | // thread. |
michael@0 | 2721 | // Store the current context when binding to thread local |
michael@0 | 2722 | // storage to support DebugMode on an arbitrary thread. |
michael@0 | 2723 | static unsigned sCurrentGLContextTLS; |
michael@0 | 2724 | #endif |
michael@0 | 2725 | |
michael@0 | 2726 | ScopedDeletePtr<GLBlitHelper> mBlitHelper; |
michael@0 | 2727 | ScopedDeletePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper; |
michael@0 | 2728 | ScopedDeletePtr<GLReadTexImageHelper> mReadTexImageHelper; |
michael@0 | 2729 | |
michael@0 | 2730 | public: |
michael@0 | 2731 | GLBlitHelper* BlitHelper(); |
michael@0 | 2732 | GLBlitTextureImageHelper* BlitTextureImageHelper(); |
michael@0 | 2733 | GLReadTexImageHelper* ReadTexImageHelper(); |
michael@0 | 2734 | |
michael@0 | 2735 | // Assumes shares are created by all sharing with the same global context. |
michael@0 | 2736 | bool SharesWith(const GLContext* other) const { |
michael@0 | 2737 | MOZ_ASSERT(!this->mSharedContext || !this->mSharedContext->mSharedContext); |
michael@0 | 2738 | MOZ_ASSERT(!other->mSharedContext || !other->mSharedContext->mSharedContext); |
michael@0 | 2739 | MOZ_ASSERT(!this->mSharedContext || |
michael@0 | 2740 | !other->mSharedContext || |
michael@0 | 2741 | this->mSharedContext == other->mSharedContext); |
michael@0 | 2742 | |
michael@0 | 2743 | const GLContext* thisShared = this->mSharedContext ? this->mSharedContext |
michael@0 | 2744 | : this; |
michael@0 | 2745 | const GLContext* otherShared = other->mSharedContext ? other->mSharedContext |
michael@0 | 2746 | : other; |
michael@0 | 2747 | |
michael@0 | 2748 | return thisShared == otherShared; |
michael@0 | 2749 | } |
michael@0 | 2750 | |
michael@0 | 2751 | bool InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps) { |
michael@0 | 2752 | if (!CreateScreenBuffer(size, caps)) |
michael@0 | 2753 | return false; |
michael@0 | 2754 | |
michael@0 | 2755 | MakeCurrent(); |
michael@0 | 2756 | fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0); |
michael@0 | 2757 | fScissor(0, 0, size.width, size.height); |
michael@0 | 2758 | fViewport(0, 0, size.width, size.height); |
michael@0 | 2759 | |
michael@0 | 2760 | mCaps = mScreen->Caps(); |
michael@0 | 2761 | if (mCaps.any) |
michael@0 | 2762 | DetermineCaps(); |
michael@0 | 2763 | |
michael@0 | 2764 | UpdateGLFormats(mCaps); |
michael@0 | 2765 | UpdatePixelFormat(); |
michael@0 | 2766 | |
michael@0 | 2767 | return true; |
michael@0 | 2768 | } |
michael@0 | 2769 | |
michael@0 | 2770 | protected: |
michael@0 | 2771 | // Note that it does -not- clear the resized buffers. |
michael@0 | 2772 | bool CreateScreenBuffer(const gfx::IntSize& size, const SurfaceCaps& caps) { |
michael@0 | 2773 | if (!IsOffscreenSizeAllowed(size)) |
michael@0 | 2774 | return false; |
michael@0 | 2775 | |
michael@0 | 2776 | SurfaceCaps tryCaps = caps; |
michael@0 | 2777 | if (tryCaps.antialias) { |
michael@0 | 2778 | // AA path |
michael@0 | 2779 | if (CreateScreenBufferImpl(size, tryCaps)) |
michael@0 | 2780 | return true; |
michael@0 | 2781 | |
michael@0 | 2782 | NS_WARNING("CreateScreenBuffer failed to initialize an AA context! Falling back to no AA..."); |
michael@0 | 2783 | tryCaps.antialias = false; |
michael@0 | 2784 | } |
michael@0 | 2785 | MOZ_ASSERT(!tryCaps.antialias); |
michael@0 | 2786 | |
michael@0 | 2787 | if (CreateScreenBufferImpl(size, tryCaps)) |
michael@0 | 2788 | return true; |
michael@0 | 2789 | |
michael@0 | 2790 | NS_WARNING("CreateScreenBuffer failed to initialize non-AA context!"); |
michael@0 | 2791 | return false; |
michael@0 | 2792 | } |
michael@0 | 2793 | |
michael@0 | 2794 | bool CreateScreenBufferImpl(const gfx::IntSize& size, |
michael@0 | 2795 | const SurfaceCaps& caps); |
michael@0 | 2796 | |
michael@0 | 2797 | public: |
michael@0 | 2798 | bool ResizeScreenBuffer(const gfx::IntSize& size); |
michael@0 | 2799 | |
michael@0 | 2800 | protected: |
michael@0 | 2801 | SurfaceCaps mCaps; |
michael@0 | 2802 | nsAutoPtr<GLFormats> mGLFormats; |
michael@0 | 2803 | nsAutoPtr<PixelBufferFormat> mPixelFormat; |
michael@0 | 2804 | |
michael@0 | 2805 | public: |
michael@0 | 2806 | void DetermineCaps(); |
michael@0 | 2807 | const SurfaceCaps& Caps() const { |
michael@0 | 2808 | return mCaps; |
michael@0 | 2809 | } |
michael@0 | 2810 | |
michael@0 | 2811 | // Only varies based on bpp16 and alpha. |
michael@0 | 2812 | GLFormats ChooseGLFormats(const SurfaceCaps& caps) const; |
michael@0 | 2813 | void UpdateGLFormats(const SurfaceCaps& caps) { |
michael@0 | 2814 | mGLFormats = new GLFormats(ChooseGLFormats(caps)); |
michael@0 | 2815 | } |
michael@0 | 2816 | |
michael@0 | 2817 | const GLFormats& GetGLFormats() const { |
michael@0 | 2818 | MOZ_ASSERT(mGLFormats); |
michael@0 | 2819 | return *mGLFormats; |
michael@0 | 2820 | } |
michael@0 | 2821 | |
michael@0 | 2822 | PixelBufferFormat QueryPixelFormat(); |
michael@0 | 2823 | void UpdatePixelFormat(); |
michael@0 | 2824 | |
michael@0 | 2825 | const PixelBufferFormat& GetPixelFormat() const { |
michael@0 | 2826 | MOZ_ASSERT(mPixelFormat); |
michael@0 | 2827 | return *mPixelFormat; |
michael@0 | 2828 | } |
michael@0 | 2829 | |
michael@0 | 2830 | bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr); |
michael@0 | 2831 | |
michael@0 | 2832 | // Does not check completeness. |
michael@0 | 2833 | void AttachBuffersToFB(GLuint colorTex, GLuint colorRB, |
michael@0 | 2834 | GLuint depthRB, GLuint stencilRB, |
michael@0 | 2835 | GLuint fb, GLenum target = LOCAL_GL_TEXTURE_2D); |
michael@0 | 2836 | |
michael@0 | 2837 | // Passing null is fine if the value you'd get is 0. |
michael@0 | 2838 | bool AssembleOffscreenFBs(const GLuint colorMSRB, |
michael@0 | 2839 | const GLuint depthRB, |
michael@0 | 2840 | const GLuint stencilRB, |
michael@0 | 2841 | const GLuint texture, |
michael@0 | 2842 | GLuint* drawFB, |
michael@0 | 2843 | GLuint* readFB); |
michael@0 | 2844 | |
michael@0 | 2845 | protected: |
michael@0 | 2846 | friend class GLScreenBuffer; |
michael@0 | 2847 | GLScreenBuffer* mScreen; |
michael@0 | 2848 | |
michael@0 | 2849 | void DestroyScreenBuffer(); |
michael@0 | 2850 | |
michael@0 | 2851 | SharedSurface_GL* mLockedSurface; |
michael@0 | 2852 | |
michael@0 | 2853 | public: |
michael@0 | 2854 | void LockSurface(SharedSurface_GL* surf) { |
michael@0 | 2855 | MOZ_ASSERT(!mLockedSurface); |
michael@0 | 2856 | mLockedSurface = surf; |
michael@0 | 2857 | } |
michael@0 | 2858 | |
michael@0 | 2859 | void UnlockSurface(SharedSurface_GL* surf) { |
michael@0 | 2860 | MOZ_ASSERT(mLockedSurface == surf); |
michael@0 | 2861 | mLockedSurface = nullptr; |
michael@0 | 2862 | } |
michael@0 | 2863 | |
michael@0 | 2864 | SharedSurface_GL* GetLockedSurface() const { |
michael@0 | 2865 | return mLockedSurface; |
michael@0 | 2866 | } |
michael@0 | 2867 | |
michael@0 | 2868 | bool IsOffscreen() const { |
michael@0 | 2869 | return mScreen; |
michael@0 | 2870 | } |
michael@0 | 2871 | |
michael@0 | 2872 | GLScreenBuffer* Screen() const { |
michael@0 | 2873 | return mScreen; |
michael@0 | 2874 | } |
michael@0 | 2875 | |
michael@0 | 2876 | bool PublishFrame(); |
michael@0 | 2877 | SharedSurface_GL* RequestFrame(); |
michael@0 | 2878 | |
michael@0 | 2879 | /* Clear to transparent black, with 0 depth and stencil, |
michael@0 | 2880 | * while preserving current ClearColor etc. values. |
michael@0 | 2881 | * Useful for resizing offscreen buffers. |
michael@0 | 2882 | */ |
michael@0 | 2883 | void ClearSafely(); |
michael@0 | 2884 | |
michael@0 | 2885 | bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; } |
michael@0 | 2886 | |
michael@0 | 2887 | protected: |
michael@0 | 2888 | nsRefPtr<TextureGarbageBin> mTexGarbageBin; |
michael@0 | 2889 | |
michael@0 | 2890 | public: |
michael@0 | 2891 | TextureGarbageBin* TexGarbageBin() { |
michael@0 | 2892 | MOZ_ASSERT(mTexGarbageBin); |
michael@0 | 2893 | return mTexGarbageBin; |
michael@0 | 2894 | } |
michael@0 | 2895 | |
michael@0 | 2896 | void EmptyTexGarbageBin(); |
michael@0 | 2897 | |
michael@0 | 2898 | bool IsOffscreenSizeAllowed(const gfx::IntSize& aSize) const; |
michael@0 | 2899 | |
michael@0 | 2900 | protected: |
michael@0 | 2901 | bool InitWithPrefix(const char *prefix, bool trygl); |
michael@0 | 2902 | |
michael@0 | 2903 | void InitExtensions(); |
michael@0 | 2904 | |
michael@0 | 2905 | GLint mViewportRect[4]; |
michael@0 | 2906 | GLint mScissorRect[4]; |
michael@0 | 2907 | |
michael@0 | 2908 | GLint mMaxTextureSize; |
michael@0 | 2909 | GLint mMaxCubeMapTextureSize; |
michael@0 | 2910 | GLint mMaxTextureImageSize; |
michael@0 | 2911 | GLint mMaxRenderbufferSize; |
michael@0 | 2912 | GLsizei mMaxSamples; |
michael@0 | 2913 | bool mNeedsTextureSizeChecks; |
michael@0 | 2914 | bool mWorkAroundDriverBugs; |
michael@0 | 2915 | |
michael@0 | 2916 | bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const { |
michael@0 | 2917 | if (mNeedsTextureSizeChecks) { |
michael@0 | 2918 | // some drivers incorrectly handle some large texture sizes that are below the |
michael@0 | 2919 | // max texture size that they report. So we check ourselves against our own values |
michael@0 | 2920 | // (mMax[CubeMap]TextureSize). |
michael@0 | 2921 | // see bug 737182 for Mac Intel 2D textures |
michael@0 | 2922 | // see bug 684882 for Mac Intel cube map textures |
michael@0 | 2923 | // see bug 814716 for Mesa Nouveau |
michael@0 | 2924 | GLsizei maxSize = target == LOCAL_GL_TEXTURE_CUBE_MAP || |
michael@0 | 2925 | (target >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X && |
michael@0 | 2926 | target <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) |
michael@0 | 2927 | ? mMaxCubeMapTextureSize |
michael@0 | 2928 | : mMaxTextureSize; |
michael@0 | 2929 | return width <= maxSize && height <= maxSize; |
michael@0 | 2930 | } |
michael@0 | 2931 | return true; |
michael@0 | 2932 | } |
michael@0 | 2933 | |
michael@0 | 2934 | |
michael@0 | 2935 | public: |
michael@0 | 2936 | |
michael@0 | 2937 | void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) { |
michael@0 | 2938 | if (mViewportRect[0] == x && |
michael@0 | 2939 | mViewportRect[1] == y && |
michael@0 | 2940 | mViewportRect[2] == width && |
michael@0 | 2941 | mViewportRect[3] == height) |
michael@0 | 2942 | { |
michael@0 | 2943 | return; |
michael@0 | 2944 | } |
michael@0 | 2945 | mViewportRect[0] = x; |
michael@0 | 2946 | mViewportRect[1] = y; |
michael@0 | 2947 | mViewportRect[2] = width; |
michael@0 | 2948 | mViewportRect[3] = height; |
michael@0 | 2949 | BEFORE_GL_CALL; |
michael@0 | 2950 | mSymbols.fViewport(x, y, width, height); |
michael@0 | 2951 | AFTER_GL_CALL; |
michael@0 | 2952 | } |
michael@0 | 2953 | |
michael@0 | 2954 | #undef ASSERT_SYMBOL_PRESENT |
michael@0 | 2955 | |
michael@0 | 2956 | #ifdef MOZ_ENABLE_GL_TRACKING |
michael@0 | 2957 | void CreatedProgram(GLContext *aOrigin, GLuint aName); |
michael@0 | 2958 | void CreatedShader(GLContext *aOrigin, GLuint aName); |
michael@0 | 2959 | void CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); |
michael@0 | 2960 | void CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); |
michael@0 | 2961 | void CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); |
michael@0 | 2962 | void CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); |
michael@0 | 2963 | void CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); |
michael@0 | 2964 | void DeletedProgram(GLContext *aOrigin, GLuint aName); |
michael@0 | 2965 | void DeletedShader(GLContext *aOrigin, GLuint aName); |
michael@0 | 2966 | void DeletedBuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); |
michael@0 | 2967 | void DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); |
michael@0 | 2968 | void DeletedTextures(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); |
michael@0 | 2969 | void DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); |
michael@0 | 2970 | void DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames); |
michael@0 | 2971 | |
michael@0 | 2972 | void SharedContextDestroyed(GLContext *aChild); |
michael@0 | 2973 | void ReportOutstandingNames(); |
michael@0 | 2974 | |
michael@0 | 2975 | struct NamedResource { |
michael@0 | 2976 | NamedResource() |
michael@0 | 2977 | : origin(nullptr), name(0), originDeleted(false) |
michael@0 | 2978 | { } |
michael@0 | 2979 | |
michael@0 | 2980 | NamedResource(GLContext *aOrigin, GLuint aName) |
michael@0 | 2981 | : origin(aOrigin), name(aName), originDeleted(false) |
michael@0 | 2982 | { } |
michael@0 | 2983 | |
michael@0 | 2984 | GLContext *origin; |
michael@0 | 2985 | GLuint name; |
michael@0 | 2986 | bool originDeleted; |
michael@0 | 2987 | |
michael@0 | 2988 | // for sorting |
michael@0 | 2989 | bool operator<(const NamedResource& aOther) const { |
michael@0 | 2990 | if (intptr_t(origin) < intptr_t(aOther.origin)) |
michael@0 | 2991 | return true; |
michael@0 | 2992 | if (name < aOther.name) |
michael@0 | 2993 | return true; |
michael@0 | 2994 | return false; |
michael@0 | 2995 | } |
michael@0 | 2996 | bool operator==(const NamedResource& aOther) const { |
michael@0 | 2997 | return origin == aOther.origin && |
michael@0 | 2998 | name == aOther.name && |
michael@0 | 2999 | originDeleted == aOther.originDeleted; |
michael@0 | 3000 | } |
michael@0 | 3001 | }; |
michael@0 | 3002 | |
michael@0 | 3003 | nsTArray<NamedResource> mTrackedPrograms; |
michael@0 | 3004 | nsTArray<NamedResource> mTrackedShaders; |
michael@0 | 3005 | nsTArray<NamedResource> mTrackedTextures; |
michael@0 | 3006 | nsTArray<NamedResource> mTrackedFramebuffers; |
michael@0 | 3007 | nsTArray<NamedResource> mTrackedRenderbuffers; |
michael@0 | 3008 | nsTArray<NamedResource> mTrackedBuffers; |
michael@0 | 3009 | nsTArray<NamedResource> mTrackedQueries; |
michael@0 | 3010 | #endif |
michael@0 | 3011 | }; |
michael@0 | 3012 | |
michael@0 | 3013 | bool DoesStringMatch(const char* aString, const char *aWantedString); |
michael@0 | 3014 | |
michael@0 | 3015 | |
michael@0 | 3016 | } /* namespace gl */ |
michael@0 | 3017 | } /* namespace mozilla */ |
michael@0 | 3018 | |
michael@0 | 3019 | #endif /* GLCONTEXT_H_ */ |