OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_surface_osmesa_x11.h" | 5 #include "ui/gl/gl_surface_osmesa_x11.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "ui/gfx/x/x11_types.h" | 12 #include "ui/gfx/x/x11_types.h" |
13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
15 | 15 |
16 namespace gl { | 16 namespace gl { |
17 | 17 |
18 GLSurfaceOSMesaX11::GLSurfaceOSMesaX11(gfx::AcceleratedWidget window) | 18 GLSurfaceOSMesaX11::GLSurfaceOSMesaX11(gfx::AcceleratedWidget window) |
19 : GLSurfaceOSMesa(SURFACE_OSMESA_BGRA, gfx::Size(1, 1)), | 19 : GLSurfaceOSMesa( |
| 20 GLSurfaceFormat(SURFACE_OSMESA_BGRA), gfx::Size(1, 1)), |
20 xdisplay_(gfx::GetXDisplay()), | 21 xdisplay_(gfx::GetXDisplay()), |
21 window_graphics_context_(0), | 22 window_graphics_context_(0), |
22 window_(window), | 23 window_(window), |
23 pixmap_graphics_context_(0), | 24 pixmap_graphics_context_(0), |
24 pixmap_(0) { | 25 pixmap_(0) { |
25 DCHECK(xdisplay_); | 26 DCHECK(xdisplay_); |
26 DCHECK(window_); | 27 DCHECK(window_); |
27 } | 28 } |
28 | 29 |
29 // static | 30 // static |
30 bool GLSurfaceOSMesaX11::InitializeOneOff() { | 31 bool GLSurfaceOSMesaX11::InitializeOneOff() { |
31 static bool initialized = false; | 32 static bool initialized = false; |
32 if (initialized) | 33 if (initialized) |
33 return true; | 34 return true; |
34 | 35 |
35 if (!gfx::GetXDisplay()) { | 36 if (!gfx::GetXDisplay()) { |
36 LOG(ERROR) << "XOpenDisplay failed."; | 37 LOG(ERROR) << "XOpenDisplay failed."; |
37 return false; | 38 return false; |
38 } | 39 } |
39 | 40 |
40 initialized = true; | 41 initialized = true; |
41 return true; | 42 return true; |
42 } | 43 } |
43 | 44 |
44 bool GLSurfaceOSMesaX11::Initialize(GLSurface::Format format) { | 45 bool GLSurfaceOSMesaX11::Initialize(GLSurfaceFormat format) { |
45 if (!GLSurfaceOSMesa::Initialize(format)) | 46 if (!GLSurfaceOSMesa::Initialize(format)) |
46 return false; | 47 return false; |
47 | 48 |
48 window_graphics_context_ = XCreateGC(xdisplay_, window_, 0, NULL); | 49 window_graphics_context_ = XCreateGC(xdisplay_, window_, 0, NULL); |
49 if (!window_graphics_context_) { | 50 if (!window_graphics_context_) { |
50 LOG(ERROR) << "XCreateGC failed."; | 51 LOG(ERROR) << "XCreateGC failed."; |
51 Destroy(); | 52 Destroy(); |
52 return false; | 53 return false; |
53 } | 54 } |
54 | 55 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 height, x, y); | 174 height, x, y); |
174 | 175 |
175 return gfx::SwapResult::SWAP_ACK; | 176 return gfx::SwapResult::SWAP_ACK; |
176 } | 177 } |
177 | 178 |
178 GLSurfaceOSMesaX11::~GLSurfaceOSMesaX11() { | 179 GLSurfaceOSMesaX11::~GLSurfaceOSMesaX11() { |
179 Destroy(); | 180 Destroy(); |
180 } | 181 } |
181 | 182 |
182 } // namespace gl | 183 } // namespace gl |
OLD | NEW |