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

Side by Side Diff: ui/gl/gl_image_glx.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: review comments addressed. Created 6 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 extern "C" { 5 extern "C" {
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 } 7 }
8 8
9 #include "ui/gl/gl_image_glx.h" 9 #include "ui/gl/gl_image_glx.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 return size; 105 return size;
106 } 106 }
107 107
108 } // namespace anonymous 108 } // namespace anonymous
109 109
110 GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat) 110 GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat)
111 : glx_pixmap_(0), size_(size), internalformat_(internalformat) { 111 : glx_pixmap_(0), size_(size), internalformat_(internalformat) {
112 } 112 }
113 113
114 GLImageGLX::~GLImageGLX() { Destroy(); } 114 GLImageGLX::~GLImageGLX() {
115 DCHECK_EQ(0u, glx_pixmap_);
116 }
115 117
116 bool GLImageGLX::Initialize(XID pixmap) { 118 bool GLImageGLX::Initialize(XID pixmap) {
117 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { 119 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) {
118 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported."; 120 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported.";
119 return false; 121 return false;
120 } 122 }
121 123
122 if (!ValidFormat(internalformat_)) { 124 if (!ValidFormat(internalformat_)) {
123 DVLOG(0) << "Invalid format: " << internalformat_; 125 DVLOG(0) << "Invalid format: " << internalformat_;
124 return false; 126 return false;
(...skipping 28 matching lines...) Expand all
153 glx_pixmap_ = glXCreatePixmap( 155 glx_pixmap_ = glXCreatePixmap(
154 gfx::GetXDisplay(), *config.get(), pixmap, pixmap_attribs); 156 gfx::GetXDisplay(), *config.get(), pixmap, pixmap_attribs);
155 if (!glx_pixmap_) { 157 if (!glx_pixmap_) {
156 DVLOG(0) << "glXCreatePixmap failed."; 158 DVLOG(0) << "glXCreatePixmap failed.";
157 return false; 159 return false;
158 } 160 }
159 161
160 return true; 162 return true;
161 } 163 }
162 164
163 void GLImageGLX::Destroy() { 165 void GLImageGLX::Destroy(bool have_context) {
164 if (glx_pixmap_) { 166 if (glx_pixmap_) {
165 glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_); 167 glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_);
166 glx_pixmap_ = 0; 168 glx_pixmap_ = 0;
167 } 169 }
168 } 170 }
169 171
170 gfx::Size GLImageGLX::GetSize() { return size_; } 172 gfx::Size GLImageGLX::GetSize() { return size_; }
171 173
172 bool GLImageGLX::BindTexImage(unsigned target) { 174 bool GLImageGLX::BindTexImage(unsigned target) {
173 if (!glx_pixmap_) 175 if (!glx_pixmap_) {
176 DVLOG(0) << "No GLXPixMap to bind";
reveman 2014/07/24 16:22:03 "Uninitialized image cannot be bound to texture"
sohanjg 2014/07/25 10:54:21 Done.
174 return false; 177 return false;
178 }
175 179
176 // Requires TEXTURE_2D target. 180 // Requires TEXTURE_2D target.
177 if (target != GL_TEXTURE_2D) 181 if (target != GL_TEXTURE_2D)
178 return false; 182 return false;
179 183
180 glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0); 184 glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0);
181 return true; 185 return true;
182 } 186 }
183 187
184 void GLImageGLX::ReleaseTexImage(unsigned target) { 188 void GLImageGLX::ReleaseTexImage(unsigned target) {
185 DCHECK(glx_pixmap_); 189 if (!glx_pixmap_) {
190 DVLOG(0) << "No GLXPixMap to release";
reveman 2014/07/24 16:22:03 "Uninitialized image cannot be released from textu
sohanjg 2014/07/25 10:54:21 Done.
191 return false;
192 }
186 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target); 193 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target);
187 194
188 glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT); 195 glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT);
189 } 196 }
190 197
191 } // namespace gfx 198 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698