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/extensions/Xcomposite.h> | 6 #include <X11/extensions/Xcomposite.h> |
7 } | 7 } |
8 | 8 |
9 #include "ui/gl/gl_image_glx.h" | 9 #include "ui/gl/gl_image_glx.h" |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 } | 42 } |
43 | 43 |
44 } // namespace anonymous | 44 } // namespace anonymous |
45 | 45 |
46 GLImageGLX::GLImageGLX(gfx::PluginWindowHandle window) | 46 GLImageGLX::GLImageGLX(gfx::PluginWindowHandle window) |
47 : display_(gfx::GetXDisplay()), | 47 : display_(gfx::GetXDisplay()), |
48 window_(window), | 48 window_(window), |
49 pixmap_(0), | 49 pixmap_(0), |
50 glx_pixmap_(0) {} | 50 glx_pixmap_(0) {} |
51 | 51 |
52 GLImageGLX::~GLImageGLX() { Destroy(); } | 52 GLImageGLX::~GLImageGLX() { |
53 DCHECK_EQ(0u, glx_pixmap_); | |
54 DCHECK_EQ(0u, pixmap_); | |
55 } | |
53 | 56 |
54 bool GLImageGLX::Initialize() { | 57 bool GLImageGLX::Initialize() { |
55 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { | 58 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { |
56 LOG(ERROR) << "GLX_EXT_texture_from_pixmap not supported."; | 59 LOG(ERROR) << "GLX_EXT_texture_from_pixmap not supported."; |
57 return false; | 60 return false; |
58 } | 61 } |
59 | 62 |
60 XWindowAttributes attributes; | 63 XWindowAttributes attributes; |
61 if (!XGetWindowAttributes(display_, window_, &attributes)) { | 64 if (!XGetWindowAttributes(display_, window_, &attributes)) { |
62 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; | 65 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; |
(...skipping 28 matching lines...) Expand all Loading... | |
91 LOG(ERROR) << "glXChooseFBConfig failed."; | 94 LOG(ERROR) << "glXChooseFBConfig failed."; |
92 return false; | 95 return false; |
93 } | 96 } |
94 if (!num_elements) { | 97 if (!num_elements) { |
95 LOG(ERROR) << "glXChooseFBConfig returned 0 elements."; | 98 LOG(ERROR) << "glXChooseFBConfig returned 0 elements."; |
96 return false; | 99 return false; |
97 } | 100 } |
98 | 101 |
99 // Create backing pixmap reference. | 102 // Create backing pixmap reference. |
100 pixmap_ = XCompositeNameWindowPixmap(display_, window_); | 103 pixmap_ = XCompositeNameWindowPixmap(display_, window_); |
104 if (!pixmap_) { | |
105 LOG(ERROR) << "XCompositeNameWindowPixmap failed."; | |
106 return false; | |
107 } | |
reveman
2014/06/02 14:34:47
This doesn't help in any way as XCompositeNameWind
sohanjg
2014/06/02 15:39:10
Done.
| |
101 | 108 |
102 XID root = 0; | 109 XID root = 0; |
103 int x = 0; | 110 int x = 0; |
104 int y = 0; | 111 int y = 0; |
105 unsigned int width = 0; | 112 unsigned int width = 0; |
106 unsigned int height = 0; | 113 unsigned int height = 0; |
107 unsigned int bw = 0; | 114 unsigned int bw = 0; |
108 unsigned int depth = 0; | 115 unsigned int depth = 0; |
109 if (!XGetGeometry( | 116 if (!XGetGeometry( |
110 display_, pixmap_, &root, &x, &y, &width, &height, &bw, &depth)) { | 117 display_, pixmap_, &root, &x, &y, &width, &height, &bw, &depth)) { |
111 LOG(ERROR) << "XGetGeometry failed for pixmap " << pixmap_ << "."; | 118 LOG(ERROR) << "XGetGeometry failed for pixmap " << pixmap_ << "."; |
112 return false; | 119 return false; |
113 } | 120 } |
114 | 121 |
115 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, | 122 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, |
116 GLX_TEXTURE_FORMAT_EXT, TextureFormat(visinfo->depth), | 123 GLX_TEXTURE_FORMAT_EXT, TextureFormat(visinfo->depth), |
117 0}; | 124 0}; |
118 glx_pixmap_ = | 125 glx_pixmap_ = |
119 glXCreatePixmap(display_, *config.get(), pixmap_, pixmap_attribs); | 126 glXCreatePixmap(display_, *config.get(), pixmap_, pixmap_attribs); |
120 if (!glx_pixmap_) { | 127 if (!glx_pixmap_) { |
121 LOG(ERROR) << "glXCreatePixmap failed."; | 128 LOG(ERROR) << "glXCreatePixmap failed."; |
122 return false; | 129 return false; |
123 } | 130 } |
124 | 131 |
125 size_ = gfx::Size(width, height); | 132 size_ = gfx::Size(width, height); |
126 return true; | 133 return true; |
127 } | 134 } |
128 | 135 |
129 void GLImageGLX::Destroy() { | 136 void GLImageGLX::Destroy(bool have_context) { |
130 if (glx_pixmap_) { | 137 if (glx_pixmap_) { |
131 glXDestroyGLXPixmap(display_, glx_pixmap_); | 138 glXDestroyGLXPixmap(display_, glx_pixmap_); |
132 glx_pixmap_ = 0; | 139 glx_pixmap_ = 0; |
133 } | 140 } |
134 if (pixmap_) { | 141 if (pixmap_) { |
135 XFreePixmap(display_, pixmap_); | 142 XFreePixmap(display_, pixmap_); |
136 pixmap_ = 0; | 143 pixmap_ = 0; |
137 } | 144 } |
138 } | 145 } |
139 | 146 |
(...skipping 12 matching lines...) Expand all Loading... | |
152 } | 159 } |
153 | 160 |
154 void GLImageGLX::ReleaseTexImage(unsigned target) { | 161 void GLImageGLX::ReleaseTexImage(unsigned target) { |
155 DCHECK(glx_pixmap_); | 162 DCHECK(glx_pixmap_); |
156 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target); | 163 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target); |
157 | 164 |
158 glXReleaseTexImageEXT(display_, glx_pixmap_, GLX_FRONT_LEFT_EXT); | 165 glXReleaseTexImageEXT(display_, glx_pixmap_, GLX_FRONT_LEFT_EXT); |
159 } | 166 } |
160 | 167 |
161 } // namespace gfx | 168 } // namespace gfx |
OLD | NEW |