Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: gpu/config/gpu_info_collector_android.cc

Issue 135213003: Ensure GL initialization only happens once, and provide common init path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initgl: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/config/gpu_info_collector.cc ('k') | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gpu/config/gpu_info_collector.h" 5 #include "gpu/config/gpu_info_collector.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 ScopedRestoreNonOwnedEGLContext::ScopedRestoreNonOwnedEGLContext() 59 ScopedRestoreNonOwnedEGLContext::ScopedRestoreNonOwnedEGLContext()
60 : context_(EGL_NO_CONTEXT), 60 : context_(EGL_NO_CONTEXT),
61 display_(EGL_NO_DISPLAY), 61 display_(EGL_NO_DISPLAY),
62 draw_surface_(EGL_NO_SURFACE), 62 draw_surface_(EGL_NO_SURFACE),
63 read_surface_(EGL_NO_SURFACE) { 63 read_surface_(EGL_NO_SURFACE) {
64 // This should only used to restore a context that is not created or owned by 64 // This should only used to restore a context that is not created or owned by
65 // Chromium native code, but created by Android system itself. 65 // Chromium native code, but created by Android system itself.
66 DCHECK(!gfx::GLContext::GetCurrent()); 66 DCHECK(!gfx::GLContext::GetCurrent());
67 67
68 if (gfx::GLSurface::InitializeOneOff()) { 68 context_ = eglGetCurrentContext();
69 context_ = eglGetCurrentContext(); 69 display_ = eglGetCurrentDisplay();
70 display_ = eglGetCurrentDisplay(); 70 draw_surface_ = eglGetCurrentSurface(EGL_DRAW);
71 draw_surface_ = eglGetCurrentSurface(EGL_DRAW); 71 read_surface_ = eglGetCurrentSurface(EGL_READ);
72 read_surface_ = eglGetCurrentSurface(EGL_READ);
73 }
74 } 72 }
75 73
76 ScopedRestoreNonOwnedEGLContext::~ScopedRestoreNonOwnedEGLContext() { 74 ScopedRestoreNonOwnedEGLContext::~ScopedRestoreNonOwnedEGLContext() {
77 if (context_ == EGL_NO_CONTEXT || display_ == EGL_NO_DISPLAY || 75 if (!eglMakeCurrent(display_, draw_surface_, read_surface_, context_))
no sievers 2014/01/29 02:00:22 I think display_ at least might have to be valid.
no sievers 2014/01/29 02:14:58 Or you can do something like this: if (display_ =
danakj 2014/01/29 19:05:59 Ok I've put back the early out as we discussed, to
78 draw_surface_ == EGL_NO_SURFACE || read_surface_ == EGL_NO_SURFACE) {
79 return;
80 }
81
82 if (!eglMakeCurrent(display_, draw_surface_, read_surface_, context_)) {
83 LOG(WARNING) << "Failed to restore EGL context"; 76 LOG(WARNING) << "Failed to restore EGL context";
84 }
85 } 77 }
86 78
87 } 79 }
88 80
89 namespace gpu { 81 namespace gpu {
90 82
91 bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { 83 bool CollectContextGraphicsInfo(GPUInfo* gpu_info) {
92 return CollectBasicGraphicsInfo(gpu_info); 84 return CollectBasicGraphicsInfo(gpu_info);
93 } 85 }
94 86
(...skipping 23 matching lines...) Expand all
118 gpu_info->gpu.device_string = gpu_info->gl_renderer; 110 gpu_info->gpu.device_string = gpu_info->gl_renderer;
119 return true; 111 return true;
120 } 112 }
121 113
122 void MergeGPUInfo(GPUInfo* basic_gpu_info, 114 void MergeGPUInfo(GPUInfo* basic_gpu_info,
123 const GPUInfo& context_gpu_info) { 115 const GPUInfo& context_gpu_info) {
124 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 116 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
125 } 117 }
126 118
127 } // namespace gpu 119 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/config/gpu_info_collector.cc ('k') | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698