Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: ui/base/x/x11_util.cc

Issue 1429083002: gl_surface_egl: ensure off and on screen surfaces use the same EGLConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | ui/base/x/x11_util_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "ui/gfx/geometry/insets.h" 46 #include "ui/gfx/geometry/insets.h"
47 #include "ui/gfx/geometry/point.h" 47 #include "ui/gfx/geometry/point.h"
48 #include "ui/gfx/geometry/point_conversions.h" 48 #include "ui/gfx/geometry/point_conversions.h"
49 #include "ui/gfx/geometry/rect.h" 49 #include "ui/gfx/geometry/rect.h"
50 #include "ui/gfx/geometry/size.h" 50 #include "ui/gfx/geometry/size.h"
51 #include "ui/gfx/image/image_skia.h" 51 #include "ui/gfx/image/image_skia.h"
52 #include "ui/gfx/image/image_skia_rep.h" 52 #include "ui/gfx/image/image_skia_rep.h"
53 #include "ui/gfx/skia_util.h" 53 #include "ui/gfx/skia_util.h"
54 #include "ui/gfx/x/x11_error_tracker.h" 54 #include "ui/gfx/x/x11_error_tracker.h"
55 55
56 #if !defined(OS_CHROMEOS)
57 #include "base/command_line.h"
58 #include "ui/gfx/x/x11_switches.h"
59 #endif
60
56 #if defined(OS_FREEBSD) 61 #if defined(OS_FREEBSD)
57 #include <sys/sysctl.h> 62 #include <sys/sysctl.h>
58 #include <sys/types.h> 63 #include <sys/types.h>
59 #endif 64 #endif
60 65
61 namespace ui { 66 namespace ui {
62 67
63 namespace { 68 namespace {
64 69
65 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) { 70 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) {
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 LOG(WARNING) 1407 LOG(WARNING)
1403 << "X error received: " 1408 << "X error received: "
1404 << "serial " << error_event.serial << ", " 1409 << "serial " << error_event.serial << ", "
1405 << "error_code " << static_cast<int>(error_event.error_code) 1410 << "error_code " << static_cast<int>(error_event.error_code)
1406 << " (" << error_str << "), " 1411 << " (" << error_str << "), "
1407 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1412 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1408 << "minor_code " << static_cast<int>(error_event.minor_code) 1413 << "minor_code " << static_cast<int>(error_event.minor_code)
1409 << " (" << request_str << ")"; 1414 << " (" << request_str << ")";
1410 } 1415 }
1411 1416
1417 #if !defined(OS_CHROMEOS)
1418 void ChooseVisualForWindow(Visual** visual, int* depth) {
1419 static Visual* s_visual = NULL;
1420 static int s_depth = 0;
1421
1422 if (!s_visual) {
1423 XDisplay* display = gfx::GetXDisplay();
1424 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False);
1425
1426 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1427 switches::kEnableTransparentVisuals) &&
1428 XGetSelectionOwner(display, NET_WM_CM_S0) != None) {
1429 // Choose the first ARGB8888 visual
1430 XVisualInfo visual_template;
1431 visual_template.screen = 0;
1432
1433 int visuals_len;
1434 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo(
1435 display, VisualScreenMask, &visual_template, &visuals_len));
1436 for (int i = 0; i < visuals_len; ++i) {
1437 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In
1438 // gdkvisual-x11.cc, they look for this specific visual and use it for
1439 // all their alpha channel using needs.
1440 //
1441 // TODO(erg): While the following does find a valid visual, some GL
1442 // drivers
1443 // don't believe that this has an alpha channel. According to marcheu@,
1444 // this should work on open source driver though. (It doesn't work with
1445 // NVidia's binaries currently.) http://crbug.com/369209
1446 const XVisualInfo& info = visual_list[i];
1447 if (info.depth == 32 && info.visual->red_mask == 0xff0000 &&
1448 info.visual->green_mask == 0x00ff00 &&
1449 info.visual->blue_mask == 0x0000ff) {
1450 s_visual = info.visual;
1451 s_depth = info.depth;
1452 break;
1453 }
1454 }
1455 } else {
1456 XWindowAttributes windowAttribs;
1457 Window root = XDefaultRootWindow(display);
1458 Status status = XGetWindowAttributes(display, root, &windowAttribs);
1459 DCHECK(status != 0);
1460 s_visual = windowAttribs.visual;
1461 s_depth = windowAttribs.depth;
1462 }
1463 } // !s_visual
1464
1465 DCHECK(s_visual);
1466 DCHECK(s_depth > 0);
1467
1468 if (visual)
1469 *visual = s_visual;
1470 if (depth)
1471 *depth = s_depth;
1472 }
1473 #endif
1474
1412 // ---------------------------------------------------------------------------- 1475 // ----------------------------------------------------------------------------
1413 // End of x11_util_internal.h 1476 // End of x11_util_internal.h
1414 1477
1415 1478
1416 } // namespace ui 1479 } // namespace ui
OLDNEW
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | ui/base/x/x11_util_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698