Use shared_from_this in GlTextureBuffer::GetReadView, GetWriteView
This ensures that the callbacks in GlTextureView won't call an expired object, even if user code holds a GlTextureView after releasing the buffer. Note that GlTextureBuffer is not always held by a shared_ptr, but it always is when GpuBuffer calls GetRead/WriteView on it. An alternative solution would have been to have GpuBuffer pass its shared_ptr<GlTextureBuffer> to the view method, which could have been implemented with some compile-time logic to detect whether the method expects such an argument. However, that doesn't seem necessary. PiperOrigin-RevId: 489611843
This commit is contained in:
committed by
Copybara-Service
parent
bbd5da7971
commit
eb8ef1ace0
@@ -35,7 +35,8 @@ class GlCalculatorHelperImpl;
|
||||
// Implements a GPU memory buffer as an OpenGL texture. For internal use.
|
||||
class GlTextureBuffer
|
||||
: public internal::GpuBufferStorageImpl<
|
||||
GlTextureBuffer, internal::ViewProvider<GlTextureView>> {
|
||||
GlTextureBuffer, internal::ViewProvider<GlTextureView>>,
|
||||
public std::enable_shared_from_this<GlTextureBuffer> {
|
||||
public:
|
||||
// This is called when the texture buffer is deleted. It is passed a sync
|
||||
// token created at that time on the GlContext. If the GlTextureBuffer has
|
||||
|
||||
Reference in New Issue
Block a user