| 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 "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 Loading... |
| 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 (context_ == EGL_NO_CONTEXT || display_ == EGL_NO_DISPLAY || |
| 78 draw_surface_ == EGL_NO_SURFACE || read_surface_ == EGL_NO_SURFACE) { | 76 draw_surface_ == EGL_NO_SURFACE || read_surface_ == EGL_NO_SURFACE) |
| 79 return; | 77 return; |
| 80 } | |
| 81 | 78 |
| 82 if (!eglMakeCurrent(display_, draw_surface_, read_surface_, context_)) { | 79 if (!eglMakeCurrent(display_, draw_surface_, read_surface_, context_)) |
| 83 LOG(WARNING) << "Failed to restore EGL context"; | 80 LOG(WARNING) << "Failed to restore EGL context"; |
| 84 } | |
| 85 } | 81 } |
| 86 | 82 |
| 87 } | 83 } |
| 88 | 84 |
| 89 namespace gpu { | 85 namespace gpu { |
| 90 | 86 |
| 91 bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { | 87 bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { |
| 92 return CollectBasicGraphicsInfo(gpu_info); | 88 return CollectBasicGraphicsInfo(gpu_info); |
| 93 } | 89 } |
| 94 | 90 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 118 gpu_info->gpu.device_string = gpu_info->gl_renderer; | 114 gpu_info->gpu.device_string = gpu_info->gl_renderer; |
| 119 return true; | 115 return true; |
| 120 } | 116 } |
| 121 | 117 |
| 122 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 118 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
| 123 const GPUInfo& context_gpu_info) { | 119 const GPUInfo& context_gpu_info) { |
| 124 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 120 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
| 125 } | 121 } |
| 126 | 122 |
| 127 } // namespace gpu | 123 } // namespace gpu |
| OLD | NEW |