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

Side by Side Diff: ui/gl/gl_surface_osmesa_x11.cc

Issue 2616723002: Refactor GL surface format handling (Closed)
Patch Set: Fix copyright notice on new files Created 3 years, 11 months 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 | « ui/gl/gl_surface_osmesa_x11.h ('k') | ui/gl/gl_surface_wgl.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 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(GLSurfaceFormat::PIXEL_LAYOUT_BGRA),
21 gfx::Size(1, 1)),
20 xdisplay_(gfx::GetXDisplay()), 22 xdisplay_(gfx::GetXDisplay()),
21 window_graphics_context_(0), 23 window_graphics_context_(0),
22 window_(window), 24 window_(window),
23 pixmap_graphics_context_(0), 25 pixmap_graphics_context_(0),
24 pixmap_(0) { 26 pixmap_(0) {
25 DCHECK(xdisplay_); 27 DCHECK(xdisplay_);
26 DCHECK(window_); 28 DCHECK(window_);
27 } 29 }
28 30
29 // static 31 // static
30 bool GLSurfaceOSMesaX11::InitializeOneOff() { 32 bool GLSurfaceOSMesaX11::InitializeOneOff() {
31 static bool initialized = false; 33 static bool initialized = false;
32 if (initialized) 34 if (initialized)
33 return true; 35 return true;
34 36
35 if (!gfx::GetXDisplay()) { 37 if (!gfx::GetXDisplay()) {
36 LOG(ERROR) << "XOpenDisplay failed."; 38 LOG(ERROR) << "XOpenDisplay failed.";
37 return false; 39 return false;
38 } 40 }
39 41
40 initialized = true; 42 initialized = true;
41 return true; 43 return true;
42 } 44 }
43 45
44 bool GLSurfaceOSMesaX11::Initialize(GLSurface::Format format) { 46 bool GLSurfaceOSMesaX11::Initialize(GLSurfaceFormat format) {
45 if (!GLSurfaceOSMesa::Initialize(format)) 47 if (!GLSurfaceOSMesa::Initialize(format))
46 return false; 48 return false;
47 49
48 window_graphics_context_ = XCreateGC(xdisplay_, window_, 0, NULL); 50 window_graphics_context_ = XCreateGC(xdisplay_, window_, 0, NULL);
49 if (!window_graphics_context_) { 51 if (!window_graphics_context_) {
50 LOG(ERROR) << "XCreateGC failed."; 52 LOG(ERROR) << "XCreateGC failed.";
51 Destroy(); 53 Destroy();
52 return false; 54 return false;
53 } 55 }
54 56
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 height, x, y); 175 height, x, y);
174 176
175 return gfx::SwapResult::SWAP_ACK; 177 return gfx::SwapResult::SWAP_ACK;
176 } 178 }
177 179
178 GLSurfaceOSMesaX11::~GLSurfaceOSMesaX11() { 180 GLSurfaceOSMesaX11::~GLSurfaceOSMesaX11() {
179 Destroy(); 181 Destroy();
180 } 182 }
181 183
182 } // namespace gl 184 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_osmesa_x11.h ('k') | ui/gl/gl_surface_wgl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698