Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ui / gl / gl_surface_mac.cc
blobcd93cb00a3bcaba7771ea1fbe7fedd786db65262
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
3 // found in the LICENSE file.
5 #include "ui/gl/gl_surface.h"
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/mesa/src/include/GL/osmesa.h"
11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/gl_surface_cgl.h"
14 #include "ui/gl/gl_surface_osmesa.h"
15 #include "ui/gl/gl_surface_stub.h"
17 namespace gfx {
19 bool GLSurface::InitializeOneOffInternal() {
20 switch (GetGLImplementation()) {
21 case kGLImplementationDesktopGL:
22 case kGLImplementationAppleGL:
23 if (!GLSurfaceCGL::InitializeOneOff()) {
24 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
25 return false;
27 break;
28 default:
29 break;
31 return true;
34 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
35 gfx::AcceleratedWidget window) {
36 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
37 switch (GetGLImplementation()) {
38 case kGLImplementationDesktopGL:
39 case kGLImplementationAppleGL: {
40 NOTIMPLEMENTED() << "No onscreen support on Mac.";
41 return NULL;
43 case kGLImplementationMockGL:
44 return new GLSurfaceStub;
45 default:
46 NOTREACHED();
47 return NULL;
51 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
52 const gfx::Size& size) {
53 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
54 switch (GetGLImplementation()) {
55 case kGLImplementationOSMesaGL: {
56 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
57 size));
58 if (!surface->Initialize())
59 return NULL;
61 return surface;
63 case kGLImplementationDesktopGL:
64 case kGLImplementationAppleGL: {
65 scoped_refptr<GLSurface> surface(new NoOpGLSurfaceCGL(size));
66 if (!surface->Initialize())
67 return NULL;
69 return surface;
71 case kGLImplementationMockGL:
72 return new GLSurfaceStub;
73 default:
74 NOTREACHED();
75 return NULL;
79 } // namespace gfx