Index: ui/gl/init/gl_factory_android.cc |
diff --git a/ui/gl/gl_context_android.cc b/ui/gl/init/gl_factory_android.cc |
similarity index 62% |
rename from ui/gl/gl_context_android.cc |
rename to ui/gl/init/gl_factory_android.cc |
index 789bc5375bb7e1406f4783fe056f70ce41a5061e..2f46db9358e3ecffe4a11fc97b1027b0f2b644c5 100644 |
--- a/ui/gl/gl_context_android.cc |
+++ b/ui/gl/init/gl_factory_android.cc |
@@ -1,21 +1,22 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ui/gl/gl_context.h" |
+#include "ui/gl/init/gl_factory.h" |
#include "base/logging.h" |
-#include "base/macros.h" |
-#include "base/memory/ref_counted.h" |
-#include "base/sys_info.h" |
+#include "base/trace_event/trace_event.h" |
#include "ui/gl/gl_bindings.h" |
+#include "ui/gl/gl_context.h" |
#include "ui/gl/gl_context_egl.h" |
#include "ui/gl/gl_context_osmesa.h" |
#include "ui/gl/gl_context_stub.h" |
#include "ui/gl/gl_implementation.h" |
+#include "ui/gl/gl_share_group.h" |
#include "ui/gl/gl_surface.h" |
namespace gl { |
+namespace init { |
namespace { |
@@ -24,7 +25,7 @@ namespace { |
// TODO(boliu): Make this inherit from GLContextEGL. |
class GLNonOwnedContext : public GLContextReal { |
public: |
- GLNonOwnedContext(GLShareGroup* share_group); |
+ explicit GLNonOwnedContext(GLShareGroup* share_group); |
// Implement GLContext. |
bool Initialize(GLSurface* compatible_surface, |
@@ -46,10 +47,10 @@ class GLNonOwnedContext : public GLContextReal { |
}; |
GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group) |
- : GLContextReal(share_group), display_(nullptr) {} |
+ : GLContextReal(share_group), display_(nullptr) {} |
bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface, |
- GpuPreference gpu_preference) { |
+ GpuPreference gpu_preference) { |
display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
return true; |
} |
@@ -70,30 +71,26 @@ std::string GLNonOwnedContext::GetExtensions() { |
} // anonymous namespace |
-// static |
-scoped_refptr<GLContext> GLContext::CreateGLContext( |
- GLShareGroup* share_group, |
- GLSurface* compatible_surface, |
- GpuPreference gpu_preference) { |
- scoped_refptr<GLContext> context; |
+scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, |
+ GLSurface* compatible_surface, |
+ GpuPreference gpu_preference) { |
+ TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); |
switch (GetGLImplementation()) { |
case kGLImplementationMockGL: |
return scoped_refptr<GLContext>(new GLContextStub(share_group)); |
case kGLImplementationOSMesaGL: |
- context = new GLContextOSMesa(share_group); |
- break; |
+ return InitializeGLContext(new GLContextOSMesa(share_group), |
+ compatible_surface, gpu_preference); |
default: |
- if (compatible_surface->GetHandle()) |
- context = new GLContextEGL(share_group); |
- else |
- context = new GLNonOwnedContext(share_group); |
- break; |
+ if (compatible_surface->GetHandle()) { |
+ return InitializeGLContext(new GLContextEGL(share_group), |
+ compatible_surface, gpu_preference); |
+ } else { |
+ return InitializeGLContext(new GLNonOwnedContext(share_group), |
+ compatible_surface, gpu_preference); |
+ } |
} |
- |
- if (!context->Initialize(compatible_surface, gpu_preference)) |
- return nullptr; |
- |
- return context; |
} |
-} |
+} // namespace init |
+} // namespace gl |