OLD | NEW |
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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // A "no-op" surface. It is not required that a CGLContextObj have an | 26 // A "no-op" surface. It is not required that a CGLContextObj have an |
27 // associated drawable (pbuffer or fullscreen context) in order to be | 27 // associated drawable (pbuffer or fullscreen context) in order to be |
28 // made current. Everywhere this surface type is used, we allocate an | 28 // made current. Everywhere this surface type is used, we allocate an |
29 // FBO at the user level as the drawable of the associated context. | 29 // FBO at the user level as the drawable of the associated context. |
30 class NoOpGLSurface : public GLSurface { | 30 class NoOpGLSurface : public GLSurface { |
31 public: | 31 public: |
32 explicit NoOpGLSurface(const gfx::Size& size) : size_(size) {} | 32 explicit NoOpGLSurface(const gfx::Size& size) : size_(size) {} |
33 | 33 |
34 // Implement GLSurface. | 34 // Implement GLSurface. |
35 bool Initialize(GLSurface::Format format) override { return true; } | 35 bool Initialize(GLSurfaceFormat format) override { return true; } |
36 void Destroy() override {} | 36 void Destroy() override {} |
37 bool IsOffscreen() override { return true; } | 37 bool IsOffscreen() override { return true; } |
38 gfx::SwapResult SwapBuffers() override { | 38 gfx::SwapResult SwapBuffers() override { |
39 NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurface."; | 39 NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurface."; |
40 return gfx::SwapResult::SWAP_FAILED; | 40 return gfx::SwapResult::SWAP_FAILED; |
41 } | 41 } |
42 gfx::Size GetSize() override { return size_; } | 42 gfx::Size GetSize() override { return size_; } |
43 void* GetHandle() override { return nullptr; } | 43 void* GetHandle() override { return nullptr; } |
44 void* GetDisplay() override { return nullptr; } | 44 void* GetDisplay() override { return nullptr; } |
45 bool IsSurfaceless() const override { return true; } | 45 bool IsSurfaceless() const override { return true; } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); | 106 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); |
107 } | 107 } |
108 case kGLImplementationMockGL: | 108 case kGLImplementationMockGL: |
109 return new GLSurfaceStub; | 109 return new GLSurfaceStub; |
110 default: | 110 default: |
111 NOTREACHED(); | 111 NOTREACHED(); |
112 return nullptr; | 112 return nullptr; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { | 116 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( |
| 117 const gfx::Size& size, GLSurfaceFormat format) { |
117 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 118 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
118 switch (GetGLImplementation()) { | 119 switch (GetGLImplementation()) { |
119 case kGLImplementationOSMesaGL: | 120 case kGLImplementationOSMesaGL: |
120 return InitializeGLSurface( | 121 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
121 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size)); | 122 return InitializeGLSurfaceWithFormat( |
| 123 new GLSurfaceOSMesa(format, size), format); |
122 case kGLImplementationDesktopGL: | 124 case kGLImplementationDesktopGL: |
123 case kGLImplementationDesktopGLCoreProfile: | 125 case kGLImplementationDesktopGLCoreProfile: |
124 case kGLImplementationAppleGL: | 126 case kGLImplementationAppleGL: |
125 return InitializeGLSurface(new NoOpGLSurface(size)); | 127 return InitializeGLSurfaceWithFormat( |
| 128 new NoOpGLSurface(size), format); |
126 case kGLImplementationMockGL: | 129 case kGLImplementationMockGL: |
127 return new GLSurfaceStub; | 130 return new GLSurfaceStub; |
128 default: | 131 default: |
129 NOTREACHED(); | 132 NOTREACHED(); |
130 return nullptr; | 133 return nullptr; |
131 } | 134 } |
132 } | 135 } |
133 | 136 |
134 } // namespace init | 137 } // namespace init |
135 } // namespace gl | 138 } // namespace gl |
OLD | NEW |