Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 97 |
| 98 return size; | 98 return size; |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace | 101 } // namespace |
| 102 | 102 |
| 103 GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat) | 103 GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat) |
| 104 : glx_pixmap_(0), size_(size), internalformat_(internalformat) {} | 104 : glx_pixmap_(0), size_(size), internalformat_(internalformat) {} |
| 105 | 105 |
| 106 GLImageGLX::~GLImageGLX() { | 106 GLImageGLX::~GLImageGLX() { |
| 107 DCHECK_EQ(0u, glx_pixmap_); | 107 if (glx_pixmap_) { |
| 108 glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_); | |
| 109 glx_pixmap_ = 0; | |
|
reveman
2016/10/27 20:01:44
nit: no need for this in dtor
sandersd (OOO until July 31)
2016/10/27 20:13:09
Done.
| |
| 110 } | |
| 108 } | 111 } |
| 109 | 112 |
| 110 bool GLImageGLX::Initialize(XID pixmap) { | 113 bool GLImageGLX::Initialize(XID pixmap) { |
| 111 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { | 114 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { |
| 112 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported."; | 115 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported."; |
| 113 return false; | 116 return false; |
| 114 } | 117 } |
| 115 | 118 |
| 116 if (!ValidFormat(internalformat_)) { | 119 if (!ValidFormat(internalformat_)) { |
| 117 DVLOG(0) << "Invalid format: " << internalformat_; | 120 DVLOG(0) << "Invalid format: " << internalformat_; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 145 glx_pixmap_ = glXCreatePixmap(gfx::GetXDisplay(), *config.get(), pixmap, | 148 glx_pixmap_ = glXCreatePixmap(gfx::GetXDisplay(), *config.get(), pixmap, |
| 146 pixmap_attribs); | 149 pixmap_attribs); |
| 147 if (!glx_pixmap_) { | 150 if (!glx_pixmap_) { |
| 148 DVLOG(0) << "glXCreatePixmap failed."; | 151 DVLOG(0) << "glXCreatePixmap failed."; |
| 149 return false; | 152 return false; |
| 150 } | 153 } |
| 151 | 154 |
| 152 return true; | 155 return true; |
| 153 } | 156 } |
| 154 | 157 |
| 155 void GLImageGLX::Destroy(bool have_context) { | |
| 156 if (glx_pixmap_) { | |
| 157 glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_); | |
| 158 glx_pixmap_ = 0; | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 gfx::Size GLImageGLX::GetSize() { | 158 gfx::Size GLImageGLX::GetSize() { |
| 163 return size_; | 159 return size_; |
| 164 } | 160 } |
| 165 | 161 |
| 166 unsigned GLImageGLX::GetInternalFormat() { return internalformat_; } | 162 unsigned GLImageGLX::GetInternalFormat() { return internalformat_; } |
| 167 | 163 |
| 168 bool GLImageGLX::BindTexImage(unsigned target) { | 164 bool GLImageGLX::BindTexImage(unsigned target) { |
| 169 if (!glx_pixmap_) | 165 if (!glx_pixmap_) |
| 170 return false; | 166 return false; |
| 171 | 167 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 202 return false; | 198 return false; |
| 203 } | 199 } |
| 204 | 200 |
| 205 void GLImageGLX::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 201 void GLImageGLX::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 206 uint64_t process_tracing_id, | 202 uint64_t process_tracing_id, |
| 207 const std::string& dump_name) { | 203 const std::string& dump_name) { |
| 208 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 | 204 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 |
| 209 } | 205 } |
| 210 | 206 |
| 211 } // namespace gl | 207 } // namespace gl |
| OLD | NEW |