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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
OLDNEW
« 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