| OLD | NEW |
| 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 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void frontFace(GC3Denum mode); | 166 void frontFace(GC3Denum mode); |
| 167 void generateMipmap(GC3Denum target); | 167 void generateMipmap(GC3Denum target); |
| 168 | 168 |
| 169 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GC3Duint index, E
xceptionCode&); | 169 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GC3Duint index, E
xceptionCode&); |
| 170 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GC3Duint index,
ExceptionCode&); | 170 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GC3Duint index,
ExceptionCode&); |
| 171 bool getAttachedShaders(WebGLProgram*, Vector<RefPtr<WebGLShader> >&, Except
ionCode&); | 171 bool getAttachedShaders(WebGLProgram*, Vector<RefPtr<WebGLShader> >&, Except
ionCode&); |
| 172 GC3Dint getAttribLocation(WebGLProgram*, const String& name); | 172 GC3Dint getAttribLocation(WebGLProgram*, const String& name); |
| 173 WebGLGetInfo getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCo
de&); | 173 WebGLGetInfo getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCo
de&); |
| 174 PassRefPtr<WebGLContextAttributes> getContextAttributes(); | 174 PassRefPtr<WebGLContextAttributes> getContextAttributes(); |
| 175 GC3Denum getError(); | 175 GC3Denum getError(); |
| 176 WebGLExtension* getExtension(const String& name); | 176 PassRefPtr<WebGLExtension> getExtension(const String& name); |
| 177 WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum att
achment, GC3Denum pname, ExceptionCode&); | 177 WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum att
achment, GC3Denum pname, ExceptionCode&); |
| 178 WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&); | 178 WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&); |
| 179 WebGLGetInfo getProgramParameter(WebGLProgram*, GC3Denum pname, ExceptionCod
e&); | 179 WebGLGetInfo getProgramParameter(WebGLProgram*, GC3Denum pname, ExceptionCod
e&); |
| 180 String getProgramInfoLog(WebGLProgram*, ExceptionCode&); | 180 String getProgramInfoLog(WebGLProgram*, ExceptionCode&); |
| 181 WebGLGetInfo getRenderbufferParameter(GC3Denum target, GC3Denum pname, Excep
tionCode&); | 181 WebGLGetInfo getRenderbufferParameter(GC3Denum target, GC3Denum pname, Excep
tionCode&); |
| 182 WebGLGetInfo getShaderParameter(WebGLShader*, GC3Denum pname, ExceptionCode&
); | 182 WebGLGetInfo getShaderParameter(WebGLShader*, GC3Denum pname, ExceptionCode&
); |
| 183 String getShaderInfoLog(WebGLShader*, ExceptionCode&); | 183 String getShaderInfoLog(WebGLShader*, ExceptionCode&); |
| 184 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GC3Denum sha
derType, GC3Denum precisionType, ExceptionCode&); | 184 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GC3Denum sha
derType, GC3Denum precisionType, ExceptionCode&); |
| 185 String getShaderSource(WebGLShader*, ExceptionCode&); | 185 String getShaderSource(WebGLShader*, ExceptionCode&); |
| 186 Vector<String> getSupportedExtensions(); | 186 Vector<String> getSupportedExtensions(); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // like GL_FLOAT, GL_INT, etc. | 360 // like GL_FLOAT, GL_INT, etc. |
| 361 unsigned int sizeInBytes(GC3Denum type); | 361 unsigned int sizeInBytes(GC3Denum type); |
| 362 | 362 |
| 363 // Check if each enabled vertex attribute is bound to a buffer. | 363 // Check if each enabled vertex attribute is bound to a buffer. |
| 364 bool validateRenderingState(); | 364 bool validateRenderingState(); |
| 365 | 365 |
| 366 bool validateWebGLObject(const char*, WebGLObject*); | 366 bool validateWebGLObject(const char*, WebGLObject*); |
| 367 | 367 |
| 368 // Adds a compressed texture format. | 368 // Adds a compressed texture format. |
| 369 void addCompressedTextureFormat(GC3Denum); | 369 void addCompressedTextureFormat(GC3Denum); |
| 370 void removeAllCompressedTextureFormats(); |
| 370 | 371 |
| 371 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, Exc
eptionCode&); | 372 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, Exc
eptionCode&); |
| 372 | 373 |
| 373 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GC3Denum target, WebGLRenderb
uffer*); | 374 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GC3Denum target, WebGLRenderb
uffer*); |
| 374 | 375 |
| 375 RefPtr<GraphicsContext3D> m_context; | 376 RefPtr<GraphicsContext3D> m_context; |
| 376 RefPtr<WebGLContextGroup> m_contextGroup; | 377 RefPtr<WebGLContextGroup> m_contextGroup; |
| 377 | 378 |
| 378 // Structure for rendering to a DrawingBuffer, instead of directly | 379 // Structure for rendering to a DrawingBuffer, instead of directly |
| 379 // to the back-buffer of m_context. | 380 // to the back-buffer of m_context. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack; | 497 GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack; |
| 497 | 498 |
| 498 bool m_isGLES2NPOTStrict; | 499 bool m_isGLES2NPOTStrict; |
| 499 bool m_isDepthStencilSupported; | 500 bool m_isDepthStencilSupported; |
| 500 bool m_isRobustnessEXTSupported; | 501 bool m_isRobustnessEXTSupported; |
| 501 | 502 |
| 502 bool m_synthesizedErrorsToConsole; | 503 bool m_synthesizedErrorsToConsole; |
| 503 int m_numGLErrorsToConsoleAllowed; | 504 int m_numGLErrorsToConsoleAllowed; |
| 504 | 505 |
| 505 // Enabled extension objects. | 506 // Enabled extension objects. |
| 506 OwnPtr<EXTFragDepth> m_extFragDepth; | 507 RefPtr<EXTFragDepth> m_extFragDepth; |
| 507 OwnPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; | 508 RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; |
| 508 OwnPtr<OESTextureFloat> m_oesTextureFloat; | 509 RefPtr<OESTextureFloat> m_oesTextureFloat; |
| 509 OwnPtr<OESTextureFloatLinear> m_oesTextureFloatLinear; | 510 RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear; |
| 510 OwnPtr<OESTextureHalfFloat> m_oesTextureHalfFloat; | 511 RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat; |
| 511 OwnPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear; | 512 RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear; |
| 512 OwnPtr<OESStandardDerivatives> m_oesStandardDerivatives; | 513 RefPtr<OESStandardDerivatives> m_oesStandardDerivatives; |
| 513 OwnPtr<OESVertexArrayObject> m_oesVertexArrayObject; | 514 RefPtr<OESVertexArrayObject> m_oesVertexArrayObject; |
| 514 OwnPtr<OESElementIndexUint> m_oesElementIndexUint; | 515 RefPtr<OESElementIndexUint> m_oesElementIndexUint; |
| 515 OwnPtr<WebGLLoseContext> m_webglLoseContext; | 516 RefPtr<WebGLLoseContext> m_webglLoseContext; |
| 516 OwnPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo; | 517 RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo; |
| 517 OwnPtr<WebGLDebugShaders> m_webglDebugShaders; | 518 RefPtr<WebGLDebugShaders> m_webglDebugShaders; |
| 518 OwnPtr<WebGLDrawBuffers> m_webglDrawBuffers; | 519 RefPtr<WebGLDrawBuffers> m_webglDrawBuffers; |
| 519 OwnPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC; | 520 RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC; |
| 520 OwnPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC; | 521 RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC; |
| 521 OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; | 522 RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; |
| 522 OwnPtr<WebGLDepthTexture> m_webglDepthTexture; | 523 RefPtr<WebGLDepthTexture> m_webglDepthTexture; |
| 523 | 524 |
| 524 class ExtensionTracker { | 525 class ExtensionTracker { |
| 525 public: | 526 public: |
| 526 ExtensionTracker(bool privileged, bool draft, bool prefixed, const char*
* prefixes) | 527 ExtensionTracker(bool privileged, bool draft, bool prefixed, const char*
* prefixes) |
| 527 : m_privileged(privileged) | 528 : m_privileged(privileged) |
| 528 , m_draft(draft) | 529 , m_draft(draft) |
| 529 , m_prefixed(prefixed) | 530 , m_prefixed(prefixed) |
| 530 , m_prefixes(prefixes) | 531 , m_prefixes(prefixes) |
| 531 { | 532 { |
| 532 } | 533 } |
| 533 | 534 |
| 535 virtual ~ExtensionTracker() |
| 536 { |
| 537 } |
| 538 |
| 534 bool getPrefixed() const | 539 bool getPrefixed() const |
| 535 { | 540 { |
| 536 return m_prefixed; | 541 return m_prefixed; |
| 537 } | 542 } |
| 538 | 543 |
| 539 bool getPrivileged() const | 544 bool getPrivileged() const |
| 540 { | 545 { |
| 541 return m_privileged; | 546 return m_privileged; |
| 542 } | 547 } |
| 543 | 548 |
| 544 bool getDraft() const | 549 bool getDraft() const |
| 545 { | 550 { |
| 546 return m_draft; | 551 return m_draft; |
| 547 } | 552 } |
| 548 | 553 |
| 549 bool matchesNameWithPrefixes(const String&) const; | 554 bool matchesNameWithPrefixes(const String&) const; |
| 550 | 555 |
| 551 virtual WebGLExtension* getExtension(WebGLRenderingContext*) const = 0; | 556 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext*)
const = 0; |
| 552 virtual bool supported(WebGLRenderingContext*) const = 0; | 557 virtual bool supported(WebGLRenderingContext*) const = 0; |
| 553 virtual const char* getExtensionName() const = 0; | 558 virtual const char* getExtensionName() const = 0; |
| 559 virtual void loseExtension() = 0; |
| 554 | 560 |
| 555 private: | 561 private: |
| 556 bool m_privileged; | 562 bool m_privileged; |
| 557 bool m_draft; | 563 bool m_draft; |
| 558 bool m_prefixed; | 564 bool m_prefixed; |
| 559 const char** m_prefixes; | 565 const char** m_prefixes; |
| 560 }; | 566 }; |
| 561 | 567 |
| 562 template <typename T> | 568 template <typename T> |
| 563 class TypedExtensionTracker : public ExtensionTracker { | 569 class TypedExtensionTracker : public ExtensionTracker { |
| 564 public: | 570 public: |
| 565 TypedExtensionTracker(OwnPtr<T>& extensionField, bool privileged, bool d
raft, bool prefixed, const char** prefixes) | 571 TypedExtensionTracker(RefPtr<T>& extensionField, bool privileged, bool d
raft, bool prefixed, const char** prefixes) |
| 566 : ExtensionTracker(privileged, draft, prefixed, prefixes) | 572 : ExtensionTracker(privileged, draft, prefixed, prefixes) |
| 567 , m_extensionField(extensionField) | 573 , m_extensionField(extensionField) |
| 568 { | 574 { |
| 569 } | 575 } |
| 570 | 576 |
| 571 virtual WebGLExtension* getExtension(WebGLRenderingContext* context) con
st | 577 ~TypedExtensionTracker() |
| 578 { |
| 579 if (m_extensionField) { |
| 580 m_extensionField->lose(true); |
| 581 m_extensionField = 0; |
| 582 } |
| 583 } |
| 584 |
| 585 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* c
ontext) const |
| 572 { | 586 { |
| 573 if (!m_extensionField) | 587 if (!m_extensionField) |
| 574 m_extensionField = T::create(context); | 588 m_extensionField = T::create(context); |
| 575 | 589 |
| 576 return m_extensionField.get(); | 590 return m_extensionField; |
| 577 } | 591 } |
| 578 | 592 |
| 579 virtual bool supported(WebGLRenderingContext* context) const | 593 virtual bool supported(WebGLRenderingContext* context) const |
| 580 { | 594 { |
| 581 return T::supported(context); | 595 return T::supported(context); |
| 582 } | 596 } |
| 583 | 597 |
| 584 virtual const char* getExtensionName() const | 598 virtual const char* getExtensionName() const |
| 585 { | 599 { |
| 586 return T::getExtensionName(); | 600 return T::getExtensionName(); |
| 587 } | 601 } |
| 588 | 602 |
| 603 virtual void loseExtension() |
| 604 { |
| 605 if (m_extensionField) { |
| 606 m_extensionField->lose(false); |
| 607 if (m_extensionField->isLost()) |
| 608 m_extensionField = 0; |
| 609 } |
| 610 } |
| 611 |
| 589 private: | 612 private: |
| 590 OwnPtr<T>& m_extensionField; | 613 RefPtr<T>& m_extensionField; |
| 591 }; | 614 }; |
| 592 | 615 |
| 593 Vector<ExtensionTracker*> m_extensions; | 616 Vector<ExtensionTracker*> m_extensions; |
| 594 | 617 |
| 595 template <typename T> | 618 template <typename T> |
| 596 void registerExtension(OwnPtr<T>& extensionPtr, bool privileged, bool draft,
bool prefixed, const char** prefixes) | 619 void registerExtension(RefPtr<T>& extensionPtr, bool privileged, bool draft,
bool prefixed, const char** prefixes) |
| 597 { | 620 { |
| 598 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, privilege
d, draft, prefixed, prefixes)); | 621 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, privilege
d, draft, prefixed, prefixes)); |
| 599 } | 622 } |
| 600 | 623 |
| 601 // Errors raised by synthesizeGLError() while the context is lost. | 624 // Errors raised by synthesizeGLError() while the context is lost. |
| 602 Vector<GC3Denum> lost_context_errors_; | 625 Vector<GC3Denum> lost_context_errors_; |
| 603 | 626 |
| 604 // Helpers for getParameter and others | 627 // Helpers for getParameter and others |
| 605 WebGLGetInfo getBooleanParameter(GC3Denum); | 628 WebGLGetInfo getBooleanParameter(GC3Denum); |
| 606 WebGLGetInfo getBooleanArrayParameter(GC3Denum); | 629 WebGLGetInfo getBooleanArrayParameter(GC3Denum); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 static void activateContext(WebGLRenderingContext*); | 872 static void activateContext(WebGLRenderingContext*); |
| 850 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList
); | 873 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList
); |
| 851 static void willDestroyContext(WebGLRenderingContext*); | 874 static void willDestroyContext(WebGLRenderingContext*); |
| 852 static void forciblyLoseOldestContext(const String& reason); | 875 static void forciblyLoseOldestContext(const String& reason); |
| 853 static IntSize oldestContextSize(); | 876 static IntSize oldestContextSize(); |
| 854 }; | 877 }; |
| 855 | 878 |
| 856 } // namespace WebCore | 879 } // namespace WebCore |
| 857 | 880 |
| 858 #endif | 881 #endif |
| OLD | NEW |