| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/gpu/surface_texture_gl_owner.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ui/gl/scoped_make_current.h" |
| 9 |
| 10 namespace media { |
| 11 |
| 12 scoped_refptr<SurfaceTextureGLOwner> SurfaceTextureGLOwner::Create() { |
| 13 GLuint texture_id; |
| 14 glGenTextures(1, &texture_id); |
| 15 if (!texture_id) |
| 16 return nullptr; |
| 17 |
| 18 return new SurfaceTextureGLOwner(texture_id); |
| 19 } |
| 20 |
| 21 SurfaceTextureGLOwner::SurfaceTextureGLOwner(GLuint texture_id) |
| 22 : SurfaceTexture(CreateJavaSurfaceTexture(texture_id)), |
| 23 context_(gl::GLContext::GetCurrent()), |
| 24 surface_(gl::GLSurface::GetCurrent()), |
| 25 texture_id_(texture_id) { |
| 26 DCHECK(context_); |
| 27 DCHECK(surface_); |
| 28 } |
| 29 |
| 30 SurfaceTextureGLOwner::~SurfaceTextureGLOwner() { |
| 31 DCHECK(thread_checker_.CalledOnValidThread()); |
| 32 // Make sure that the SurfaceTexture isn't using the GL objects. |
| 33 DestroyJavaObject(); |
| 34 |
| 35 ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get()); |
| 36 if (scoped_make_current.Succeeded()) { |
| 37 glDeleteTextures(1, &texture_id_); |
| 38 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 39 } |
| 40 } |
| 41 |
| 42 void SurfaceTextureGLOwner::AttachToGLContext() { |
| 43 NOTIMPLEMENTED(); |
| 44 } |
| 45 |
| 46 void SurfaceTextureGLOwner::DetachFromGLContext() { |
| 47 NOTIMPLEMENTED(); |
| 48 } |
| 49 |
| 50 } // namespace media |
| OLD | NEW |