OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gfx/x/x11_types.h" | 5 #include "ui/gfx/x/x11_types.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
| 9 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "ui/gfx/x/x11_switches.h" |
10 | 12 |
11 namespace gfx { | 13 namespace gfx { |
12 | 14 |
13 XDisplay* GetXDisplay() { | 15 XDisplay* GetXDisplay() { |
14 static XDisplay* display = NULL; | 16 static XDisplay* display = NULL; |
15 if (!display) | 17 if (!display) |
16 display = XOpenDisplay(NULL); | 18 display = OpenNewXDisplay(); |
17 return display; | 19 return display; |
18 } | 20 } |
19 | 21 |
| 22 XDisplay* OpenNewXDisplay() { |
| 23 #if defined(OS_CHROMEOS) |
| 24 return XOpenDisplay(NULL); |
| 25 #else |
| 26 std::string display_str = base::CommandLine::ForCurrentProcess()-> |
| 27 GetSwitchValueASCII(switches::kX11Display); |
| 28 return XOpenDisplay(display_str.empty() ? NULL : display_str.c_str()); |
| 29 #endif |
| 30 } |
| 31 |
20 void PutARGBImage(XDisplay* display, | 32 void PutARGBImage(XDisplay* display, |
21 void* visual, int depth, | 33 void* visual, int depth, |
22 XID pixmap, void* pixmap_gc, | 34 XID pixmap, void* pixmap_gc, |
23 const uint8* data, | 35 const uint8* data, |
24 int width, int height) { | 36 int width, int height) { |
25 PutARGBImage(display, | 37 PutARGBImage(display, |
26 visual, depth, | 38 visual, depth, |
27 pixmap, pixmap_gc, | 39 pixmap, pixmap_gc, |
28 data, width, height, | 40 data, width, height, |
29 0, 0, // src_x, src_y | 41 0, 0, // src_x, src_y |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 free(orig_bitmap16); | 161 free(orig_bitmap16); |
150 } else { | 162 } else { |
151 LOG(FATAL) << "Sorry, we don't support your visual depth without " | 163 LOG(FATAL) << "Sorry, we don't support your visual depth without " |
152 "Xrender support (depth:" << depth | 164 "Xrender support (depth:" << depth |
153 << " bpp:" << pixmap_bpp << ")"; | 165 << " bpp:" << pixmap_bpp << ")"; |
154 } | 166 } |
155 } | 167 } |
156 | 168 |
157 } // namespace gfx | 169 } // namespace gfx |
158 | 170 |
OLD | NEW |