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

Side by Side Diff: ui/gl/init/gl_factory_win.cc

Issue 2616723002: Refactor GL surface format handling (Closed)
Patch Set: 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
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/init/gl_factory.h" 5 #include "ui/gl/init/gl_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/gl/gl_context.h" 9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_context_egl.h" 10 #include "ui/gl/gl_context_egl.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case kGLImplementationDesktopGL: 86 case kGLImplementationDesktopGL:
87 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window)); 87 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window));
88 case kGLImplementationMockGL: 88 case kGLImplementationMockGL:
89 return new GLSurfaceStub; 89 return new GLSurfaceStub;
90 default: 90 default:
91 NOTREACHED(); 91 NOTREACHED();
92 return nullptr; 92 return nullptr;
93 } 93 }
94 } 94 }
95 95
96 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { 96 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(
97 const gfx::Size& size, GLSurfaceFormat format) {
97 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); 98 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
98 switch (GetGLImplementation()) { 99 switch (GetGLImplementation()) {
99 case kGLImplementationOSMesaGL: 100 case kGLImplementationOSMesaGL:
100 return InitializeGLSurface( 101 if (format.IsDefault()) {
101 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size)); 102 format = GLSurfaceFormat(GLSurfaceFormat::SURFACE_OSMESA_RGBA);
103 }
104 return InitializeGLSurfaceWithFormat(
105 new GLSurfaceOSMesa(format, size), format);
102 case kGLImplementationEGLGLES2: 106 case kGLImplementationEGLGLES2:
103 return InitializeGLSurface(new PbufferGLSurfaceEGL(size)); 107 return InitializeGLSurfaceWithFormat(
108 new PbufferGLSurfaceEGL(size), format);
104 case kGLImplementationDesktopGL: 109 case kGLImplementationDesktopGL:
105 return InitializeGLSurface(new PbufferGLSurfaceWGL(size)); 110 return InitializeGLSurfaceWithFormat(
111 new PbufferGLSurfaceWGL(size), format);
106 case kGLImplementationMockGL: 112 case kGLImplementationMockGL:
107 return new GLSurfaceStub; 113 return new GLSurfaceStub;
108 default: 114 default:
109 NOTREACHED(); 115 NOTREACHED();
110 return nullptr; 116 return nullptr;
111 } 117 }
112 } 118 }
113 119
114 } // namespace init 120 } // namespace init
115 } // namespace gl 121 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698