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

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

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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.h ('k') | ui/gl/gl_surface_egl.cc » ('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 #include "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 // static 30 // static
31 bool GLSurface::InitializeOneOff(GLImplementation impl) { 31 bool GLSurface::InitializeOneOff(GLImplementation impl) {
32 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 32 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
33 33
34 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); 34 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff");
35 35
36 std::vector<GLImplementation> allowed_impls; 36 std::vector<GLImplementation> allowed_impls;
37 GetAllowedGLImplementations(&allowed_impls); 37 GetAllowedGLImplementations(&allowed_impls);
38 DCHECK(!allowed_impls.empty()); 38 DCHECK(!allowed_impls.empty());
39 39
40 CommandLine* cmd = CommandLine::ForCurrentProcess(); 40 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
41 41
42 // The default implementation is always the first one in list. 42 // The default implementation is always the first one in list.
43 if (impl == kGLImplementationNone) 43 if (impl == kGLImplementationNone)
44 impl = allowed_impls[0]; 44 impl = allowed_impls[0];
45 bool fallback_to_osmesa = false; 45 bool fallback_to_osmesa = false;
46 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) { 46 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
47 impl = kGLImplementationOSMesaGL; 47 impl = kGLImplementationOSMesaGL;
48 } else if (cmd->HasSwitch(switches::kUseGL)) { 48 } else if (cmd->HasSwitch(switches::kUseGL)) {
49 std::string requested_implementation_name = 49 std::string requested_implementation_name =
50 cmd->GetSwitchValueASCII(switches::kUseGL); 50 cmd->GetSwitchValueASCII(switches::kUseGL);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 102 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
103 103
104 #if defined(USE_X11) 104 #if defined(USE_X11)
105 XInitThreads(); 105 XInitThreads();
106 #endif 106 #endif
107 107
108 bool use_osmesa = true; 108 bool use_osmesa = true;
109 109
110 // We usually use OSMesa as this works on all bots. The command line can 110 // We usually use OSMesa as this works on all bots. The command line can
111 // override this behaviour to use hardware GL. 111 // override this behaviour to use hardware GL.
112 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGpuInTests)) 112 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
113 switches::kUseGpuInTests))
113 use_osmesa = false; 114 use_osmesa = false;
114 115
115 #if defined(OS_ANDROID) 116 #if defined(OS_ANDROID)
116 // On Android we always use hardware GL. 117 // On Android we always use hardware GL.
117 use_osmesa = false; 118 use_osmesa = false;
118 #endif 119 #endif
119 120
120 std::vector<GLImplementation> allowed_impls; 121 std::vector<GLImplementation> allowed_impls;
121 GetAllowedGLImplementations(&allowed_impls); 122 GetAllowedGLImplementations(&allowed_impls);
122 DCHECK(!allowed_impls.empty()); 123 DCHECK(!allowed_impls.empty());
123 124
124 GLImplementation impl = allowed_impls[0]; 125 GLImplementation impl = allowed_impls[0];
125 if (use_osmesa) 126 if (use_osmesa)
126 impl = kGLImplementationOSMesaGL; 127 impl = kGLImplementationOSMesaGL;
127 128
128 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) 129 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL))
129 << "kUseGL has not effect in tests"; 130 << "kUseGL has not effect in tests";
130 131
131 bool fallback_to_osmesa = false; 132 bool fallback_to_osmesa = false;
132 bool gpu_service_logging = false; 133 bool gpu_service_logging = false;
133 bool disable_gl_drawing = true; 134 bool disable_gl_drawing = true;
134 135
135 CHECK(InitializeOneOffImplementation( 136 CHECK(InitializeOneOffImplementation(
136 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); 137 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing));
137 } 138 }
138 139
139 // static 140 // static
140 void GLSurface::InitializeOneOffWithMockBindingsForTests() { 141 void GLSurface::InitializeOneOffWithMockBindingsForTests() {
141 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) 142 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL))
142 << "kUseGL has not effect in tests"; 143 << "kUseGL has not effect in tests";
143 144
144 // This method may be called multiple times in the same process to set up 145 // This method may be called multiple times in the same process to set up
145 // mock bindings in different ways. 146 // mock bindings in different ways.
146 ClearGLBindings(); 147 ClearGLBindings();
147 148
148 bool fallback_to_osmesa = false; 149 bool fallback_to_osmesa = false;
149 bool gpu_service_logging = false; 150 bool gpu_service_logging = false;
150 bool disable_gl_drawing = false; 151 bool disable_gl_drawing = false;
151 152
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 186 }
186 187
187 bool GLSurface::SupportsPostSubBuffer() { 188 bool GLSurface::SupportsPostSubBuffer() {
188 return false; 189 return false;
189 } 190 }
190 191
191 unsigned int GLSurface::GetBackingFrameBufferObject() { 192 unsigned int GLSurface::GetBackingFrameBufferObject() {
192 return 0; 193 return 0;
193 } 194 }
194 195
196 bool GLSurface::SwapBuffersAsync(const SwapCompletionCallback& callback) {
197 DCHECK(!IsSurfaceless());
198 bool success = SwapBuffers();
199 callback.Run();
200 return success;
201 }
202
195 bool GLSurface::PostSubBuffer(int x, int y, int width, int height) { 203 bool GLSurface::PostSubBuffer(int x, int y, int width, int height) {
196 return false; 204 return false;
197 } 205 }
198 206
207 bool GLSurface::PostSubBufferAsync(int x,
208 int y,
209 int width,
210 int height,
211 const SwapCompletionCallback& callback) {
212 bool success = PostSubBuffer(x, y, width, height);
213 callback.Run();
214 return success;
215 }
216
199 bool GLSurface::OnMakeCurrent(GLContext* context) { 217 bool GLSurface::OnMakeCurrent(GLContext* context) {
200 return true; 218 return true;
201 } 219 }
202 220
203 void GLSurface::NotifyWasBound() { 221 void GLSurface::NotifyWasBound() {
204 } 222 }
205 223
206 bool GLSurface::SetBackbufferAllocation(bool allocated) { 224 bool GLSurface::SetBackbufferAllocation(bool allocated) {
207 return true; 225 return true;
208 } 226 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 314 }
297 315
298 bool GLSurfaceAdapter::IsOffscreen() { 316 bool GLSurfaceAdapter::IsOffscreen() {
299 return surface_->IsOffscreen(); 317 return surface_->IsOffscreen();
300 } 318 }
301 319
302 bool GLSurfaceAdapter::SwapBuffers() { 320 bool GLSurfaceAdapter::SwapBuffers() {
303 return surface_->SwapBuffers(); 321 return surface_->SwapBuffers();
304 } 322 }
305 323
324 bool GLSurfaceAdapter::SwapBuffersAsync(
325 const SwapCompletionCallback& callback) {
326 return surface_->SwapBuffersAsync(callback);
327 }
328
306 bool GLSurfaceAdapter::PostSubBuffer(int x, int y, int width, int height) { 329 bool GLSurfaceAdapter::PostSubBuffer(int x, int y, int width, int height) {
307 return surface_->PostSubBuffer(x, y, width, height); 330 return surface_->PostSubBuffer(x, y, width, height);
308 } 331 }
309 332
333 bool GLSurfaceAdapter::PostSubBufferAsync(
334 int x, int y, int width, int height,
335 const SwapCompletionCallback& callback) {
336 return surface_->PostSubBufferAsync(x, y, width, height, callback);
337 }
338
310 bool GLSurfaceAdapter::SupportsPostSubBuffer() { 339 bool GLSurfaceAdapter::SupportsPostSubBuffer() {
311 return surface_->SupportsPostSubBuffer(); 340 return surface_->SupportsPostSubBuffer();
312 } 341 }
313 342
314 gfx::Size GLSurfaceAdapter::GetSize() { 343 gfx::Size GLSurfaceAdapter::GetSize() {
315 return surface_->GetSize(); 344 return surface_->GetSize();
316 } 345 }
317 346
318 void* GLSurfaceAdapter::GetHandle() { 347 void* GLSurfaceAdapter::GetHandle() {
319 return surface_->GetHandle(); 348 return surface_->GetHandle();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 z_order, transform, image, bounds_rect, crop_rect); 393 z_order, transform, image, bounds_rect, crop_rect);
365 } 394 }
366 395
367 bool GLSurfaceAdapter::IsSurfaceless() const { 396 bool GLSurfaceAdapter::IsSurfaceless() const {
368 return surface_->IsSurfaceless(); 397 return surface_->IsSurfaceless();
369 } 398 }
370 399
371 GLSurfaceAdapter::~GLSurfaceAdapter() {} 400 GLSurfaceAdapter::~GLSurfaceAdapter() {}
372 401
373 } // namespace gfx 402 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface.h ('k') | ui/gl/gl_surface_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698