| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (!m_readFramebufferBinding && m_drawingBuffer) | 136 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 137 m_drawingBuffer->restoreFramebufferBindings(); | 137 m_drawingBuffer->restoreFramebufferBindings(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 DrawingBuffer* m_drawingBuffer; | 141 DrawingBuffer* m_drawingBuffer; |
| 142 Member<WebGLFramebuffer> m_readFramebufferBinding; | 142 Member<WebGLFramebuffer> m_readFramebufferBinding; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { | 145 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { |
| 146 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); | 146 USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); |
| 147 public: | 147 public: |
| 148 ~WebGLRenderingContextBase() override; | 148 ~WebGLRenderingContextBase() override; |
| 149 | 149 |
| 150 virtual unsigned version() const = 0; | 150 virtual unsigned version() const = 0; |
| 151 virtual String contextName() const = 0; | 151 virtual String contextName() const = 0; |
| 152 virtual void registerContextExtensions() = 0; | 152 virtual void registerContextExtensions() = 0; |
| 153 | 153 |
| 154 virtual void initializeNewContext(); | 154 virtual void initializeNewContext(); |
| 155 | 155 |
| 156 static unsigned getWebGLVersion(const CanvasRenderingContext*); | 156 static unsigned getWebGLVersion(const CanvasRenderingContext*); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 GLenum format, GLenum type, DOMArrayBufferView*); | 287 GLenum format, GLenum type, DOMArrayBufferView*); |
| 288 void texImage2D(GLenum target, GLint level, GLint internalformat, | 288 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 289 GLenum format, GLenum type, ImageData*); | 289 GLenum format, GLenum type, ImageData*); |
| 290 void texImage2D(GLenum target, GLint level, GLint internalformat, | 290 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 291 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); | 291 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); |
| 292 void texImage2D(GLenum target, GLint level, GLint internalformat, | 292 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 293 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); | 293 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); |
| 294 void texImage2D(GLenum target, GLint level, GLint internalformat, | 294 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 295 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); | 295 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); |
| 296 void texImage2D(GLenum target, GLint level, GLint internalformat, | 296 void texImage2D(GLenum target, GLint level, GLint internalformat, |
| 297 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap>, Excepti
onState&); | 297 GLenum format, GLenum type, RawPtr<ImageBitmap>, ExceptionState&); |
| 298 | 298 |
| 299 void texParameterf(GLenum target, GLenum pname, GLfloat param); | 299 void texParameterf(GLenum target, GLenum pname, GLfloat param); |
| 300 void texParameteri(GLenum target, GLenum pname, GLint param); | 300 void texParameteri(GLenum target, GLenum pname, GLint param); |
| 301 | 301 |
| 302 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 302 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 303 GLsizei width, GLsizei height, | 303 GLsizei width, GLsizei height, |
| 304 GLenum format, GLenum type, DOMArrayBufferView*); | 304 GLenum format, GLenum type, DOMArrayBufferView*); |
| 305 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 305 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 306 GLenum format, GLenum type, ImageData*); | 306 GLenum format, GLenum type, ImageData*); |
| 307 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 307 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 308 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); | 308 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); |
| 309 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 309 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 310 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); | 310 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); |
| 311 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 311 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 312 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); | 312 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); |
| 313 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 313 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 314 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap>, Excepti
onState&); | 314 GLenum format, GLenum type, RawPtr<ImageBitmap>, ExceptionState&); |
| 315 | 315 |
| 316 void uniform1f(const WebGLUniformLocation*, GLfloat x); | 316 void uniform1f(const WebGLUniformLocation*, GLfloat x); |
| 317 void uniform1fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); | 317 void uniform1fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); |
| 318 void uniform1fv(const WebGLUniformLocation*, Vector<GLfloat>&); | 318 void uniform1fv(const WebGLUniformLocation*, Vector<GLfloat>&); |
| 319 void uniform1i(const WebGLUniformLocation*, GLint x); | 319 void uniform1i(const WebGLUniformLocation*, GLint x); |
| 320 void uniform1iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); | 320 void uniform1iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); |
| 321 void uniform1iv(const WebGLUniformLocation*, Vector<GLint>&); | 321 void uniform1iv(const WebGLUniformLocation*, Vector<GLint>&); |
| 322 void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y); | 322 void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y); |
| 323 void uniform2fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); | 323 void uniform2fv(const WebGLUniformLocation*, const FlexibleFloat32ArrayView&
); |
| 324 void uniform2fv(const WebGLUniformLocation*, Vector<GLfloat>&); | 324 void uniform2fv(const WebGLUniformLocation*, Vector<GLfloat>&); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; | 518 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; |
| 519 #else | 519 #else |
| 520 // The hash set isn't traced, hence the references are effectively | 520 // The hash set isn't traced, hence the references are effectively |
| 521 // weakly kept. Each WebGLContextObject is responsible for detaching | 521 // weakly kept. Each WebGLContextObject is responsible for detaching |
| 522 // itself upon finalization if the WebGLRenderingContextBase hasn't been | 522 // itself upon finalization if the WebGLRenderingContextBase hasn't been |
| 523 // finalized already and detached them via detachAndRemoveAllObjects(). | 523 // finalized already and detached them via detachAndRemoveAllObjects(). |
| 524 // See http://crbug.com/534524 for the details. | 524 // See http://crbug.com/534524 for the details. |
| 525 HashSet<UntracedMember<WebGLContextObject>> m_contextObjects; | 525 HashSet<UntracedMember<WebGLContextObject>> m_contextObjects; |
| 526 #endif | 526 #endif |
| 527 | 527 |
| 528 PersistentWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMes
sageCallbackAdapter; | 528 Member<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap
ter; |
| 529 | 529 |
| 530 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a
nd stored values for ELEMENT_ARRAY_BUFFER | 530 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a
nd stored values for ELEMENT_ARRAY_BUFFER |
| 531 PersistentWillBeMember<WebGLBuffer> m_boundArrayBuffer; | 531 Member<WebGLBuffer> m_boundArrayBuffer; |
| 532 | 532 |
| 533 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_defaultVertexArrayObjec
t; | 533 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; |
| 534 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; | 534 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; |
| 535 bool m_preservedDefaultVAOObjectWrapper; | 535 bool m_preservedDefaultVAOObjectWrapper; |
| 536 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*); | 536 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*); |
| 537 | 537 |
| 538 enum VertexAttribValueType { | 538 enum VertexAttribValueType { |
| 539 Float32ArrayType, | 539 Float32ArrayType, |
| 540 Int32ArrayType, | 540 Int32ArrayType, |
| 541 Uint32ArrayType, | 541 Uint32ArrayType, |
| 542 }; | 542 }; |
| 543 | 543 |
| 544 Vector<VertexAttribValueType> m_vertexAttribType; | 544 Vector<VertexAttribValueType> m_vertexAttribType; |
| 545 unsigned m_maxVertexAttribs; | 545 unsigned m_maxVertexAttribs; |
| 546 void setVertexAttribType(GLuint index, VertexAttribValueType); | 546 void setVertexAttribType(GLuint index, VertexAttribValueType); |
| 547 | 547 |
| 548 PersistentWillBeMember<WebGLProgram> m_currentProgram; | 548 Member<WebGLProgram> m_currentProgram; |
| 549 PersistentWillBeMember<WebGLFramebuffer> m_framebufferBinding; | 549 Member<WebGLFramebuffer> m_framebufferBinding; |
| 550 PersistentWillBeMember<WebGLRenderbuffer> m_renderbufferBinding; | 550 Member<WebGLRenderbuffer> m_renderbufferBinding; |
| 551 PersistentWillBeMember<CHROMIUMValuebuffer> m_valuebufferBinding; | 551 Member<CHROMIUMValuebuffer> m_valuebufferBinding; |
| 552 | 552 |
| 553 PersistentHeapVectorWillBeHeapVector<TextureUnitState> m_textureUnits; | 553 HeapVector<TextureUnitState> m_textureUnits; |
| 554 unsigned long m_activeTextureUnit; | 554 unsigned long m_activeTextureUnit; |
| 555 | 555 |
| 556 Vector<GLenum> m_compressedTextureFormats; | 556 Vector<GLenum> m_compressedTextureFormats; |
| 557 | 557 |
| 558 // Fixed-size cache of reusable image buffers for video texImage2D calls. | 558 // Fixed-size cache of reusable image buffers for video texImage2D calls. |
| 559 class LRUImageBufferCache { | 559 class LRUImageBufferCache { |
| 560 public: | 560 public: |
| 561 LRUImageBufferCache(int capacity); | 561 LRUImageBufferCache(int capacity); |
| 562 // The pointer returned is owned by the image buffer map. | 562 // The pointer returned is owned by the image buffer map. |
| 563 ImageBuffer* imageBuffer(const IntSize&); | 563 ImageBuffer* imageBuffer(const IntSize&); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 DEFINE_INLINE_VIRTUAL_TRACE() { } | 647 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 648 | 648 |
| 649 private: | 649 private: |
| 650 bool m_draft; | 650 bool m_draft; |
| 651 const char* const* m_prefixes; | 651 const char* const* m_prefixes; |
| 652 }; | 652 }; |
| 653 | 653 |
| 654 template <typename T> | 654 template <typename T> |
| 655 class TypedExtensionTracker final : public ExtensionTracker { | 655 class TypedExtensionTracker final : public ExtensionTracker { |
| 656 public: | 656 public: |
| 657 static TypedExtensionTracker<T>* create(PersistentWillBeMember<T>& exten
sionField, ExtensionFlags flags, const char* const* prefixes) | 657 static TypedExtensionTracker<T>* create(Member<T>& extensionField, Exten
sionFlags flags, const char* const* prefixes) |
| 658 { | 658 { |
| 659 return new TypedExtensionTracker<T>(extensionField, flags, prefixes)
; | 659 return new TypedExtensionTracker<T>(extensionField, flags, prefixes)
; |
| 660 } | 660 } |
| 661 | 661 |
| 662 WebGLExtension* getExtension(WebGLRenderingContextBase* context) overrid
e | 662 WebGLExtension* getExtension(WebGLRenderingContextBase* context) overrid
e |
| 663 { | 663 { |
| 664 if (!m_extension) { | 664 if (!m_extension) { |
| 665 m_extension = T::create(context); | 665 m_extension = T::create(context); |
| 666 m_extensionField = m_extension; | 666 m_extensionField = m_extension; |
| 667 } | 667 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 | 690 |
| 691 DEFINE_INLINE_VIRTUAL_TRACE() | 691 DEFINE_INLINE_VIRTUAL_TRACE() |
| 692 { | 692 { |
| 693 visitor->trace(m_extension); | 693 visitor->trace(m_extension); |
| 694 ExtensionTracker::trace(visitor); | 694 ExtensionTracker::trace(visitor); |
| 695 } | 695 } |
| 696 | 696 |
| 697 private: | 697 private: |
| 698 TypedExtensionTracker(PersistentWillBeMember<T>& extensionField, Extensi
onFlags flags, const char* const* prefixes) | 698 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c
onst char* const* prefixes) |
| 699 : ExtensionTracker(flags, prefixes) | 699 : ExtensionTracker(flags, prefixes) |
| 700 , m_extensionField(extensionField) | 700 , m_extensionField(extensionField) |
| 701 { | 701 { |
| 702 } | 702 } |
| 703 | 703 |
| 704 GC_PLUGIN_IGNORE("http://crbug.com/519953") | 704 GC_PLUGIN_IGNORE("http://crbug.com/519953") |
| 705 PersistentWillBeMember<T>& m_extensionField; | 705 Member<T>& m_extensionField; |
| 706 // ExtensionTracker holds it's own reference to the extension to ensure | 706 // ExtensionTracker holds it's own reference to the extension to ensure |
| 707 // that it is not deleted before this object's destructor is called | 707 // that it is not deleted before this object's destructor is called |
| 708 Member<T> m_extension; | 708 Member<T> m_extension; |
| 709 }; | 709 }; |
| 710 | 710 |
| 711 bool m_extensionEnabled[WebGLExtensionNameCount]; | 711 bool m_extensionEnabled[WebGLExtensionNameCount]; |
| 712 PersistentHeapVectorWillBeHeapVector<Member<ExtensionTracker>> m_extensions; | 712 HeapVector<Member<ExtensionTracker>> m_extensions; |
| 713 | 713 |
| 714 template <typename T> | 714 template <typename T> |
| 715 void registerExtension(PersistentWillBeMember<T>& extensionPtr, ExtensionFla
gs flags = ApprovedExtension, const char* const* prefixes = nullptr) | 715 void registerExtension(Member<T>& extensionPtr, ExtensionFlags flags = Appro
vedExtension, const char* const* prefixes = nullptr) |
| 716 { | 716 { |
| 717 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags
, prefixes)); | 717 m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags
, prefixes)); |
| 718 } | 718 } |
| 719 | 719 |
| 720 bool extensionSupportedAndAllowed(const ExtensionTracker*); | 720 bool extensionSupportedAndAllowed(const ExtensionTracker*); |
| 721 | 721 |
| 722 inline bool extensionEnabled(WebGLExtensionName name) | 722 inline bool extensionEnabled(WebGLExtensionName name) |
| 723 { | 723 { |
| 724 return m_extensionEnabled[name]; | 724 return m_extensionEnabled[name]; |
| 725 } | 725 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 #endif | 1103 #endif |
| 1104 }; | 1104 }; |
| 1105 | 1105 |
| 1106 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1106 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
| 1107 | 1107 |
| 1108 } // namespace blink | 1108 } // namespace blink |
| 1109 | 1109 |
| 1110 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1110 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
| 1111 | 1111 |
| 1112 #endif // WebGLRenderingContextBase_h | 1112 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |