OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "android_webview/browser/scoped_app_gl_state_restore.h" | 5 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/gl_surface_stub.h" | 13 #include "ui/gl/gl_surface_stub.h" |
14 #include "ui/gl/init/gl_factory.h" | 14 #include "ui/gl/init/gl_factory.h" |
15 | 15 |
16 namespace android_webview { | 16 namespace android_webview { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 gl::GLContextAttribs GetAppContextAttribs() { | |
21 gl::GLContextAttribs attribs; | |
22 attribs.gpu_preference = gl::PreferDiscreteGpu; | |
23 return attribs; | |
24 } | |
25 | |
20 // "App" context is a bit of a stretch. Basically we use this context while | 26 // "App" context is a bit of a stretch. Basically we use this context while |
21 // saving and restoring the App GL state. | 27 // saving and restoring the App GL state. |
22 class AppContextSurface { | 28 class AppContextSurface { |
23 public: | 29 public: |
24 AppContextSurface() | 30 AppContextSurface() |
25 : surface(new gl::GLSurfaceStub), | 31 : surface(new gl::GLSurfaceStub), |
26 context(gl::init::CreateGLContext(nullptr, | 32 context(gl::init::CreateGLContext(nullptr, |
27 surface.get(), | 33 surface.get(), |
28 gl::PreferDiscreteGpu)) {} | 34 GetAppContextAttribs())) {} |
piman
2016/11/07 21:01:01
nit: the default GLContextAttribs would be perfect
Geoff Lang
2016/11/07 21:36:20
Done.
| |
29 void MakeCurrent() { context->MakeCurrent(surface.get()); } | 35 void MakeCurrent() { context->MakeCurrent(surface.get()); } |
30 | 36 |
31 private: | 37 private: |
32 scoped_refptr<gl::GLSurfaceStub> surface; | 38 scoped_refptr<gl::GLSurfaceStub> surface; |
33 scoped_refptr<gl::GLContext> context; | 39 scoped_refptr<gl::GLContext> context; |
34 | 40 |
35 DISALLOW_COPY_AND_ASSIGN(AppContextSurface); | 41 DISALLOW_COPY_AND_ASSIGN(AppContextSurface); |
36 }; | 42 }; |
37 | 43 |
38 base::LazyInstance<AppContextSurface> g_app_context_surface = | 44 base::LazyInstance<AppContextSurface> g_app_context_surface = |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 } | 443 } |
438 | 444 |
439 StencilState ScopedAppGLStateRestore::stencil_state() const { | 445 StencilState ScopedAppGLStateRestore::stencil_state() const { |
440 return impl_->stencil_state(); | 446 return impl_->stencil_state(); |
441 } | 447 } |
442 int ScopedAppGLStateRestore::framebuffer_binding_ext() const { | 448 int ScopedAppGLStateRestore::framebuffer_binding_ext() const { |
443 return impl_->framebuffer_binding_ext(); | 449 return impl_->framebuffer_binding_ext(); |
444 } | 450 } |
445 | 451 |
446 } // namespace android_webview | 452 } // namespace android_webview |
OLD | NEW |