| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if (!m_readFramebufferBinding && m_drawingBuffer) | 145 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 146 m_drawingBuffer->restoreFramebufferBindings(); | 146 m_drawingBuffer->restoreFramebufferBindings(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 DrawingBuffer* m_drawingBuffer; | 150 DrawingBuffer* m_drawingBuffer; |
| 151 Member<WebGLFramebuffer> m_readFramebufferBinding; | 151 Member<WebGLFramebuffer> m_readFramebufferBinding; |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { | 154 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { |
| 155 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); | 155 USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); |
| 156 public: | 156 public: |
| 157 ~WebGLRenderingContextBase() override; | 157 ~WebGLRenderingContextBase() override; |
| 158 | 158 |
| 159 virtual unsigned version() const = 0; | 159 virtual unsigned version() const = 0; |
| 160 virtual String contextName() const = 0; | 160 virtual String contextName() const = 0; |
| 161 virtual void registerContextExtensions() = 0; | 161 virtual void registerContextExtensions() = 0; |
| 162 | 162 |
| 163 virtual void initializeNewContext(); | 163 virtual void initializeNewContext(); |
| 164 | 164 |
| 165 static unsigned getWebGLVersion(const CanvasRenderingContext*); | 165 static unsigned getWebGLVersion(const CanvasRenderingContext*); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 GLenum format, GLenum type, DOMArrayBufferView*); | 296 GLenum format, GLenum type, DOMArrayBufferView*); |
| 297 void texImage2D(GLenum target, GLint level, GLint internalformat, | 297 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 298 GLenum format, GLenum type, ImageData*); | 298 GLenum format, GLenum type, ImageData*); |
| 299 void texImage2D(GLenum target, GLint level, GLint internalformat, | 299 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 300 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); | 300 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); |
| 301 void texImage2D(GLenum target, GLint level, GLint internalformat, | 301 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 302 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); | 302 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); |
| 303 void texImage2D(GLenum target, GLint level, GLint internalformat, | 303 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 304 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); | 304 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); |
| 305 void texImage2D(GLenum target, GLint level, GLint internalformat, | 305 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 306 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap>, Excepti
onState&); | 306 GLenum format, GLenum type, RawPtr<ImageBitmap>, ExceptionState&); |
| 307 | 307 |
| 308 void texParameterf(GLenum target, GLenum pname, GLfloat param); | 308 void texParameterf(GLenum target, GLenum pname, GLfloat param); |
| 309 void texParameteri(GLenum target, GLenum pname, GLint param); | 309 void texParameteri(GLenum target, GLenum pname, GLint param); |
| 310 | 310 |
| 311 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 311 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 312 GLsizei width, GLsizei height, | 312 GLsizei width, GLsizei height, |
| 313 GLenum format, GLenum type, DOMArrayBufferView*); | 313 GLenum format, GLenum type, DOMArrayBufferView*); |
| 314 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 314 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 315 GLenum format, GLenum type, ImageData*); | 315 GLenum format, GLenum type, ImageData*); |
| 316 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 316 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 317 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); | 317 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); |
| 318 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 318 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 319 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); | 319 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); |
| 320 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 320 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 321 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); | 321 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); |
| 322 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 322 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 323 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap>, Excepti
onState&); | 323 GLenum format, GLenum type, RawPtr<ImageBitmap>, ExceptionState&); |
| 324 | 324 |
| 325 void uniform1f(const WebGLUniformLocation*, GLfloat x); | 325 void uniform1f(const WebGLUniformLocation*, GLfloat x); |
| 326 void uniform1fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); | 326 void uniform1fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); |
| 327 void uniform1fv(const WebGLUniformLocation*, Vector<GLfloat>&); | 327 void uniform1fv(const WebGLUniformLocation*, Vector<GLfloat>&); |
| 328 void uniform1i(const WebGLUniformLocation*, GLint x); | 328 void uniform1i(const WebGLUniformLocation*, GLint x); |
| 329 void uniform1iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); | 329 void uniform1iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); |
| 330 void uniform1iv(const WebGLUniformLocation*, Vector<GLint>&); | 330 void uniform1iv(const WebGLUniformLocation*, Vector<GLint>&); |
| 331 void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y); | 331 void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y); |
| 332 void uniform2fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); | 332 void uniform2fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); |
| 333 void uniform2fv(const WebGLUniformLocation*, Vector<GLfloat>&); | 333 void uniform2fv(const WebGLUniformLocation*, Vector<GLfloat>&); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; | 530 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; |
| 531 #else | 531 #else |
| 532 // The hash set isn't traced, hence the references are effectively | 532 // The hash set isn't traced, hence the references are effectively |
| 533 // weakly kept. Each WebGLContextObject is responsible for detaching | 533 // weakly kept. Each WebGLContextObject is responsible for detaching |
| 534 // itself upon finalization if the WebGLRenderingContextBase hasn't been | 534 // itself upon finalization if the WebGLRenderingContextBase hasn't been |
| 535 // finalized already and detached them via detachAndRemoveAllObjects(). | 535 // finalized already and detached them via detachAndRemoveAllObjects(). |
| 536 // See http://crbug.com/534524 for the details. | 536 // See http://crbug.com/534524 for the details. |
| 537 HashSet<UntracedMember<WebGLContextObject>> m_contextObjects; | 537 HashSet<UntracedMember<WebGLContextObject>> m_contextObjects; |
| 538 #endif | 538 #endif |
| 539 | 539 |
| 540 PersistentWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallb
ackAdapter; | 540 Member<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; |
| 541 PersistentWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMes
sageCallbackAdapter; | 541 Member<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap
ter; |
| 542 | 542 |
| 543 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a
nd stored values for ELEMENT_ARRAY_BUFFER | 543 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a
nd stored values for ELEMENT_ARRAY_BUFFER |
| 544 PersistentWillBeMember<WebGLBuffer> m_boundArrayBuffer; | 544 Member<WebGLBuffer> m_boundArrayBuffer; |
| 545 | 545 |
| 546 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_defaultVertexArrayObjec
t; | 546 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; |
| 547 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; | 547 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; |
| 548 bool m_preservedDefaultVAOObjectWrapper; | 548 bool m_preservedDefaultVAOObjectWrapper; |
| 549 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*); | 549 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*); |
| 550 | 550 |
| 551 enum VertexAttribValueType { | 551 enum VertexAttribValueType { |
| 552 Float32ArrayType, | 552 Float32ArrayType, |
| 553 Int32ArrayType, | 553 Int32ArrayType, |
| 554 Uint32ArrayType, | 554 Uint32ArrayType, |
| 555 }; | 555 }; |
| 556 | 556 |
| 557 Vector<VertexAttribValueType> m_vertexAttribType; | 557 Vector<VertexAttribValueType> m_vertexAttribType; |
| 558 unsigned m_maxVertexAttribs; | 558 unsigned m_maxVertexAttribs; |
| 559 void setVertexAttribType(GLuint index, VertexAttribValueType); | 559 void setVertexAttribType(GLuint index, VertexAttribValueType); |
| 560 | 560 |
| 561 PersistentWillBeMember<WebGLProgram> m_currentProgram; | 561 Member<WebGLProgram> m_currentProgram; |
| 562 PersistentWillBeMember<WebGLFramebuffer> m_framebufferBinding; | 562 Member<WebGLFramebuffer> m_framebufferBinding; |
| 563 PersistentWillBeMember<WebGLRenderbuffer> m_renderbufferBinding; | 563 Member<WebGLRenderbuffer> m_renderbufferBinding; |
| 564 PersistentWillBeMember<CHROMIUMValuebuffer> m_valuebufferBinding; | 564 Member<CHROMIUMValuebuffer> m_valuebufferBinding; |
| 565 | 565 |
| 566 PersistentHeapVectorWillBeHeapVector<TextureUnitState> m_textureUnits; | 566 HeapVector<TextureUnitState> m_textureUnits; |
| 567 unsigned long m_activeTextureUnit; | 567 unsigned long m_activeTextureUnit; |
| 568 | 568 |
| 569 Vector<GLenum> m_compressedTextureFormats; | 569 Vector<GLenum> m_compressedTextureFormats; |
| 570 | 570 |
| 571 // Fixed-size cache of reusable image buffers for video texImage2D calls. | 571 // Fixed-size cache of reusable image buffers for video texImage2D calls. |
| 572 class LRUImageBufferCache { | 572 class LRUImageBufferCache { |
| 573 public: | 573 public: |
| 574 LRUImageBufferCache(int capacity); | 574 LRUImageBufferCache(int capacity); |
| 575 // The pointer returned is owned by the image buffer map. | 575 // The pointer returned is owned by the image buffer map. |
| 576 ImageBuffer* imageBuffer(const IntSize&); | 576 ImageBuffer* imageBuffer(const IntSize&); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 DEFINE_INLINE_VIRTUAL_TRACE() { } | 660 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 661 | 661 |
| 662 private: | 662 private: |
| 663 bool m_draft; | 663 bool m_draft; |
| 664 const char* const* m_prefixes; | 664 const char* const* m_prefixes; |
| 665 }; | 665 }; |
| 666 | 666 |
| 667 template <typename T> | 667 template <typename T> |
| 668 class TypedExtensionTracker final : public ExtensionTracker { | 668 class TypedExtensionTracker final : public ExtensionTracker { |
| 669 public: | 669 public: |
| 670 static TypedExtensionTracker<T>* create(PersistentWillBeMember<T>& exten
sionField, ExtensionFlags flags, const char* const* prefixes) | 670 static TypedExtensionTracker<T>* create(Member<T>& extensionField, Exten
sionFlags flags, const char* const* prefixes) |
| 671 { | 671 { |
| 672 return new TypedExtensionTracker<T>(extensionField, flags, prefixes)
; | 672 return new TypedExtensionTracker<T>(extensionField, flags, prefixes)
; |
| 673 } | 673 } |
| 674 | 674 |
| 675 WebGLExtension* getExtension(WebGLRenderingContextBase* context) overrid
e | 675 WebGLExtension* getExtension(WebGLRenderingContextBase* context) overrid
e |
| 676 { | 676 { |
| 677 if (!m_extension) { | 677 if (!m_extension) { |
| 678 m_extension = T::create(context); | 678 m_extension = T::create(context); |
| 679 m_extensionField = m_extension; | 679 m_extensionField = m_extension; |
| 680 } | 680 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 DEFINE_INLINE_VIRTUAL_TRACE() | 704 DEFINE_INLINE_VIRTUAL_TRACE() |
| 705 { | 705 { |
| 706 visitor->trace(m_extension); | 706 visitor->trace(m_extension); |
| 707 ExtensionTracker::trace(visitor); | 707 ExtensionTracker::trace(visitor); |
| 708 } | 708 } |
| 709 | 709 |
| 710 private: | 710 private: |
| 711 TypedExtensionTracker(PersistentWillBeMember<T>& extensionField, Extensi
onFlags flags, const char* const* prefixes) | 711 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c
onst char* const* prefixes) |
| 712 : ExtensionTracker(flags, prefixes) | 712 : ExtensionTracker(flags, prefixes) |
| 713 , m_extensionField(extensionField) | 713 , m_extensionField(extensionField) |
| 714 { | 714 { |
| 715 } | 715 } |
| 716 | 716 |
| 717 GC_PLUGIN_IGNORE("http://crbug.com/519953") | 717 GC_PLUGIN_IGNORE("http://crbug.com/519953") |
| 718 PersistentWillBeMember<T>& m_extensionField; | 718 Member<T>& m_extensionField; |
| 719 // ExtensionTracker holds it's own reference to the extension to ensure | 719 // ExtensionTracker holds it's own reference to the extension to ensure |
| 720 // that it is not deleted before this object's destructor is called | 720 // that it is not deleted before this object's destructor is called |
| 721 Member<T> m_extension; | 721 Member<T> m_extension; |
| 722 }; | 722 }; |
| 723 | 723 |
| 724 bool m_extensionEnabled[WebGLExtensionNameCount]; | 724 bool m_extensionEnabled[WebGLExtensionNameCount]; |
| 725 PersistentHeapVectorWillBeHeapVector<Member<ExtensionTracker>> m_extensions; | 725 HeapVector<Member<ExtensionTracker>> m_extensions; |
| 726 | 726 |
| 727 template <typename T> | 727 template <typename T> |
| 728 void registerExtension(PersistentWillBeMember<T>& extensionPtr, ExtensionFla
gs flags = ApprovedExtension, const char* const* prefixes = nullptr) | 728 void registerExtension(Member<T>& extensionPtr, ExtensionFlags flags = Appro
vedExtension, const char* const* prefixes = nullptr) |
| 729 { | 729 { |
| 730 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags
, prefixes)); | 730 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags
, prefixes)); |
| 731 } | 731 } |
| 732 | 732 |
| 733 bool extensionSupportedAndAllowed(const ExtensionTracker*); | 733 bool extensionSupportedAndAllowed(const ExtensionTracker*); |
| 734 | 734 |
| 735 inline bool extensionEnabled(WebGLExtensionName name) | 735 inline bool extensionEnabled(WebGLExtensionName name) |
| 736 { | 736 { |
| 737 return m_extensionEnabled[name]; | 737 return m_extensionEnabled[name]; |
| 738 } | 738 } |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 #endif | 1125 #endif |
| 1126 }; | 1126 }; |
| 1127 | 1127 |
| 1128 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1128 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
| 1129 | 1129 |
| 1130 } // namespace blink | 1130 } // namespace blink |
| 1131 | 1131 |
| 1132 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1132 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
| 1133 | 1133 |
| 1134 #endif // WebGLRenderingContextBase_h | 1134 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |