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

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

Issue 1652873002: Android: Use virtualized context only for those with compatible config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 10 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
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 #include "ui/gl/gl_context_osmesa.h" 5 #include "ui/gl/gl_context_osmesa.h"
6 6
7 #include <GL/osmesa.h> 7 #include <GL/osmesa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gfx/geometry/size.h" 10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/gl_surface.h" 12 #include "ui/gl/gl_surface.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 GLContextOSMesa::GLContextOSMesa(GLShareGroup* share_group) 16 GLContextOSMesa::GLContextOSMesa(GLShareGroup* share_group)
17 : GLContextReal(share_group), 17 : GLContextReal(share_group),
18 context_(nullptr), 18 context_(nullptr),
19 is_released_(false) { 19 is_released_(false) {
20 } 20 }
21 21
22 bool GLContextOSMesa::Initialize(GLSurface* compatible_surface, 22 bool GLContextOSMesa::Initialize(GLSurface* compatible_surface,
23 GpuPreference gpu_preference) { 23 GpuPreference gpu_preference) {
24 DCHECK(!context_); 24 DCHECK(!context_);
25 25
26 OSMesaContext share_handle = static_cast<OSMesaContext>( 26 OSMesaContext share_handle = static_cast<OSMesaContext>(
27 share_group() ? share_group()->GetHandle() : nullptr); 27 share_group() ? share_group()->GetHandle() : nullptr);
28 28
29 GLuint format = compatible_surface->GetFormat(); 29 GLuint format = 0;
30 switch (compatible_surface->GetFormat()) {
31 case GLSurface::SURFACE_OSMESA_BGRA:
32 format = OSMESA_BGRA;
33 break;
34 case GLSurface::SURFACE_OSMESA_RGBA:
35 format = OSMESA_RGBA;
36 break;
37 default:
no sievers 2016/02/22 22:50:03 nit: NOTREACHED() (and remove line 40). Maybe we s
Jinsuk Kim 2016/02/23 01:27:38 Done.
38 break;
39 }
30 DCHECK_NE(format, (unsigned)0); 40 DCHECK_NE(format, (unsigned)0);
31 context_ = OSMesaCreateContextExt(format, 41 context_ = OSMesaCreateContextExt(format,
32 0, // depth bits 42 0, // depth bits
33 0, // stencil bits 43 0, // stencil bits
34 0, // accum bits 44 0, // accum bits
35 share_handle); 45 share_handle);
36 if (!context_) { 46 if (!context_) {
37 LOG(ERROR) << "OSMesaCreateContextExt failed."; 47 LOG(ERROR) << "OSMesaCreateContextExt failed.";
38 return false; 48 return false;
39 } 49 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 144
135 void GLContextOSMesa::OnSetSwapInterval(int interval) { 145 void GLContextOSMesa::OnSetSwapInterval(int interval) {
136 DCHECK(IsCurrent(nullptr)); 146 DCHECK(IsCurrent(nullptr));
137 } 147 }
138 148
139 GLContextOSMesa::~GLContextOSMesa() { 149 GLContextOSMesa::~GLContextOSMesa() {
140 Destroy(); 150 Destroy();
141 } 151 }
142 152
143 } // namespace gfx 153 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698