Chromium Code Reviews| 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 unsigned long m_onePlusMaxNonDefaultTextureUnit; | 799 unsigned long m_onePlusMaxNonDefaultTextureUnit; | 
| 800 | 800 | 
| 801 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; | 801 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; | 
| 802 | 802 | 
| 803 enum ExtensionFlags { | 803 enum ExtensionFlags { | 
| 804 ApprovedExtension = 0x00, | 804 ApprovedExtension = 0x00, | 
| 805 // Extension that is behind the draft extensions runtime flag: | 805 // Extension that is behind the draft extensions runtime flag: | 
| 806 DraftExtension = 0x01, | 806 DraftExtension = 0x01, | 
| 807 }; | 807 }; | 
| 808 | 808 | 
| 809 class ExtensionTracker : public GarbageCollected<ExtensionTracker> { | 809 class ExtensionTracker : public GarbageCollected<ExtensionTracker>, | 
| 810 public TraceWrapperBase { | |
| 810 public: | 811 public: | 
| 811 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) | 812 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) | 
| 812 : m_draft(flags & DraftExtension), m_prefixes(prefixes) {} | 813 : m_draft(flags & DraftExtension), m_prefixes(prefixes) {} | 
| 813 | 814 | 
| 814 bool draft() const { return m_draft; } | 815 bool draft() const { return m_draft; } | 
| 815 | 816 | 
| 816 const char* const* prefixes() const; | 817 const char* const* prefixes() const; | 
| 817 bool matchesNameWithPrefixes(const String&) const; | 818 bool matchesNameWithPrefixes(const String&) const; | 
| 818 | 819 | 
| 819 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0; | 820 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0; | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 835 class TypedExtensionTracker final : public ExtensionTracker { | 836 class TypedExtensionTracker final : public ExtensionTracker { | 
| 836 public: | 837 public: | 
| 837 static TypedExtensionTracker<T>* create(Member<T>& extensionField, | 838 static TypedExtensionTracker<T>* create(Member<T>& extensionField, | 
| 838 ExtensionFlags flags, | 839 ExtensionFlags flags, | 
| 839 const char* const* prefixes) { | 840 const char* const* prefixes) { | 
| 840 return new TypedExtensionTracker<T>(extensionField, flags, prefixes); | 841 return new TypedExtensionTracker<T>(extensionField, flags, prefixes); | 
| 841 } | 842 } | 
| 842 | 843 | 
| 843 WebGLExtension* getExtension(WebGLRenderingContextBase* context) override { | 844 WebGLExtension* getExtension(WebGLRenderingContextBase* context) override { | 
| 844 if (!m_extension) { | 845 if (!m_extension) { | 
| 845 m_extension = T::create(context); | 846 m_extension = T::create(context); | 
| 
 
Michael Lippautz
2016/11/30 21:07:38
This lazy creation is the reason we need to trace
 
haraken
2016/12/01 01:44:14
Makes sense. We should not do anything non-trivial
 
 | |
| 846 m_extensionField = m_extension; | 847 m_extensionField = m_extension; | 
| 847 } | 848 } | 
| 848 | 849 | 
| 849 return m_extension; | 850 return m_extension; | 
| 850 } | 851 } | 
| 851 | 852 | 
| 852 bool supported(WebGLRenderingContextBase* context) const override { | 853 bool supported(WebGLRenderingContextBase* context) const override { | 
| 853 return T::supported(context); | 854 return T::supported(context); | 
| 854 } | 855 } | 
| 855 | 856 | 
| 856 const char* extensionName() const override { return T::extensionName(); } | 857 const char* extensionName() const override { return T::extensionName(); } | 
| 857 | 858 | 
| 858 void loseExtension(bool force) override { | 859 void loseExtension(bool force) override { | 
| 859 if (m_extension) { | 860 if (m_extension) { | 
| 860 m_extension->lose(force); | 861 m_extension->lose(force); | 
| 861 if (m_extension->isLost()) | 862 if (m_extension->isLost()) | 
| 862 m_extension = nullptr; | 863 m_extension = nullptr; | 
| 863 } | 864 } | 
| 864 } | 865 } | 
| 865 | 866 | 
| 866 WebGLExtension* getExtensionObjectIfAlreadyEnabled() override { | 867 WebGLExtension* getExtensionObjectIfAlreadyEnabled() override { | 
| 867 return m_extension; | 868 return m_extension; | 
| 868 } | 869 } | 
| 869 | 870 | 
| 870 DEFINE_INLINE_VIRTUAL_TRACE() { | 871 DEFINE_INLINE_VIRTUAL_TRACE() { | 
| 871 visitor->trace(m_extension); | 872 visitor->trace(m_extension); | 
| 872 ExtensionTracker::trace(visitor); | 873 ExtensionTracker::trace(visitor); | 
| 873 } | 874 } | 
| 874 | 875 | 
| 876 DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() { | |
| 877 visitor->traceWrappers(m_extension); | |
| 878 } | |
| 879 | |
| 875 private: | 880 private: | 
| 876 TypedExtensionTracker(Member<T>& extensionField, | 881 TypedExtensionTracker(Member<T>& extensionField, | 
| 877 ExtensionFlags flags, | 882 ExtensionFlags flags, | 
| 878 const char* const* prefixes) | 883 const char* const* prefixes) | 
| 879 : ExtensionTracker(flags, prefixes), m_extensionField(extensionField) {} | 884 : ExtensionTracker(flags, prefixes), | 
| 885 m_extensionField(extensionField), | |
| 886 m_extension(this, nullptr) {} | |
| 
 
Michael Lippautz
2016/11/30 21:07:38
IIUC, then the TypedExtensionTracker should lazily
 
Ken Russell (switch to Gerrit)
2016/12/02 02:12:26
Yes, I think that's right. Sorry for the complexit
 
 | |
| 880 | 887 | 
| 881 GC_PLUGIN_IGNORE("http://crbug.com/519953") | 888 GC_PLUGIN_IGNORE("http://crbug.com/519953") | 
| 882 Member<T>& m_extensionField; | 889 Member<T>& m_extensionField; | 
| 883 // ExtensionTracker holds it's own reference to the extension to ensure | 890 // ExtensionTracker holds it's own reference to the extension to ensure | 
| 884 // that it is not deleted before this object's destructor is called | 891 // that it is not deleted before this object's destructor is called | 
| 885 Member<T> m_extension; | 892 TraceWrapperMember<T> m_extension; | 
| 886 }; | 893 }; | 
| 887 | 894 | 
| 888 bool m_extensionEnabled[WebGLExtensionNameCount]; | 895 bool m_extensionEnabled[WebGLExtensionNameCount]; | 
| 889 HeapVector<TraceWrapperMember<ExtensionTracker>> m_extensions; | 896 HeapVector<TraceWrapperMember<ExtensionTracker>> m_extensions; | 
| 890 | 897 | 
| 891 template <typename T> | 898 template <typename T> | 
| 892 void registerExtension(Member<T>& extensionPtr, | 899 void registerExtension(Member<T>& extensionPtr, | 
| 893 ExtensionFlags flags = ApprovedExtension, | 900 ExtensionFlags flags = ApprovedExtension, | 
| 894 const char* const* prefixes = nullptr) { | 901 const char* const* prefixes = nullptr) { | 
| 895 m_extensions.append(TraceWrapperMember<ExtensionTracker>( | 902 m_extensions.append(TraceWrapperMember<ExtensionTracker>( | 
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 context, | 1675 context, | 
| 1669 context->is3d(), | 1676 context->is3d(), | 
| 1670 context.is3d()); | 1677 context.is3d()); | 
| 1671 | 1678 | 
| 1672 } // namespace blink | 1679 } // namespace blink | 
| 1673 | 1680 | 
| 1674 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 1681 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 
| 1675 blink::WebGLRenderingContextBase::TextureUnitState); | 1682 blink::WebGLRenderingContextBase::TextureUnitState); | 
| 1676 | 1683 | 
| 1677 #endif // WebGLRenderingContextBase_h | 1684 #endif // WebGLRenderingContextBase_h | 
| OLD | NEW |