| OLD | NEW |
| 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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "third_party/mesa/src/include/GL/osmesa.h" | 10 #include "third_party/mesa/src/include/GL/osmesa.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 x, y, width, height, | 166 x, y, width, height, |
| 167 GetHandle(), | 167 GetHandle(), |
| 168 reinterpret_cast<BITMAPINFO*>(&info), | 168 reinterpret_cast<BITMAPINFO*>(&info), |
| 169 DIB_RGB_COLORS, | 169 DIB_RGB_COLORS, |
| 170 SRCCOPY); | 170 SRCCOPY); |
| 171 | 171 |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 175 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 176 bool software, | |
| 177 gfx::AcceleratedWidget window) { | 176 gfx::AcceleratedWidget window) { |
| 178 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); | 177 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); |
| 179 switch (GetGLImplementation()) { | 178 switch (GetGLImplementation()) { |
| 180 case kGLImplementationOSMesaGL: { | 179 case kGLImplementationOSMesaGL: { |
| 181 scoped_refptr<GLSurface> surface( | 180 scoped_refptr<GLSurface> surface( |
| 182 new NativeViewGLSurfaceOSMesa(window)); | 181 new NativeViewGLSurfaceOSMesa(window)); |
| 183 if (!surface->Initialize()) | 182 if (!surface->Initialize()) |
| 184 return NULL; | 183 return NULL; |
| 185 | 184 |
| 186 return surface; | 185 return surface; |
| 187 } | 186 } |
| 188 case kGLImplementationEGLGLES2: { | 187 case kGLImplementationEGLGLES2: { |
| 189 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(software, | 188 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(window)); |
| 190 window)); | |
| 191 if (!surface->Initialize()) | 189 if (!surface->Initialize()) |
| 192 return NULL; | 190 return NULL; |
| 193 | 191 |
| 194 return surface; | 192 return surface; |
| 195 } | 193 } |
| 196 case kGLImplementationDesktopGL: { | 194 case kGLImplementationDesktopGL: { |
| 197 if (software) | |
| 198 return NULL; | |
| 199 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceWGL( | 195 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceWGL( |
| 200 window)); | 196 window)); |
| 201 if (!surface->Initialize()) | 197 if (!surface->Initialize()) |
| 202 return NULL; | 198 return NULL; |
| 203 | 199 |
| 204 return surface; | 200 return surface; |
| 205 } | 201 } |
| 206 case kGLImplementationMockGL: | 202 case kGLImplementationMockGL: |
| 207 return new GLSurfaceStub; | 203 return new GLSurfaceStub; |
| 208 default: | 204 default: |
| 209 NOTREACHED(); | 205 NOTREACHED(); |
| 210 return NULL; | 206 return NULL; |
| 211 } | 207 } |
| 212 } | 208 } |
| 213 | 209 |
| 214 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 210 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
| 215 bool software, | |
| 216 const gfx::Size& size) { | 211 const gfx::Size& size) { |
| 217 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); | 212 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); |
| 218 switch (GetGLImplementation()) { | 213 switch (GetGLImplementation()) { |
| 219 case kGLImplementationOSMesaGL: { | 214 case kGLImplementationOSMesaGL: { |
| 220 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, | 215 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, |
| 221 size)); | 216 size)); |
| 222 if (!surface->Initialize()) | 217 if (!surface->Initialize()) |
| 223 return NULL; | 218 return NULL; |
| 224 | 219 |
| 225 return surface; | 220 return surface; |
| 226 } | 221 } |
| 227 case kGLImplementationEGLGLES2: { | 222 case kGLImplementationEGLGLES2: { |
| 228 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(software, size)); | 223 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); |
| 229 if (!surface->Initialize()) | 224 if (!surface->Initialize()) |
| 230 return NULL; | 225 return NULL; |
| 231 | 226 |
| 232 return surface; | 227 return surface; |
| 233 } | 228 } |
| 234 case kGLImplementationDesktopGL: { | 229 case kGLImplementationDesktopGL: { |
| 235 if (software) | |
| 236 return NULL; | |
| 237 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceWGL(size)); | 230 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceWGL(size)); |
| 238 if (!surface->Initialize()) | 231 if (!surface->Initialize()) |
| 239 return NULL; | 232 return NULL; |
| 240 | 233 |
| 241 return surface; | 234 return surface; |
| 242 } | 235 } |
| 243 case kGLImplementationMockGL: | 236 case kGLImplementationMockGL: |
| 244 return new GLSurfaceStub; | 237 return new GLSurfaceStub; |
| 245 default: | 238 default: |
| 246 NOTREACHED(); | 239 NOTREACHED(); |
| 247 return NULL; | 240 return NULL; |
| 248 } | 241 } |
| 249 } | 242 } |
| 250 | 243 |
| 251 } // namespace gfx | 244 } // namespace gfx |
| OLD | NEW |