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

Side by Side Diff: ui/gl/gl_surface_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_surface_osmesa.h" 5 #include "ui/gl/gl_surface_osmesa.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
11 #include "third_party/mesa/src/include/GL/osmesa.h" 11 #include "third_party/mesa/src/include/GL/osmesa.h"
12 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_context.h" 13 #include "ui/gl/gl_context.h"
14 #include "ui/gl/scoped_make_current.h" 14 #include "ui/gl/scoped_make_current.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 17
18 GLSurfaceOSMesa::GLSurfaceOSMesa(OSMesaSurfaceFormat format, 18 GLSurfaceOSMesa::GLSurfaceOSMesa(OSMesaSurfaceFormat format,
19 const gfx::Size& size) 19 const gfx::Size& size)
20 : size_(size) { 20 : size_(size) {
21 switch (format) { 21 switch (format) {
22 case OSMesaSurfaceFormatBGRA: 22 case OSMesaSurfaceFormatBGRA:
23 format_ = OSMESA_BGRA; 23 format_ = static_cast<GLSurface::Format>(OSMESA_BGRA);
no sievers 2016/02/19 20:25:18 hmm this seems like a hack. how about just adding
Jinsuk Kim 2016/02/20 13:56:57 Had meant to do it but didn't. This is certainly b
24 break; 24 break;
25 case OSMesaSurfaceFormatRGBA: 25 case OSMesaSurfaceFormatRGBA:
26 format_ = OSMESA_RGBA; 26 format_ = static_cast<GLSurface::Format>(OSMESA_RGBA);
27 break; 27 break;
28 } 28 }
29 // Implementations of OSMesa surface do not support having a 0 size. In such 29 // Implementations of OSMesa surface do not support having a 0 size. In such
30 // cases use a (1, 1) surface. 30 // cases use a (1, 1) surface.
31 if (size_.GetArea() == 0) 31 if (size_.GetArea() == 0)
32 size_.SetSize(1, 1); 32 size_.SetSize(1, 1);
33 } 33 }
34 34
35 bool GLSurfaceOSMesa::Initialize(GLSurface::Format format) { 35 bool GLSurfaceOSMesa::Initialize(GLSurface::Format format) {
36 return Resize(size_, 1.f, true); 36 return Resize(size_, 1.f, true);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 gfx::Size GLSurfaceOSMesa::GetSize() { 97 gfx::Size GLSurfaceOSMesa::GetSize() {
98 return size_; 98 return size_;
99 } 99 }
100 100
101 void* GLSurfaceOSMesa::GetHandle() { 101 void* GLSurfaceOSMesa::GetHandle() {
102 return buffer_.get(); 102 return buffer_.get();
103 } 103 }
104 104
105 unsigned GLSurfaceOSMesa::GetFormat() {
106 return format_;
107 }
108
109 GLSurfaceOSMesa::~GLSurfaceOSMesa() { 105 GLSurfaceOSMesa::~GLSurfaceOSMesa() {
110 Destroy(); 106 Destroy();
111 } 107 }
112 108
113 bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; } 109 bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; }
114 110
115 gfx::SwapResult GLSurfaceOSMesaHeadless::SwapBuffers() { 111 gfx::SwapResult GLSurfaceOSMesaHeadless::SwapBuffers() {
116 return gfx::SwapResult::SWAP_ACK; 112 return gfx::SwapResult::SWAP_ACK;
117 } 113 }
118 114
119 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless() 115 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless()
120 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) { 116 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) {
121 } 117 }
122 118
123 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } 119 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); }
124 120
125 } // namespace gfx 121 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698