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

Side by Side Diff: media/gpu/surface_texture_gl_owner.cc

Issue 2706653002: Added SurfaceTextureGLOwner to create / own GL objects. (Closed)
Patch Set: made destruction the same as before Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(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 // Make sure that the SurfaceTexture isn't using the GL objects.
32 DestroyJavaObject();
33
34 ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get());
35 if (scoped_make_current.Succeeded()) {
36 glDeleteTextures(1, &texture_id_);
37 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
38 }
39 }
40
41 void SurfaceTextureGLOwner::AttachToGLContext() {
42 NOTIMPLEMENTED();
43 }
44
45 void SurfaceTextureGLOwner::DetachFromGLContext() {
46 NOTIMPLEMENTED();
47 }
48
49 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698