Chromium Code Reviews| Index: media/gpu/surface_texture_gl_owner.h |
| diff --git a/media/gpu/surface_texture_gl_owner.h b/media/gpu/surface_texture_gl_owner.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b3ac17d5f5925afe6c20d379849a491da946d572 |
| --- /dev/null |
| +++ b/media/gpu/surface_texture_gl_owner.h |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_GPU_AVDA_SURFACE_TEXTURE_GL_OWNER_H_ |
| +#define MEDIA_GPU_AVDA_SURFACE_TEXTURE_GL_OWNER_H_ |
|
watk
2017/02/21 23:18:31
remove AVDA
liberato (no reviews please)
2017/02/22 01:22:45
Done.
|
| + |
| +#include "media/gpu/media_gpu_export.h" |
| +#include "ui/gl/android/surface_texture.h" |
| +#include "ui/gl/gl_bindings.h" |
| +#include "ui/gl/gl_context.h" |
| +#include "ui/gl/gl_surface.h" |
| + |
| +namespace media { |
| + |
| +// Handy subclass of SurfaceTexture which creates and maintains ownership of the |
| +// GL texture also. This texture is only destroyed with the object; one may |
| +// ReleaseSurfaceTexture without destroying the GL texture. |
| +class MEDIA_GPU_EXPORT SurfaceTextureGLOwner : public gl::SurfaceTexture { |
|
watk
2017/02/21 23:18:31
This requires that it's deleted on the thread it w
liberato (no reviews please)
2017/02/22 01:22:45
Done.
|
| + public: |
| + // Must be called with a platform gl context current. Creates the GL texture |
| + // using this context, and memorizes it to delete the texture later. |
| + static scoped_refptr<SurfaceTextureGLOwner> Create(); |
| + |
| + // Return the GL texture id that we created. |
| + GLuint texture_id() const { return texture_id_; } |
| + |
| + gl::GLContext* context() const { return context_.get(); } |
| + gl::GLSurface* surface() const { return surface_.get(); } |
| + |
| + // We don't support these. In principle, we could, but they're fairly buggy |
| + // anyway on many devices. |
| + void AttachToGLContext() override; |
| + void DetachFromGLContext() override; |
| + |
| + private: |
| + SurfaceTextureGLOwner(GLuint texture_id); |
| + ~SurfaceTextureGLOwner() override; |
| + |
| + // Context and surface that were used to create |texture_id_|. |
| + scoped_refptr<gl::GLContext> context_; |
| + scoped_refptr<gl::GLSurface> surface_; |
| + |
| + GLuint texture_id_; |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_GPU_AVDA_SURFACE_TEXTURE_GL_OWNER_H_ |