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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLObject.h

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Fixed WebGLContextObject::validate. Made WebGLExtension non-finalized. Created 4 years 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
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
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 GLuint result = object->object(); 53 GLuint result = object->object();
54 DCHECK(result); 54 DCHECK(result);
55 return result; 55 return result;
56 } 56 }
57 57
58 class WebGLObject : public GarbageCollectedFinalized<WebGLObject>, 58 class WebGLObject : public GarbageCollectedFinalized<WebGLObject>,
59 public ScriptWrappable { 59 public ScriptWrappable {
60 WTF_MAKE_NONCOPYABLE(WebGLObject); 60 WTF_MAKE_NONCOPYABLE(WebGLObject);
61 61
62 public: 62 public:
63 // We can't call virtual functions like deleteObjectImpl in this class's
64 // destructor; doing so results in a pure virtual function call. Further,
65 // making this destructor non-virtual is complicated with respect to
66 // Oilpan tracing. Therefore this destructor is declared virtual, but is
67 // empty, and the code that would have gone into its body is called by
68 // subclasses via runDestructor().
63 virtual ~WebGLObject(); 69 virtual ~WebGLObject();
64 70
65 // deleteObject may not always delete the OpenGL resource. For programs and 71 // deleteObject may not always delete the OpenGL resource. For programs and
66 // shaders, deletion is delayed until they are no longer attached. 72 // shaders, deletion is delayed until they are no longer attached.
67 // FIXME: revisit this when resource sharing between contexts are implemented. 73 // FIXME: revisit this when resource sharing between contexts are implemented.
68 void deleteObject(gpu::gles2::GLES2Interface*); 74 void deleteObject(gpu::gles2::GLES2Interface*);
69 75
70 void onAttached() { ++m_attachmentCount; } 76 void onAttached() { ++m_attachmentCount; }
71 void onDetached(gpu::gles2::GLES2Interface*); 77 void onDetached(gpu::gles2::GLES2Interface*);
72 78
73 // This indicates whether the client side issue a delete call already, not 79 // This indicates whether the client side issue a delete call already, not
74 // whether the OpenGL resource is deleted. 80 // whether the OpenGL resource is deleted.
75 // object()==0 indicates the OpenGL resource is deleted. 81 // object()==0 indicates the OpenGL resource is deleted.
76 bool isDeleted() { return m_deleted; } 82 bool isDeleted() { return m_deleted; }
77 83
78 // True if this object belongs to the group or context. 84 // True if this object belongs to the group or context.
79 virtual bool validate(const WebGLContextGroup*, 85 virtual bool validate(const WebGLContextGroup*,
80 const WebGLRenderingContextBase*) const = 0; 86 const WebGLRenderingContextBase*) const = 0;
81 virtual bool hasObject() const = 0; 87 virtual bool hasObject() const = 0;
82 88
89 // WebGLObjects are eagerly finalized, and the WebGLRenderingContextBase
90 // is specifically not. This is done in order to allow WebGLObjects to
91 // refer back to their owning context in their destructor to delete their
92 // resources if they are GC'd before the context is.
93 EAGERLY_FINALIZE();
94 DECLARE_EAGER_FINALIZATION_OPERATOR_NEW();
haraken 2016/12/05 05:15:59 Do you need this macro?
Ken Russell (switch to Gerrit) 2016/12/05 06:03:40 Yes, we absolutely do. The entire point of this CL
haraken 2016/12/05 06:08:40 EAGERLY_FINALIZE() is needed but DECLARE_EAGER_FIN
Ken Russell (switch to Gerrit) 2016/12/05 06:36:20 Thanks for the clarification. Will fix. (Is there
95
83 DEFINE_INLINE_VIRTUAL_TRACE() {} 96 DEFINE_INLINE_VIRTUAL_TRACE() {}
84 97
98 DECLARE_VIRTUAL_TRACE_WRAPPERS();
99
85 protected: 100 protected:
86 // To allow WebGL[2]RenderingContextBase to call visitChildDOMWrappers. 101 // To allow WebGL[2]RenderingContextBase to call visitChildDOMWrappers.
87 friend class WebGLRenderingContextBase; 102 friend class WebGLRenderingContextBase;
88 friend class WebGL2RenderingContextBase; 103 friend class WebGL2RenderingContextBase;
89 104
90 explicit WebGLObject(WebGLRenderingContextBase*); 105 explicit WebGLObject(WebGLRenderingContextBase*);
91 106
92 // deleteObjectImpl should be only called once to delete the OpenGL resource. 107 // deleteObjectImpl should be only called once to delete the OpenGL resource.
93 // After calling deleteObjectImpl, hasObject() should return false. 108 // After calling deleteObjectImpl, hasObject() should return false.
94 virtual void deleteObjectImpl(gpu::gles2::GLES2Interface*) = 0; 109 virtual void deleteObjectImpl(gpu::gles2::GLES2Interface*) = 0;
95 110
96 virtual bool hasGroupOrContext() const = 0; 111 virtual bool hasGroupOrContext() const = 0;
97 112
113 // Return the current number of context losses associated with this
114 // object's context group (if it's a shared object), or its
115 // context's context group (if it's a per-context object).
116 virtual uint32_t currentNumberOfContextLosses() const = 0;
117
118 uint32_t cachedNumberOfContextLosses() const;
119
98 void detach(); 120 void detach();
99 void detachAndDeleteObject(); 121 void detachAndDeleteObject();
100 122
101 virtual gpu::gles2::GLES2Interface* getAGLInterface() const = 0; 123 virtual gpu::gles2::GLES2Interface* getAGLInterface() const = 0;
102 124
103 virtual void visitChildDOMWrappers(v8::Isolate*, 125 virtual void visitChildDOMWrappers(v8::Isolate*,
104 const v8::Persistent<v8::Object>&) {} 126 const v8::Persistent<v8::Object>&) {}
105 127
128 // Used by leaf subclasses to run the destruction sequence -- what would
129 // be in the destructor of the base class, if it could be. Must be called
130 // no more than once.
131 void runDestructor();
132
133 // Indicates to subclasses that the destructor is being run.
134 bool destructionInProgress() const;
135
106 private: 136 private:
137 // This was the number of context losses of the object's associated
138 // WebGLContextGroup at the time this object was created. Contexts
139 // no longer refer to all the objects that they ever created, so
140 // it's necessary to check this count when validating each object.
141 uint32_t m_cachedNumberOfContextLosses;
142
107 unsigned m_attachmentCount; 143 unsigned m_attachmentCount;
144
145 // Indicates whether the WebGL context's deletion function for this
146 // object (deleteBuffer, deleteTexture, etc.) has been called.
108 bool m_deleted; 147 bool m_deleted;
148
149 // Indicates whether the destructor has been entered and we therefore
150 // need to be careful in subclasses to not touch other on-heap objects.
151 bool m_destructionInProgress;
109 }; 152 };
110 153
111 } // namespace blink 154 } // namespace blink
112 155
113 #endif // WebGLObject_h 156 #endif // WebGLObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698