Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.h

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WebGLRenderingContext_h 26 #ifndef WebGLRenderingContextBase_h
27 #define WebGLRenderingContext_h 27 #define WebGLRenderingContextBase_h
28 28
29 #include "core/dom/ActiveDOMObject.h" 29 #include "core/dom/ActiveDOMObject.h"
30 #include "core/html/canvas/CanvasRenderingContext.h" 30 #include "core/html/canvas/CanvasRenderingContext.h"
31 #include "core/html/canvas/WebGLGetInfo.h" 31 #include "core/html/canvas/WebGLGetInfo.h"
32 #include "core/page/Page.h" 32 #include "core/page/Page.h"
33 #include "core/platform/Timer.h" 33 #include "core/platform/Timer.h"
34 #include "core/platform/graphics/GraphicsContext3D.h" 34 #include "core/platform/graphics/GraphicsContext3D.h"
35 #include "core/platform/graphics/ImageBuffer.h" 35 #include "core/platform/graphics/ImageBuffer.h"
36 36
37 #include "wtf/Float32Array.h" 37 #include "wtf/Float32Array.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 class WebGLObject; 78 class WebGLObject;
79 class WebGLProgram; 79 class WebGLProgram;
80 class WebGLRenderbuffer; 80 class WebGLRenderbuffer;
81 class WebGLShader; 81 class WebGLShader;
82 class WebGLShaderPrecisionFormat; 82 class WebGLShaderPrecisionFormat;
83 class WebGLSharedObject; 83 class WebGLSharedObject;
84 class WebGLTexture; 84 class WebGLTexture;
85 class WebGLUniformLocation; 85 class WebGLUniformLocation;
86 class WebGLVertexArrayObjectOES; 86 class WebGLVertexArrayObjectOES;
87 87
88 class WebGLRenderingContext : public CanvasRenderingContext, public ActiveDOMObj ect, private Page::MultisamplingChangedObserver { 88 class WebGLRenderingContextBase : public CanvasRenderingContext, public ActiveDO MObject, private Page::MultisamplingChangedObserver {
89 public: 89 public:
90 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLCon textAttributes*); 90 virtual ~WebGLRenderingContextBase();
91 virtual ~WebGLRenderingContext();
92 91
93 virtual bool is3d() const { return true; } 92 virtual bool is3d() const { return true; }
94 virtual bool isAccelerated() const { return true; } 93 virtual bool isAccelerated() const { return true; }
95 94
95 virtual void registerContextExtensions() = 0;
96
96 int drawingBufferWidth() const; 97 int drawingBufferWidth() const;
97 int drawingBufferHeight() const; 98 int drawingBufferHeight() const;
98 99
99 void activeTexture(GC3Denum texture); 100 void activeTexture(GC3Denum texture);
100 void attachShader(WebGLProgram*, WebGLShader*); 101 void attachShader(WebGLProgram*, WebGLShader*);
101 void bindAttribLocation(WebGLProgram*, GC3Duint index, const String& name); 102 void bindAttribLocation(WebGLProgram*, GC3Duint index, const String& name);
102 void bindBuffer(GC3Denum target, WebGLBuffer*); 103 void bindBuffer(GC3Denum target, WebGLBuffer*);
103 void bindFramebuffer(GC3Denum target, WebGLFramebuffer*); 104 void bindFramebuffer(GC3Denum target, WebGLFramebuffer*);
104 void bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*); 105 void bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*);
105 void bindTexture(GC3Denum target, WebGLTexture*); 106 void bindTexture(GC3Denum target, WebGLTexture*);
(...skipping 11 matching lines...) Expand all
117 118
118 GC3Denum checkFramebufferStatus(GC3Denum target); 119 GC3Denum checkFramebufferStatus(GC3Denum target);
119 void clear(GC3Dbitfield mask); 120 void clear(GC3Dbitfield mask);
120 void clearColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat al pha); 121 void clearColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat al pha);
121 void clearDepth(GC3Dfloat); 122 void clearDepth(GC3Dfloat);
122 void clearStencil(GC3Dint); 123 void clearStencil(GC3Dint);
123 void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboo lean alpha); 124 void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboo lean alpha);
124 void compileShader(WebGLShader*); 125 void compileShader(WebGLShader*);
125 126
126 void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalf ormat, GC3Dsizei width, 127 void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalf ormat, GC3Dsizei width,
127 GC3Dsizei height, GC3Dint border, ArrayBufferView* data); 128 GC3Dsizei height, GC3Dint border, ArrayBufferView* data);
bajones 2013/09/20 19:24:25 Apologies for the clutter, but cl upload decided t
128 void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset , GC3Dint yoffset, 129 void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset , GC3Dint yoffset,
129 GC3Dsizei width, GC3Dsizei height, GC3Denum for mat, ArrayBufferView* data); 130 GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* dat a);
130 131
131 void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border); 132 void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
132 void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); 133 void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
133 134
134 PassRefPtr<WebGLBuffer> createBuffer(); 135 PassRefPtr<WebGLBuffer> createBuffer();
135 PassRefPtr<WebGLFramebuffer> createFramebuffer(); 136 PassRefPtr<WebGLFramebuffer> createFramebuffer();
136 PassRefPtr<WebGLProgram> createProgram(); 137 PassRefPtr<WebGLProgram> createProgram();
137 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); 138 PassRefPtr<WebGLRenderbuffer> createRenderbuffer();
138 PassRefPtr<WebGLShader> createShader(GC3Denum type); 139 PassRefPtr<WebGLShader> createShader(GC3Denum type);
139 PassRefPtr<WebGLTexture> createTexture(); 140 PassRefPtr<WebGLTexture> createTexture();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 326
326 void removeSharedObject(WebGLSharedObject*); 327 void removeSharedObject(WebGLSharedObject*);
327 void removeContextObject(WebGLContextObject*); 328 void removeContextObject(WebGLContextObject*);
328 329
329 unsigned getMaxVertexAttribs() const { return m_maxVertexAttribs; } 330 unsigned getMaxVertexAttribs() const { return m_maxVertexAttribs; }
330 331
331 // ActiveDOMObject notifications 332 // ActiveDOMObject notifications
332 virtual bool hasPendingActivity() const; 333 virtual bool hasPendingActivity() const;
333 virtual void stop(); 334 virtual void stop();
334 335
335 private: 336 protected:
336 friend class WebGLDrawBuffers; 337 friend class WebGLDrawBuffers;
337 friend class WebGLFramebuffer; 338 friend class WebGLFramebuffer;
338 friend class WebGLObject; 339 friend class WebGLObject;
339 friend class OESVertexArrayObject; 340 friend class OESVertexArrayObject;
340 friend class WebGLDebugShaders; 341 friend class WebGLDebugShaders;
341 friend class WebGLCompressedTextureATC; 342 friend class WebGLCompressedTextureATC;
342 friend class WebGLCompressedTexturePVRTC; 343 friend class WebGLCompressedTexturePVRTC;
343 friend class WebGLCompressedTextureS3TC; 344 friend class WebGLCompressedTextureS3TC;
344 friend class WebGLRenderingContextErrorMessageCallback; 345 friend class WebGLRenderingContextErrorMessageCallback;
345 friend class WebGLVertexArrayObjectOES; 346 friend class WebGLVertexArrayObjectOES;
346 347
347 WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, Gra phicsContext3D::Attributes, GraphicsContext3D::Attributes); 348 WebGLRenderingContextBase(const String&, HTMLCanvasElement*, PassRefPtr<Grap hicsContext3D>, GraphicsContext3D::Attributes, GraphicsContext3D::Attributes);
348 void initializeNewContext(); 349 void initializeNewContext();
349 void setupFlags(); 350 void setupFlags();
350 351
351 void addSharedObject(WebGLSharedObject*); 352 void addSharedObject(WebGLSharedObject*);
352 void addContextObject(WebGLContextObject*); 353 void addContextObject(WebGLContextObject*);
353 void detachAndRemoveAllObjects(); 354 void detachAndRemoveAllObjects();
354 355
355 void destroyGraphicsContext3D(); 356 void destroyGraphicsContext3D();
356 void markContextChanged(); 357 void markContextChanged();
357 358
358 // Query if the GL implementation is NPOT strict. 359 // Query if the GL implementation is NPOT strict.
359 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } 360 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; }
360 // Query if depth_stencil buffer is supported. 361 // Query if depth_stencil buffer is supported.
361 bool isDepthStencilSupported() { return m_isDepthStencilSupported; } 362 bool isDepthStencilSupported() { return m_isDepthStencilSupported; }
362 363
363 // Helper to return the size in bytes of OpenGL data types 364 // Helper to return the size in bytes of OpenGL data types
364 // like GL_FLOAT, GL_INT, etc. 365 // like GL_FLOAT, GL_INT, etc.
365 unsigned int sizeInBytes(GC3Denum type); 366 unsigned sizeInBytes(GC3Denum type);
366 367
367 // Check if each enabled vertex attribute is bound to a buffer. 368 // Check if each enabled vertex attribute is bound to a buffer.
368 bool validateRenderingState(); 369 bool validateRenderingState();
369 370
370 bool validateWebGLObject(const char*, WebGLObject*); 371 bool validateWebGLObject(const char*, WebGLObject*);
371 372
372 // Adds a compressed texture format. 373 // Adds a compressed texture format.
373 void addCompressedTextureFormat(GC3Denum); 374 void addCompressedTextureFormat(GC3Denum);
374 void removeAllCompressedTextureFormats(); 375 void removeAllCompressedTextureFormats();
375 376
376 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 377 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
377 378
378 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GC3Denum target, WebGLRenderb uffer*); 379 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GC3Denum target, WebGLRenderb uffer*);
379 380
381 const String m_contextName;
Zhenyao Mo 2013/09/20 23:04:45 I still feel like we should have a unsigned int m_
bajones 2013/09/20 23:08:49 If we want to branch functionality based on WebGL
380 RefPtr<GraphicsContext3D> m_context; 382 RefPtr<GraphicsContext3D> m_context;
381 RefPtr<WebGLContextGroup> m_contextGroup; 383 RefPtr<WebGLContextGroup> m_contextGroup;
382 384
383 // Structure for rendering to a DrawingBuffer, instead of directly 385 // Structure for rendering to a DrawingBuffer, instead of directly
384 // to the back-buffer of m_context. 386 // to the back-buffer of m_context.
385 RefPtr<DrawingBuffer> m_drawingBuffer; 387 RefPtr<DrawingBuffer> m_drawingBuffer;
386 388
387 // Dispatches a context lost event once it is determined that one is needed. 389 // Dispatches a context lost event once it is determined that one is needed.
388 // This is used both for synthetic and real context losses. For real ones, i t's 390 // This is used both for synthetic and real context losses. For real ones, i t's
389 // likely that there's no JavaScript on the stack, but that might be depende nt 391 // likely that there's no JavaScript on the stack, but that might be depende nt
390 // on how exactly the platform discovers that the context was lost. For bett er 392 // on how exactly the platform discovers that the context was lost. For bett er
391 // portability we always defer the dispatch of the event. 393 // portability we always defer the dispatch of the event.
392 Timer<WebGLRenderingContext> m_dispatchContextLostEventTimer; 394 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
393 bool m_restoreAllowed; 395 bool m_restoreAllowed;
394 Timer<WebGLRenderingContext> m_restoreTimer; 396 Timer<WebGLRenderingContextBase> m_restoreTimer;
395 397
396 bool m_needsUpdate; 398 bool m_needsUpdate;
397 bool m_markedCanvasDirty; 399 bool m_markedCanvasDirty;
398 HashSet<WebGLContextObject*> m_contextObjects; 400 HashSet<WebGLContextObject*> m_contextObjects;
399 401
400 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER 402 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER
401 RefPtr<WebGLBuffer> m_boundArrayBuffer; 403 RefPtr<WebGLBuffer> m_boundArrayBuffer;
402 404
403 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; 405 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
404 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; 406 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 RefPtr<WebGLTexture> m_blackTexture2D; 451 RefPtr<WebGLTexture> m_blackTexture2D;
450 RefPtr<WebGLTexture> m_blackTextureCubeMap; 452 RefPtr<WebGLTexture> m_blackTextureCubeMap;
451 453
452 Vector<GC3Denum> m_compressedTextureFormats; 454 Vector<GC3Denum> m_compressedTextureFormats;
453 455
454 // Fixed-size cache of reusable image buffers for video texImage2D calls. 456 // Fixed-size cache of reusable image buffers for video texImage2D calls.
455 class LRUImageBufferCache { 457 class LRUImageBufferCache {
456 public: 458 public:
457 LRUImageBufferCache(int capacity); 459 LRUImageBufferCache(int capacity);
458 // The pointer returned is owned by the image buffer map. 460 // The pointer returned is owned by the image buffer map.
459 ImageBuffer* imageBuffer(const IntSize& size); 461 ImageBuffer* imageBuffer(const IntSize&);
460 private: 462 private:
461 void bubbleToFront(int idx); 463 void bubbleToFront(int idx);
462 OwnArrayPtr<OwnPtr<ImageBuffer> > m_buffers; 464 OwnArrayPtr<OwnPtr<ImageBuffer> > m_buffers;
463 int m_capacity; 465 int m_capacity;
464 }; 466 };
465 LRUImageBufferCache m_videoCache; 467 LRUImageBufferCache m_videoCache;
466 468
467 GC3Dint m_maxTextureSize; 469 GC3Dint m_maxTextureSize;
468 GC3Dint m_maxCubeMapTextureSize; 470 GC3Dint m_maxCubeMapTextureSize;
469 GC3Dint m_maxRenderbufferSize; 471 GC3Dint m_maxRenderbufferSize;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 507
506 bool m_synthesizedErrorsToConsole; 508 bool m_synthesizedErrorsToConsole;
507 int m_numGLErrorsToConsoleAllowed; 509 int m_numGLErrorsToConsoleAllowed;
508 510
509 bool m_multisamplingAllowed; 511 bool m_multisamplingAllowed;
510 bool m_multisamplingObserverRegistered; 512 bool m_multisamplingObserverRegistered;
511 513
512 GC3Duint m_onePlusMaxEnabledAttribIndex; 514 GC3Duint m_onePlusMaxEnabledAttribIndex;
513 unsigned long m_onePlusMaxNonDefaultTextureUnit; 515 unsigned long m_onePlusMaxNonDefaultTextureUnit;
514 516
515 // Enabled extension objects. 517 // Enabled extension objects.
bajones 2013/09/20 19:24:25 This is an area worth evaluating. Currently the co
516 RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays; 518 RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays;
517 RefPtr<EXTFragDepth> m_extFragDepth; 519 RefPtr<EXTFragDepth> m_extFragDepth;
518 RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; 520 RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic;
521 RefPtr<OESElementIndexUint> m_oesElementIndexUint;
522 RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
519 RefPtr<OESTextureFloat> m_oesTextureFloat; 523 RefPtr<OESTextureFloat> m_oesTextureFloat;
520 RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear; 524 RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear;
521 RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat; 525 RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat;
522 RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear; 526 RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear;
523 RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
524 RefPtr<OESVertexArrayObject> m_oesVertexArrayObject; 527 RefPtr<OESVertexArrayObject> m_oesVertexArrayObject;
525 RefPtr<OESElementIndexUint> m_oesElementIndexUint;
526 RefPtr<WebGLLoseContext> m_webglLoseContext;
527 RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
528 RefPtr<WebGLDebugShaders> m_webglDebugShaders;
529 RefPtr<WebGLDrawBuffers> m_webglDrawBuffers;
530 RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC; 528 RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC;
531 RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC; 529 RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC;
532 RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; 530 RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
531 RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
532 RefPtr<WebGLDebugShaders> m_webglDebugShaders;
533 RefPtr<WebGLDepthTexture> m_webglDepthTexture; 533 RefPtr<WebGLDepthTexture> m_webglDepthTexture;
534 RefPtr<WebGLDrawBuffers> m_webglDrawBuffers;
535 RefPtr<WebGLLoseContext> m_webglLoseContext;
534 536
535 enum ExtensionFlags { 537 enum ExtensionFlags {
536 ApprovedExtension = 0x00, 538 ApprovedExtension = 0x00,
537 DraftExtension = 0x01, 539 DraftExtension = 0x01,
538 PrivilegedExtension = 0x02, 540 PrivilegedExtension = 0x02,
539 PrefixedExtension = 0x04, 541 PrefixedExtension = 0x04,
540 }; 542 };
541 543
542 class ExtensionTracker { 544 class ExtensionTracker {
543 public: 545 public:
(...skipping 19 matching lines...) Expand all
563 return m_privileged; 565 return m_privileged;
564 } 566 }
565 567
566 bool getDraft() const 568 bool getDraft() const
567 { 569 {
568 return m_draft; 570 return m_draft;
569 } 571 }
570 572
571 bool matchesNameWithPrefixes(const String&) const; 573 bool matchesNameWithPrefixes(const String&) const;
572 574
573 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext*) const = 0; 575 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e*) const = 0;
574 virtual bool supported(WebGLRenderingContext*) const = 0; 576 virtual bool supported(WebGLRenderingContextBase*) const = 0;
575 virtual const char* getExtensionName() const = 0; 577 virtual const char* getExtensionName() const = 0;
576 virtual void loseExtension() = 0; 578 virtual void loseExtension() = 0;
577 579
578 private: 580 private:
579 bool m_privileged; 581 bool m_privileged;
580 bool m_draft; 582 bool m_draft;
581 bool m_prefixed; 583 bool m_prefixed;
582 const char** m_prefixes; 584 const char** m_prefixes;
583 }; 585 };
584 586
585 template <typename T> 587 template <typename T>
586 class TypedExtensionTracker : public ExtensionTracker { 588 class TypedExtensionTracker : public ExtensionTracker {
587 public: 589 public:
588 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char** prefixes) 590 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char** prefixes)
589 : ExtensionTracker(flags, prefixes) 591 : ExtensionTracker(flags, prefixes)
590 , m_extensionField(extensionField) 592 , m_extensionField(extensionField)
591 { 593 {
592 } 594 }
593 595
594 ~TypedExtensionTracker() 596 ~TypedExtensionTracker()
595 { 597 {
596 if (m_extensionField) { 598 if (m_extensionField) {
597 m_extensionField->lose(true); 599 m_extensionField->lose(true);
598 m_extensionField = 0; 600 m_extensionField = 0;
599 } 601 }
600 } 602 }
601 603
602 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* c ontext) const 604 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBas e* context) const
603 { 605 {
604 if (!m_extensionField) 606 if (!m_extensionField)
605 m_extensionField = T::create(context); 607 m_extensionField = T::create(context);
606 608
607 return m_extensionField; 609 return m_extensionField;
608 } 610 }
609 611
610 virtual bool supported(WebGLRenderingContext* context) const 612 virtual bool supported(WebGLRenderingContextBase* context) const
611 { 613 {
612 return T::supported(context); 614 return T::supported(context);
613 } 615 }
614 616
615 virtual const char* getExtensionName() const 617 virtual const char* getExtensionName() const
616 { 618 {
617 return T::getExtensionName(); 619 return T::getExtensionName();
618 } 620 }
619 621
620 virtual void loseExtension() 622 virtual void loseExtension()
(...skipping 11 matching lines...) Expand all
632 634
633 Vector<ExtensionTracker*> m_extensions; 635 Vector<ExtensionTracker*> m_extensions;
634 636
635 template <typename T> 637 template <typename T>
636 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char** prefixes = 0) 638 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char** prefixes = 0)
637 { 639 {
638 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes)); 640 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes));
639 } 641 }
640 642
641 // Errors raised by synthesizeGLError() while the context is lost. 643 // Errors raised by synthesizeGLError() while the context is lost.
642 Vector<GC3Denum> lost_context_errors_; 644 Vector<GC3Denum> m_lostContextErrors;
643 645
644 // Helpers for getParameter and others 646 // Helpers for getParameter and others
645 WebGLGetInfo getBooleanParameter(GC3Denum); 647 WebGLGetInfo getBooleanParameter(GC3Denum);
646 WebGLGetInfo getBooleanArrayParameter(GC3Denum); 648 WebGLGetInfo getBooleanArrayParameter(GC3Denum);
647 WebGLGetInfo getFloatParameter(GC3Denum); 649 WebGLGetInfo getFloatParameter(GC3Denum);
648 WebGLGetInfo getIntParameter(GC3Denum); 650 WebGLGetInfo getIntParameter(GC3Denum);
649 WebGLGetInfo getUnsignedIntParameter(GC3Denum); 651 WebGLGetInfo getUnsignedIntParameter(GC3Denum);
650 WebGLGetInfo getWebGLFloatArrayParameter(GC3Denum); 652 WebGLGetInfo getWebGLFloatArrayParameter(GC3Denum);
651 WebGLGetInfo getWebGLIntArrayParameter(GC3Denum); 653 WebGLGetInfo getWebGLIntArrayParameter(GC3Denum);
652 654
653 // Clear the backbuffer if it was composited since the last operation. 655 // Clear the backbuffer if it was composited since the last operation.
654 // clearMask is set to the bitfield of any clear that would happen anyway at this time 656 // clearMask is set to the bitfield of any clear that would happen anyway at this time
655 // and the function returns true if that clear is now unnecessary. 657 // and the function returns true if that clear is now unnecessary.
656 bool clearIfComposited(GC3Dbitfield clearMask = 0); 658 bool clearIfComposited(GC3Dbitfield clearMask = 0);
657 659
658 // Helper to restore state that clearing the framebuffer may destroy. 660 // Helper to restore state that clearing the framebuffer may destroy.
659 void restoreStateAfterClear(); 661 void restoreStateAfterClear();
660 662
661 void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum ty pe, const void* pixels, ExceptionState&); 663 void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum ty pe, const void* pixels, ExceptionState&);
662 void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&); 664 void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&);
663 void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels, ExceptionState&); 665 void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels, ExceptionState&);
664 void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtm lDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&); 666 void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3D int yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtm lDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&);
665 667
666 void handleTextureCompleteness(const char*, bool); 668 void handleTextureCompleteness(const char*, bool);
667 void createFallbackBlackTextures1x1(); 669 void createFallbackBlackTextures1x1();
668 670
669 // Helper function for copyTex{Sub}Image, check whether the internalformat 671 // Helper function for copyTex{Sub}Image, check whether the internalformat
670 // and the color buffer format of the current bound framebuffer combination 672 // and the color buffer format of the current bound framebuffer combination
671 // is valid. 673 // is valid.
672 bool isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalForm at, 674 bool isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalForm at, GC3Denum colorBufferFormat);
673 GC3Denum colorBufferForm at);
674 675
675 // Helper function to get the bound framebuffer's color buffer format. 676 // Helper function to get the bound framebuffer's color buffer format.
676 GC3Denum getBoundFramebufferColorFormat(); 677 GC3Denum getBoundFramebufferColorFormat();
677 678
678 // Helper function to get the bound framebuffer's width. 679 // Helper function to get the bound framebuffer's width.
679 int getBoundFramebufferWidth(); 680 int getBoundFramebufferWidth();
680 681
681 // Helper function to get the bound framebuffer's height. 682 // Helper function to get the bound framebuffer's height.
682 int getBoundFramebufferHeight(); 683 int getBoundFramebufferHeight();
683 684
684 // Helper function to verify limits on the length of uniform and attribute l ocations. 685 // Helper function to verify limits on the length of uniform and attribute l ocations.
685 bool validateLocationLength(const char* functionName, const String&); 686 bool validateLocationLength(const char* functionName, const String&);
686 687
687 // Helper function to check if size is non-negative. 688 // Helper function to check if size is non-negative.
688 // Generate GL error and return false for negative inputs; otherwise, return true. 689 // Generate GL error and return false for negative inputs; otherwise, return true.
689 bool validateSize(const char* functionName, GC3Dint x, GC3Dint y); 690 bool validateSize(const char* functionName, GC3Dint x, GC3Dint y);
690 691
691 // Helper function to check if all characters in the string belong to the 692 // Helper function to check if all characters in the string belong to the
692 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. 693 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1.
693 bool validateString(const char* functionName, const String&); 694 bool validateString(const char* functionName, const String&);
694 695
695 // Helper function to check target and texture bound to the target. 696 // Helper function to check target and texture bound to the target.
696 // Generate GL errors and return 0 if target is invalid or texture bound is 697 // Generate GL errors and return 0 if target is invalid or texture bound is
697 // null. Otherwise, return the texture bound to the target. 698 // null. Otherwise, return the texture bound to the target.
698 WebGLTexture* validateTextureBinding(const char* functionName, GC3Denum targ et, bool useSixEnumsForCubeMap); 699 WebGLTexture* validateTextureBinding(const char* functionName, GC3Denum targ et, bool useSixEnumsForCubeMap);
699 700
700 // Helper function to check input format/type for functions {copy}Tex{Sub}Im age. 701 // Helper function to check input format/type for functions {copy}Tex{Sub}Im age.
701 // Generates GL error and returns false if parameters are invalid. 702 // Generates GL error and returns false if parameters are invalid.
702 bool validateTexFuncFormatAndType(const char* functionName, GC3Denum format, GC3Denum type, GC3Dint level); 703 bool validateTexFuncFormatAndType(const char* functionName, GC3Denum format, GC3Denum type, GC3Dint level);
703 704
704 // Helper function to check input level for functions {copy}Tex{Sub}Image. 705 // Helper function to check input level for functions {copy}Tex{Sub}Image.
705 // Generates GL error and returns false if level is invalid. 706 // Generates GL error and returns false if level is invalid.
706 bool validateTexFuncLevel(const char* functionName, GC3Denum target, GC3Dint level); 707 bool validateTexFuncLevel(const char* functionName, GC3Denum target, GC3Dint level);
707 708
(...skipping 16 matching lines...) Expand all
724 GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Din t xoffset, GC3Dint yoffset); 725 GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Din t xoffset, GC3Dint yoffset);
725 726
726 // Helper function to check input width and height for functions {copy, comp ressed}Tex{Sub}Image. 727 // Helper function to check input width and height for functions {copy, comp ressed}Tex{Sub}Image.
727 // Generates GL error and returns false if width or height is invalid. 728 // Generates GL error and returns false if width or height is invalid.
728 bool validateTexFuncDimensions(const char* functionName, TexFuncValidationFu nctionType, 729 bool validateTexFuncDimensions(const char* functionName, TexFuncValidationFu nctionType,
729 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height); 730 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height);
730 731
731 // Helper function to check input parameters for functions {copy}Tex{Sub}Ima ge. 732 // Helper function to check input parameters for functions {copy}Tex{Sub}Ima ge.
732 // Generates GL error and returns false if parameters are invalid. 733 // Generates GL error and returns false if parameters are invalid.
733 bool validateTexFuncParameters(const char* functionName, 734 bool validateTexFuncParameters(const char* functionName,
734 TexFuncValidationFunctionType, 735 TexFuncValidationFunctionType,
735 GC3Denum target, GC3Dint level, 736 GC3Denum target, GC3Dint level,
736 GC3Denum internalformat, 737 GC3Denum internalformat,
737 GC3Dsizei width, GC3Dsizei height, GC3Dint bo rder, 738 GC3Dsizei width, GC3Dsizei height, GC3Dint border,
738 GC3Denum format, GC3Denum type); 739 GC3Denum format, GC3Denum type);
739 740
740 enum NullDisposition { 741 enum NullDisposition {
741 NullAllowed, 742 NullAllowed,
742 NullNotAllowed 743 NullNotAllowed
743 }; 744 };
744 745
745 // Helper function to validate that the given ArrayBufferView 746 // Helper function to validate that the given ArrayBufferView
746 // is of the correct type and contains enough data for the texImage call. 747 // is of the correct type and contains enough data for the texImage call.
747 // Generates GL error and returns false if parameters are invalid. 748 // Generates GL error and returns false if parameters are invalid.
748 bool validateTexFuncData(const char* functionName, GC3Dint level, 749 bool validateTexFuncData(const char* functionName, GC3Dint level,
749 GC3Dsizei width, GC3Dsizei height, 750 GC3Dsizei width, GC3Dsizei height,
750 GC3Denum format, GC3Denum type, 751 GC3Denum format, GC3Denum type,
751 ArrayBufferView* pixels, 752 ArrayBufferView* pixels,
752 NullDisposition); 753 NullDisposition);
753 754
754 // Helper function to validate a given texture format is settable as in 755 // Helper function to validate a given texture format is settable as in
755 // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and 756 // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and
756 // copyTexSubImage2D. 757 // copyTexSubImage2D.
757 // Generates GL error and returns false if the format is not settable. 758 // Generates GL error and returns false if the format is not settable.
758 bool validateSettableTexFormat(const char* functionName, GC3Denum format); 759 bool validateSettableTexFormat(const char* functionName, GC3Denum format);
759 760
760 // Helper function to validate compressed texture data is correct size 761 // Helper function to validate compressed texture data is correct size
761 // for the given format and dimensions. 762 // for the given format and dimensions.
762 bool validateCompressedTexFuncData(const char* functionName, 763 bool validateCompressedTexFuncData(const char* functionName,
763 GC3Dsizei width, GC3Dsizei height, 764 GC3Dsizei width, GC3Dsizei height,
764 GC3Denum format, ArrayBufferView* pixels) ; 765 GC3Denum format, ArrayBufferView* pixels);
765 766
766 // Helper function for validating compressed texture formats. 767 // Helper function for validating compressed texture formats.
767 bool validateCompressedTexFormat(GC3Denum format); 768 bool validateCompressedTexFormat(GC3Denum format);
768 769
769 // Helper function to validate compressed texture dimensions are valid for 770 // Helper function to validate compressed texture dimensions are valid for
770 // the given format. 771 // the given format.
771 bool validateCompressedTexDimensions(const char* functionName, TexFuncValida tionFunctionType, GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei hei ght, GC3Denum format); 772 bool validateCompressedTexDimensions(const char* functionName, TexFuncValida tionFunctionType, GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei hei ght, GC3Denum format);
772 773
773 // Helper function to validate compressed texture dimensions are valid for 774 // Helper function to validate compressed texture dimensions are valid for
774 // the given format. 775 // the given format.
775 bool validateCompressedTexSubDimensions(const char* functionName, GC3Denum t arget, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, 776 bool validateCompressedTexSubDimensions(const char* functionName, GC3Denum t arget, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
776 GC3Dsizei width, GC3Dsizei height, G C3Denum format, WebGLTexture*); 777 GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*);
777 778
778 // Helper function to validate mode for draw{Arrays/Elements}. 779 // Helper function to validate mode for draw{Arrays/Elements}.
779 bool validateDrawMode(const char* functionName, GC3Denum); 780 bool validateDrawMode(const char* functionName, GC3Denum);
780 781
781 // Helper function to validate if front/back stencilMask and stencilFunc set tings are the same. 782 // Helper function to validate if front/back stencilMask and stencilFunc set tings are the same.
782 bool validateStencilSettings(const char* functionName); 783 bool validateStencilSettings(const char* functionName);
783 784
784 // Helper function to validate stencil or depth func. 785 // Helper function to validate stencil or depth func.
785 bool validateStencilOrDepthFunc(const char* functionName, GC3Denum); 786 bool validateStencilOrDepthFunc(const char* functionName, GC3Denum);
786 787
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 844
844 // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions. 845 // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions.
845 // Return false if caller should return without further processing. 846 // Return false if caller should return without further processing.
846 bool deleteObject(WebGLObject*); 847 bool deleteObject(WebGLObject*);
847 848
848 // Helper function for bind* (bindBuffer, bindTexture, etc) and useProgram. 849 // Helper function for bind* (bindBuffer, bindTexture, etc) and useProgram.
849 // If the object has already been deleted, set deleted to true upon return. 850 // If the object has already been deleted, set deleted to true upon return.
850 // Return false if caller should return without further processing. 851 // Return false if caller should return without further processing.
851 bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& dele ted); 852 bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& dele ted);
852 853
853 void dispatchContextLostEvent(Timer<WebGLRenderingContext>*); 854 void dispatchContextLostEvent(Timer<WebGLRenderingContextBase>*);
854 // Helper for restoration after context lost. 855 // Helper for restoration after context lost.
855 void maybeRestoreContext(Timer<WebGLRenderingContext>*); 856 void maybeRestoreContext(Timer<WebGLRenderingContextBase>*);
856 857
857 // Determine if we are running privileged code in the browser, for example, 858 // Determine if we are running privileged code in the browser, for example,
858 // a Safari or Chrome extension. 859 // a Safari or Chrome extension.
859 bool allowPrivilegedExtensions() const; 860 bool allowPrivilegedExtensions() const;
860 861
861 enum ConsoleDisplayPreference { 862 enum ConsoleDisplayPreference {
862 DisplayInConsole, 863 DisplayInConsole,
863 DontDisplayInConsole 864 DontDisplayInConsole
864 }; 865 };
865 866
(...skipping 25 matching lines...) Expand all
891 void restoreCurrentTexture2D(); 892 void restoreCurrentTexture2D();
892 893
893 virtual void multisamplingChanged(bool); 894 virtual void multisamplingChanged(bool);
894 895
895 void findNewMaxEnabledAttribIndex(); 896 void findNewMaxEnabledAttribIndex();
896 void findNewMaxNonDefaultTextureUnit(); 897 void findNewMaxNonDefaultTextureUnit();
897 898
898 friend class WebGLStateRestorer; 899 friend class WebGLStateRestorer;
899 friend class WebGLRenderingContextEvictionManager; 900 friend class WebGLRenderingContextEvictionManager;
900 901
901 static Vector<WebGLRenderingContext*>& activeContexts(); 902 static Vector<WebGLRenderingContextBase*>& activeContexts();
902 static Vector<WebGLRenderingContext*>& forciblyEvictedContexts(); 903 static Vector<WebGLRenderingContextBase*>& forciblyEvictedContexts();
903 904
904 static void activateContext(WebGLRenderingContext*); 905 static void activateContext(WebGLRenderingContextBase*);
905 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList ); 906 static void deactivateContext(WebGLRenderingContextBase*, bool addToInactive List);
906 static void willDestroyContext(WebGLRenderingContext*); 907 static void willDestroyContext(WebGLRenderingContextBase*);
907 static void forciblyLoseOldestContext(const String& reason); 908 static void forciblyLoseOldestContext(const String& reason);
908 static IntSize oldestContextSize(); 909 static IntSize oldestContextSize();
910
911 static GraphicsContext3D::Attributes adjustAttributes(const GraphicsContext3 D::Attributes&, Settings*);
909 }; 912 };
910 913
911 } // namespace WebCore 914 } // namespace WebCore
912 915
913 #endif 916 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698