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

Unified Diff: media/gpu/surface_texture_gl_owner.cc

Issue 2706653002: Added SurfaceTextureGLOwner to create / own GL objects. (Closed)
Patch Set: stopped including gl_initializer.h Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/gpu/surface_texture_gl_owner.h ('k') | media/gpu/surface_texture_gl_owner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/surface_texture_gl_owner.cc
diff --git a/media/gpu/surface_texture_gl_owner.cc b/media/gpu/surface_texture_gl_owner.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f64ff0d1fa28c5628388fdb8b2558ee501105334
--- /dev/null
+++ b/media/gpu/surface_texture_gl_owner.cc
@@ -0,0 +1,50 @@
+// 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.
+
+#include "media/gpu/surface_texture_gl_owner.h"
+
+#include "base/logging.h"
+#include "ui/gl/scoped_make_current.h"
+
+namespace media {
+
+scoped_refptr<SurfaceTextureGLOwner> SurfaceTextureGLOwner::Create() {
+ GLuint texture_id;
+ glGenTextures(1, &texture_id);
+ if (!texture_id)
+ return nullptr;
+
+ return new SurfaceTextureGLOwner(texture_id);
+}
+
+SurfaceTextureGLOwner::SurfaceTextureGLOwner(GLuint texture_id)
+ : SurfaceTexture(CreateJavaSurfaceTexture(texture_id)),
+ context_(gl::GLContext::GetCurrent()),
+ surface_(gl::GLSurface::GetCurrent()),
+ texture_id_(texture_id) {
+ DCHECK(context_);
+ DCHECK(surface_);
+}
+
+SurfaceTextureGLOwner::~SurfaceTextureGLOwner() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // Make sure that the SurfaceTexture isn't using the GL objects.
+ DestroyJavaObject();
+
+ ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get());
+ if (scoped_make_current.Succeeded()) {
+ glDeleteTextures(1, &texture_id_);
+ DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ }
+}
+
+void SurfaceTextureGLOwner::AttachToGLContext() {
+ NOTIMPLEMENTED();
+}
+
+void SurfaceTextureGLOwner::DetachFromGLContext() {
+ NOTIMPLEMENTED();
+}
+
+} // namespace media
« no previous file with comments | « media/gpu/surface_texture_gl_owner.h ('k') | media/gpu/surface_texture_gl_owner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698