| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/hardware_renderer.h" | 5 #include "android_webview/browser/hardware_renderer.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_gl_surface.h" | 7 #include "android_webview/browser/aw_gl_surface.h" |
| 8 #include "android_webview/browser/browser_view_renderer_client.h" | 8 #include "android_webview/browser/browser_view_renderer_client.h" |
| 9 #include "android_webview/browser/gl_view_renderer_manager.h" | 9 #include "android_webview/browser/gl_view_renderer_manager.h" |
| 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const char kDefaultTileSize[] = "384"; | 199 const char kDefaultTileSize[] = "384"; |
| 200 if (!cl->HasSwitch(switches::kDefaultTileWidth)) | 200 if (!cl->HasSwitch(switches::kDefaultTileWidth)) |
| 201 cl->AppendSwitchASCII(switches::kDefaultTileWidth, kDefaultTileSize); | 201 cl->AppendSwitchASCII(switches::kDefaultTileWidth, kDefaultTileSize); |
| 202 | 202 |
| 203 if (!cl->HasSwitch(switches::kDefaultTileHeight)) | 203 if (!cl->HasSwitch(switches::kDefaultTileHeight)) |
| 204 cl->AppendSwitchASCII(switches::kDefaultTileHeight, kDefaultTileSize); | 204 cl->AppendSwitchASCII(switches::kDefaultTileHeight, kDefaultTileSize); |
| 205 } | 205 } |
| 206 | 206 |
| 207 namespace internal { | 207 namespace internal { |
| 208 | 208 |
| 209 bool ScopedAllowGL::allow_gl = false; | 209 base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; |
| 210 | 210 |
| 211 // static | 211 // static |
| 212 bool ScopedAllowGL::IsAllowed() { | 212 bool ScopedAllowGL::IsAllowed() { |
| 213 return GLViewRendererManager::GetInstance()->OnRenderThread() && allow_gl; | 213 return allow_gl.Get().Get(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 ScopedAllowGL::ScopedAllowGL() { | 216 ScopedAllowGL::ScopedAllowGL() { |
| 217 DCHECK(GLViewRendererManager::GetInstance()->OnRenderThread()); | 217 DCHECK(!allow_gl.Get().Get()); |
| 218 DCHECK(!allow_gl); | 218 allow_gl.Get().Set(true); |
| 219 allow_gl = true; | |
| 220 | 219 |
| 221 if (g_service.Get()) | 220 if (g_service.Get()) |
| 222 g_service.Get()->RunTasks(); | 221 g_service.Get()->RunTasks(); |
| 223 } | 222 } |
| 224 | 223 |
| 225 ScopedAllowGL::~ScopedAllowGL() { allow_gl = false; } | 224 ScopedAllowGL::~ScopedAllowGL() { allow_gl.Get().Set(false); } |
| 226 | 225 |
| 227 DeferredGpuCommandService::DeferredGpuCommandService() {} | 226 DeferredGpuCommandService::DeferredGpuCommandService() {} |
| 228 | 227 |
| 229 DeferredGpuCommandService::~DeferredGpuCommandService() { | 228 DeferredGpuCommandService::~DeferredGpuCommandService() { |
| 230 base::AutoLock lock(tasks_lock_); | 229 base::AutoLock lock(tasks_lock_); |
| 231 DCHECK(tasks_.empty()); | 230 DCHECK(tasks_.empty()); |
| 232 } | 231 } |
| 233 | 232 |
| 234 // static | 233 // static |
| 235 void DeferredGpuCommandService::RequestProcessGLOnUIThread() { | 234 void DeferredGpuCommandService::RequestProcessGLOnUIThread() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); | 294 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 void DeferredGpuCommandService::Release() const { | 297 void DeferredGpuCommandService::Release() const { |
| 299 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); | 298 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); |
| 300 } | 299 } |
| 301 | 300 |
| 302 } // namespace internal | 301 } // namespace internal |
| 303 | 302 |
| 304 } // namespace android_webview | 303 } // namespace android_webview |
| OLD | NEW |