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

Side by Side Diff: android_webview/browser/hardware_renderer.h

Issue 273703008: aw: Refactor hardware init (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more refactoring Created 6 years, 7 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
OLDNEW
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_HARDWARE_RENDERER_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ 6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "android_webview/browser/gl_view_renderer_manager.h"
11 #include "android_webview/browser/shared_renderer_state.h" 10 #include "android_webview/browser/shared_renderer_state.h"
12 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_local.h" 13 #include "base/threading/thread_local.h"
15 14
16 struct AwDrawGLInfo; 15 struct AwDrawGLInfo;
17 16
18 namespace android_webview { 17 namespace android_webview {
19 18
20 class AwGLSurface; 19 class AwGLSurface;
21 class BrowserViewRendererClient; 20 class BrowserViewRendererClient;
22 21
23 namespace internal { 22 namespace internal {
24 class DeferredGpuCommandService; 23 class DeferredGpuCommandService;
25 } // namespace internal 24 } // namespace internal
26 25
27 class HardwareRenderer { 26 class HardwareRenderer {
28 public: 27 public:
29 explicit HardwareRenderer(SharedRendererState* state); 28 explicit HardwareRenderer(SharedRendererState* state);
30 ~HardwareRenderer(); 29 ~HardwareRenderer();
31 30
32 bool DrawGL(AwDrawGLInfo* draw_info, DrawGLResult* result); 31 bool DrawGL(bool stencil_enabled,
32 int framebuffer_binding_ext,
33 AwDrawGLInfo* draw_info,
34 DrawGLResult* result);
33 35
34 private: 36 private:
35 friend class internal::DeferredGpuCommandService; 37 friend class internal::DeferredGpuCommandService;
36 38
37 void SetCompositorMemoryPolicy(); 39 void SetCompositorMemoryPolicy();
38 40
39 SharedRendererState* shared_renderer_state_; 41 SharedRendererState* shared_renderer_state_;
40 42
41 typedef void* EGLContext; 43 typedef void* EGLContext;
42 EGLContext last_egl_context_; 44 EGLContext last_egl_context_;
43 45
44 scoped_refptr<AwGLSurface> gl_surface_; 46 scoped_refptr<AwGLSurface> gl_surface_;
45 47
46 GLViewRendererManager::Key renderer_manager_key_;
47
48 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); 48 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer);
49 }; 49 };
50 50
51 namespace internal {
52
53 class ScopedAllowGL {
54 public:
55 ScopedAllowGL();
56 ~ScopedAllowGL();
57
58 static bool IsAllowed();
59
60 private:
61 static base::LazyInstance<base::ThreadLocalBoolean> allow_gl;
62
63 DISALLOW_COPY_AND_ASSIGN(ScopedAllowGL);
64 };
65
66 // TODO(boliu): Teach this class about RT.
67 class DeferredGpuCommandService
68 : public gpu::InProcessCommandBuffer::Service,
69 public base::RefCountedThreadSafe<DeferredGpuCommandService> {
70 public:
71 DeferredGpuCommandService();
72
73 virtual void ScheduleTask(const base::Closure& task) OVERRIDE;
74 virtual void ScheduleIdleWork(const base::Closure& task) OVERRIDE;
75 virtual bool UseVirtualizedGLContexts() OVERRIDE;
76 virtual scoped_refptr<gpu::gles2::ShaderTranslatorCache>
77 shader_translator_cache() OVERRIDE;
78
79 void RunTasks();
80
81 virtual void AddRef() const OVERRIDE;
82 virtual void Release() const OVERRIDE;
83
84 protected:
85 virtual ~DeferredGpuCommandService();
86 friend class base::RefCountedThreadSafe<DeferredGpuCommandService>;
87
88 private:
89 static void RequestProcessGLOnUIThread();
90
91 base::Lock tasks_lock_;
92 std::queue<base::Closure> tasks_;
93
94 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_;
95 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService);
96 };
97
98 } // namespace internal
99
100 } // namespace android_webview 51 } // namespace android_webview
101 52
102 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ 53 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698