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
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
8 #include "android_webview/browser/shared_renderer_state.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/layers/delegated_frame_resource_collection.h"
11 #include "cc/trees/layer_tree_host_client.h"
12 #include "cc/trees/layer_tree_host_single_thread_client.h"
17 class DelegatedFrameProvider
;
18 class DelegatedRendererLayer
;
23 namespace android_webview
{
27 class ParentOutputSurface
;
29 class HardwareRenderer
: public cc::LayerTreeHostClient
,
30 public cc::LayerTreeHostSingleThreadClient
,
31 public cc::DelegatedFrameResourceCollectionClient
{
33 explicit HardwareRenderer(SharedRendererState
* state
);
34 ~HardwareRenderer() override
;
36 void DrawGL(bool stencil_enabled
,
37 int framebuffer_binding_ext
,
38 AwDrawGLInfo
* draw_info
);
41 // cc::LayerTreeHostClient overrides.
42 void WillBeginMainFrame() override
{}
43 void DidBeginMainFrame() override
;
44 void BeginMainFrame(const cc::BeginFrameArgs
& args
) override
{}
45 void BeginMainFrameNotExpectedSoon() override
{}
46 void Layout() override
{}
47 void ApplyViewportDeltas(const gfx::Vector2dF
& inner_delta
,
48 const gfx::Vector2dF
& outer_delta
,
49 const gfx::Vector2dF
& elastic_overscroll_delta
,
51 float top_controls_delta
) override
{}
52 void ApplyViewportDeltas(const gfx::Vector2d
& scroll_delta
,
54 float top_controls_delta
) override
{}
55 void RequestNewOutputSurface() override
;
56 void DidInitializeOutputSurface() override
{}
57 void DidFailToInitializeOutputSurface() override
;
58 void WillCommit() override
{}
59 void DidCommit() override
{}
60 void DidCommitAndDrawFrame() override
{}
61 void DidCompleteSwapBuffers() override
{}
62 void DidCompletePageScaleAnimation() override
{}
64 // cc::LayerTreeHostSingleThreadClient overrides.
65 void DidPostSwapBuffers() override
{}
66 void DidAbortSwapBuffers() override
{}
68 // cc::DelegatedFrameResourceCollectionClient overrides.
69 void UnusedResourcesAreAvailable() override
;
72 SharedRendererState
* shared_renderer_state_
;
74 typedef void* EGLContext
;
75 EGLContext last_egl_context_
;
77 // Information about last delegated frame.
78 gfx::Size frame_size_
;
80 // Infromation from UI on last commit.
81 gfx::Vector2d scroll_offset_
;
83 // Information from draw.
86 bool stencil_enabled_
;
87 bool viewport_clip_valid_for_dcheck_
;
89 scoped_ptr
<ChildFrame
> child_frame_
;
91 scoped_refptr
<AwGLSurface
> gl_surface_
;
93 scoped_ptr
<cc::LayerTreeHost
> layer_tree_host_
;
94 scoped_refptr
<cc::Layer
> root_layer_
;
96 scoped_refptr
<cc::DelegatedFrameResourceCollection
> resource_collection_
;
97 scoped_refptr
<cc::DelegatedFrameProvider
> frame_provider_
;
98 scoped_refptr
<cc::DelegatedRendererLayer
> delegated_layer_
;
100 // This is owned indirectly by |layer_tree_host_|.
101 ParentOutputSurface
* output_surface_
;
103 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer
);
106 } // namespace android_webview
108 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_