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

Side by Side Diff: ui/gl/gl_image_egl.cc

Issue 301793003: During image destroy, delete textures only if we have a GL context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Destroy GLImage during ContextGroup destroy Created 6 years, 6 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_image_egl.h" 5 #include "ui/gl/gl_image_egl.h"
6 6
7 #include "ui/gl/gl_surface_egl.h" 7 #include "ui/gl/gl_surface_egl.h"
8 8
9 namespace gfx { 9 namespace gfx {
10 10
11 GLImageEGL::GLImageEGL(gfx::Size size) 11 GLImageEGL::GLImageEGL(gfx::Size size)
12 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {} 12 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {}
13 13
14 GLImageEGL::~GLImageEGL() { Destroy(); } 14 GLImageEGL::~GLImageEGL() {
15 Destroy(false);
reveman 2014/05/29 16:30:34 No call to Destroy in dtor please. Instead verify
16 }
15 17
16 bool GLImageEGL::Initialize(EGLenum target, 18 bool GLImageEGL::Initialize(EGLenum target,
17 EGLClientBuffer buffer, 19 EGLClientBuffer buffer,
18 const EGLint* attrs) { 20 const EGLint* attrs) {
19 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 21 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
20 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), 22 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
21 EGL_NO_CONTEXT, 23 EGL_NO_CONTEXT,
22 target, 24 target,
23 buffer, 25 buffer,
24 attrs); 26 attrs);
25 if (egl_image_ == EGL_NO_IMAGE_KHR) { 27 if (egl_image_ == EGL_NO_IMAGE_KHR) {
26 EGLint error = eglGetError(); 28 EGLint error = eglGetError();
27 LOG(ERROR) << "Error creating EGLImage: " << error; 29 LOG(ERROR) << "Error creating EGLImage: " << error;
28 return false; 30 return false;
29 } 31 }
30 32
31 return true; 33 return true;
32 } 34 }
33 35
34 void GLImageEGL::Destroy() { 36 void GLImageEGL::Destroy(bool have_context) {
35 if (egl_image_ != EGL_NO_IMAGE_KHR) { 37 if (egl_image_ != EGL_NO_IMAGE_KHR) {
36 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 38 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
37 egl_image_ = EGL_NO_IMAGE_KHR; 39 egl_image_ = EGL_NO_IMAGE_KHR;
38 } 40 }
39 } 41 }
40 42
41 gfx::Size GLImageEGL::GetSize() { return size_; } 43 gfx::Size GLImageEGL::GetSize() { return size_; }
42 44
43 bool GLImageEGL::BindTexImage(unsigned target) { 45 bool GLImageEGL::BindTexImage(unsigned target) {
44 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); 46 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
45 glEGLImageTargetTexture2DOES(target, egl_image_); 47 glEGLImageTargetTexture2DOES(target, egl_image_);
46 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 48 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
47 return true; 49 return true;
48 } 50 }
49 51
50 } // namespace gfx 52 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698