| 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 #ifndef ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 virtual void ScheduleTask(const base::Closure& task) OVERRIDE; | 39 virtual void ScheduleTask(const base::Closure& task) OVERRIDE; |
| 40 virtual void ScheduleIdleWork(const base::Closure& task) OVERRIDE; | 40 virtual void ScheduleIdleWork(const base::Closure& task) OVERRIDE; |
| 41 virtual bool UseVirtualizedGLContexts() OVERRIDE; | 41 virtual bool UseVirtualizedGLContexts() OVERRIDE; |
| 42 virtual scoped_refptr<gpu::gles2::ShaderTranslatorCache> | 42 virtual scoped_refptr<gpu::gles2::ShaderTranslatorCache> |
| 43 shader_translator_cache() OVERRIDE; | 43 shader_translator_cache() OVERRIDE; |
| 44 | 44 |
| 45 void RunTasks(); | 45 void RunTasks(); |
| 46 // If |is_idle| is false, this will only run older idle tasks. | 46 // If |is_idle| is false, this will only run older idle tasks. |
| 47 void PerformIdleWork(bool is_idle); | 47 void PerformIdleWork(bool is_idle); |
| 48 bool HasIdleWork(); | 48 // Flush the idle queue until it is empty. This is different from |
| 49 // PerformIdleWork(is_idle = true), which does not run any newly scheduled |
| 50 // idle tasks during the idle run. |
| 51 void PerformAllIdleWork(); |
| 49 | 52 |
| 50 virtual void AddRef() const OVERRIDE; | 53 virtual void AddRef() const OVERRIDE; |
| 51 virtual void Release() const OVERRIDE; | 54 virtual void Release() const OVERRIDE; |
| 52 | 55 |
| 53 protected: | 56 protected: |
| 54 virtual ~DeferredGpuCommandService(); | 57 virtual ~DeferredGpuCommandService(); |
| 55 friend class base::RefCountedThreadSafe<DeferredGpuCommandService>; | 58 friend class base::RefCountedThreadSafe<DeferredGpuCommandService>; |
| 56 | 59 |
| 57 private: | 60 private: |
| 58 friend class ScopedAllowGL; | 61 friend class ScopedAllowGL; |
| 59 static void RequestProcessGL(); | 62 static void RequestProcessGL(); |
| 60 | 63 |
| 61 DeferredGpuCommandService(); | 64 DeferredGpuCommandService(); |
| 65 size_t IdleQueueSize(); |
| 62 | 66 |
| 63 base::Lock tasks_lock_; | 67 base::Lock tasks_lock_; |
| 64 std::queue<base::Closure> tasks_; | 68 std::queue<base::Closure> tasks_; |
| 65 std::queue<std::pair<base::Time, base::Closure> > idle_tasks_; | 69 std::queue<std::pair<base::Time, base::Closure> > idle_tasks_; |
| 66 | 70 |
| 67 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | 71 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
| 68 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); | 72 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); |
| 69 }; | 73 }; |
| 70 | 74 |
| 71 } // namespace android_webview | 75 } // namespace android_webview |
| 72 | 76 |
| 73 #endif // ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ | 77 #endif // ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ |
| OLD | NEW |