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 "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 #include "ui/gl/gl_image_glx.h" | 12 #include "ui/gl/gl_image_glx.h" |
13 #include "ui/gl/gl_surface_glx.h" | 13 #include "ui/gl/gl_surface_glx.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // scoped_ptr functor for XFree(). Use as follows: | |
20 // scoped_ptr<XVisualInfo, ScopedPtrXFree> foo(...); | |
21 // where "XVisualInfo" is any X type that is freed with XFree. | |
22 struct ScopedPtrXFree { | |
23 void operator()(void* x) const { ::XFree(x); } | |
24 }; | |
25 | |
26 bool ValidFormat(unsigned internalformat) { | 19 bool ValidFormat(unsigned internalformat) { |
27 switch (internalformat) { | 20 switch (internalformat) { |
28 case GL_RGB: | 21 case GL_RGB: |
29 case GL_RGBA: | 22 case GL_RGBA: |
30 return true; | 23 return true; |
31 default: | 24 default: |
32 return false; | 25 return false; |
33 } | 26 } |
34 } | 27 } |
35 | 28 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 127 |
135 DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap)); | 128 DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap)); |
136 DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString()); | 129 DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString()); |
137 | 130 |
138 int config_attribs[] = { | 131 int config_attribs[] = { |
139 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, | 132 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, |
140 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT, | 133 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT, |
141 BindToTextureFormat(internalformat_), GL_TRUE, | 134 BindToTextureFormat(internalformat_), GL_TRUE, |
142 0}; | 135 0}; |
143 int num_elements = 0; | 136 int num_elements = 0; |
144 scoped_ptr<GLXFBConfig, ScopedPtrXFree> config( | 137 gfx::XScopedPtr<GLXFBConfig> config( |
145 glXChooseFBConfig(gfx::GetXDisplay(), | 138 glXChooseFBConfig(gfx::GetXDisplay(), DefaultScreen(gfx::GetXDisplay()), |
146 DefaultScreen(gfx::GetXDisplay()), | 139 config_attribs, &num_elements)); |
147 config_attribs, | |
148 &num_elements)); | |
149 if (!config.get()) { | 140 if (!config.get()) { |
150 DVLOG(0) << "glXChooseFBConfig failed."; | 141 DVLOG(0) << "glXChooseFBConfig failed."; |
151 return false; | 142 return false; |
152 } | 143 } |
153 if (!num_elements) { | 144 if (!num_elements) { |
154 DVLOG(0) << "glXChooseFBConfig returned 0 elements."; | 145 DVLOG(0) << "glXChooseFBConfig returned 0 elements."; |
155 return false; | 146 return false; |
156 } | 147 } |
157 | 148 |
158 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, | 149 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 193 |
203 bool GLImageGLX::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 194 bool GLImageGLX::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
204 int z_order, | 195 int z_order, |
205 OverlayTransform transform, | 196 OverlayTransform transform, |
206 const Rect& bounds_rect, | 197 const Rect& bounds_rect, |
207 const RectF& crop_rect) { | 198 const RectF& crop_rect) { |
208 return false; | 199 return false; |
209 } | 200 } |
210 | 201 |
211 } // namespace gfx | 202 } // namespace gfx |
OLD | NEW |