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 18 matching lines...) Expand all Loading... |
29 DISALLOW_COPY_AND_ASSIGN(ScopedAllowGL); | 29 DISALLOW_COPY_AND_ASSIGN(ScopedAllowGL); |
30 }; | 30 }; |
31 | 31 |
32 class DeferredGpuCommandService | 32 class DeferredGpuCommandService |
33 : public gpu::InProcessCommandBuffer::Service, | 33 : public gpu::InProcessCommandBuffer::Service, |
34 public base::RefCountedThreadSafe<DeferredGpuCommandService> { | 34 public base::RefCountedThreadSafe<DeferredGpuCommandService> { |
35 public: | 35 public: |
36 static void SetInstance(); | 36 static void SetInstance(); |
37 static DeferredGpuCommandService* GetInstance(); | 37 static DeferredGpuCommandService* GetInstance(); |
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 // Flush the idle queue until it is empty. This is different from | 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 | 49 // PerformIdleWork(is_idle = true), which does not run any newly scheduled |
50 // idle tasks during the idle run. | 50 // idle tasks during the idle run. |
51 void PerformAllIdleWork(); | 51 void PerformAllIdleWork(); |
52 | 52 |
53 virtual void AddRef() const OVERRIDE; | 53 virtual void AddRef() const override; |
54 virtual void Release() const OVERRIDE; | 54 virtual void Release() const override; |
55 | 55 |
56 protected: | 56 protected: |
57 virtual ~DeferredGpuCommandService(); | 57 virtual ~DeferredGpuCommandService(); |
58 friend class base::RefCountedThreadSafe<DeferredGpuCommandService>; | 58 friend class base::RefCountedThreadSafe<DeferredGpuCommandService>; |
59 | 59 |
60 private: | 60 private: |
61 friend class ScopedAllowGL; | 61 friend class ScopedAllowGL; |
62 static void RequestProcessGL(); | 62 static void RequestProcessGL(); |
63 | 63 |
64 DeferredGpuCommandService(); | 64 DeferredGpuCommandService(); |
65 size_t IdleQueueSize(); | 65 size_t IdleQueueSize(); |
66 | 66 |
67 base::Lock tasks_lock_; | 67 base::Lock tasks_lock_; |
68 std::queue<base::Closure> tasks_; | 68 std::queue<base::Closure> tasks_; |
69 std::queue<std::pair<base::Time, base::Closure> > idle_tasks_; | 69 std::queue<std::pair<base::Time, base::Closure> > idle_tasks_; |
70 | 70 |
71 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | 71 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
72 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); | 72 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); |
73 }; | 73 }; |
74 | 74 |
75 } // namespace android_webview | 75 } // namespace android_webview |
76 | 76 |
77 #endif // ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ | 77 #endif // ANDROID_WEBVIEW_BROWSER_DEFERRED_GPU_COMMAND_SERVICE_H_ |
OLD | NEW |