blob: f64ff0d1fa28c5628388fdb8b2558ee501105334 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
|