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_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 "android_webview/browser/hardware_renderer_interface.h" |
9 | |
10 #include "android_webview/browser/shared_renderer_state.h" | 9 #include "android_webview/browser/shared_renderer_state.h" |
11 #include "base/lazy_instance.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread_local.h" | 12 #include "cc/layers/delegated_frame_resource_collection.h" |
13 #include "cc/trees/layer_tree_host_client.h" | |
14 #include "cc/trees/layer_tree_host_single_thread_client.h" | |
14 | 15 |
15 struct AwDrawGLInfo; | 16 struct AwDrawGLInfo; |
16 | 17 |
18 namespace cc { | |
19 class DelegatedFrameProvider; | |
20 class DelegatedRendererLayer; | |
21 class Layer; | |
22 class LayerTreeHost; | |
23 } | |
24 | |
17 namespace android_webview { | 25 namespace android_webview { |
18 | 26 |
19 class AwGLSurface; | 27 class AwGLSurface; |
20 class BrowserViewRendererClient; | 28 class ParentOutputSurface; |
21 | 29 |
22 namespace internal { | 30 class HardwareRenderer : public HardwareRendererInterface, |
23 class DeferredGpuCommandService; | 31 public cc::LayerTreeHostClient, |
24 } // namespace internal | 32 public cc::LayerTreeHostSingleThreadClient, |
25 | 33 public cc::DelegatedFrameResourceCollectionClient { |
26 class HardwareRenderer { | |
27 public: | 34 public: |
28 explicit HardwareRenderer(SharedRendererState* state); | 35 explicit HardwareRenderer(SharedRendererState* state); |
29 ~HardwareRenderer(); | 36 virtual ~HardwareRenderer(); |
30 | 37 |
31 bool DrawGL(bool stencil_enabled, | 38 // HardwareRendererInterface. |
32 int framebuffer_binding_ext, | 39 virtual bool DrawGL(bool stencil_enabled, |
33 AwDrawGLInfo* draw_info, | 40 int framebuffer_binding_ext, |
34 DrawGLResult* result); | 41 AwDrawGLInfo* draw_info, |
42 DrawGLResult* result) OVERRIDE; | |
43 | |
44 // cc::LayerTreeHostClient. | |
45 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | |
46 virtual void DidBeginMainFrame() OVERRIDE {} | |
47 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | |
48 virtual void Layout() OVERRIDE {} | |
49 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | |
50 float page_scale) OVERRIDE {} | |
51 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | |
52 bool fallback) OVERRIDE; | |
53 virtual void DidInitializeOutputSurface() OVERRIDE {} | |
54 virtual void WillCommit() OVERRIDE {} | |
55 virtual void DidCommit() OVERRIDE {} | |
56 virtual void DidCommitAndDrawFrame() OVERRIDE {} | |
57 virtual void DidCompleteSwapBuffers() OVERRIDE {} | |
58 | |
59 // cc::LayerTreeHostSingleThreadClient. | |
60 virtual void ScheduleComposite() OVERRIDE {} | |
61 virtual void ScheduleAnimation() OVERRIDE {} | |
62 virtual void DidPostSwapBuffers() OVERRIDE {} | |
63 virtual void DidAbortSwapBuffers() OVERRIDE {} | |
64 | |
65 // cc::DelegatedFrameResourceCollectionClient. | |
66 virtual void UnusedResourcesAreAvailable() OVERRIDE; | |
35 | 67 |
36 private: | 68 private: |
37 friend class internal::DeferredGpuCommandService; | |
38 | |
39 void SetCompositorMemoryPolicy(); | |
40 | |
41 SharedRendererState* shared_renderer_state_; | 69 SharedRendererState* shared_renderer_state_; |
42 | 70 |
43 typedef void* EGLContext; | 71 typedef void* EGLContext; |
44 EGLContext last_egl_context_; | 72 EGLContext last_egl_context_; |
45 | 73 |
74 int view_width_; | |
75 int view_height_; | |
76 gfx::Vector2d scroll_offset_; | |
77 | |
46 scoped_refptr<AwGLSurface> gl_surface_; | 78 scoped_refptr<AwGLSurface> gl_surface_; |
47 | 79 |
80 scoped_ptr<cc::LayerTreeHost> layer_tree_host_; | |
81 scoped_refptr<cc::Layer> root_layer_; | |
82 | |
83 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; | |
84 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; | |
85 scoped_refptr<cc::DelegatedRendererLayer> layer_; | |
danakj
2014/05/20 21:50:02
better name please, which layer?
boliu
2014/05/21 01:33:26
Umm...delegated_layer_?
There's the root, and the
danakj
2014/05/21 15:22:54
Yes, sure, that's much better :)
| |
86 | |
87 scoped_ptr<ParentOutputSurface> output_surface_holder_; | |
88 base::WeakPtr<ParentOutputSurface> output_surface_; | |
danakj
2014/05/20 21:50:02
can name this output_surface_weak_ptr_? then it's
boliu
2014/05/21 01:33:26
Done.
| |
89 | |
48 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); | 90 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); |
49 }; | 91 }; |
50 | 92 |
51 } // namespace android_webview | 93 } // namespace android_webview |
52 | 94 |
53 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ | 95 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ |
OLD | NEW |