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/parent_compositor_draw_constraints.h"
9 #include "android_webview/browser/shared_renderer_state.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/layers/delegated_frame_resource_collection.h"
12 #include "cc/trees/layer_tree_host_client.h"
13 #include "cc/trees/layer_tree_host_single_thread_client.h"
18 class DelegatedFrameProvider
;
19 class DelegatedRendererLayer
;
24 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 virtual ~HardwareRenderer();
36 void DrawGL(bool stencil_enabled
,
37 int framebuffer_binding_ext
,
38 AwDrawGLInfo
* draw_info
);
41 // cc::LayerTreeHostClient overrides.
42 virtual void WillBeginMainFrame(int frame_id
) override
{}
43 virtual void DidBeginMainFrame() override
;
44 virtual void BeginMainFrame(const cc::BeginFrameArgs
& args
) override
{}
45 virtual void Layout() override
{}
46 virtual void ApplyViewportDeltas(
47 const gfx::Vector2d
& inner_delta
,
48 const gfx::Vector2d
& outer_delta
,
49 const gfx::Vector2dF
& elastic_overscroll_delta
,
51 float top_controls_delta
) override
{}
52 virtual void ApplyViewportDeltas(const gfx::Vector2d
& scroll_delta
,
54 float top_controls_delta
) override
{}
55 virtual void RequestNewOutputSurface() override
;
56 virtual void DidInitializeOutputSurface() override
{}
57 virtual void DidFailToInitializeOutputSurface() override
;
58 virtual void WillCommit() override
{}
59 virtual void DidCommit() override
{}
60 virtual void DidCommitAndDrawFrame() override
{}
61 virtual void DidCompleteSwapBuffers() override
{}
63 // cc::LayerTreeHostSingleThreadClient overrides.
64 virtual void DidPostSwapBuffers() override
{}
65 virtual void DidAbortSwapBuffers() override
{}
67 // cc::DelegatedFrameResourceCollectionClient overrides.
68 virtual void UnusedResourcesAreAvailable() override
;
73 SharedRendererState
* shared_renderer_state_
;
75 typedef void* EGLContext
;
76 EGLContext last_egl_context_
;
78 scoped_ptr
<cc::CompositorFrame
> committed_frame_
;
80 // Information about last delegated frame.
81 gfx::Size frame_size_
;
83 // Infromation from UI on last commit.
84 gfx::Vector2d scroll_offset_
;
86 // Information from draw.
89 bool stencil_enabled_
;
90 bool viewport_clip_valid_for_dcheck_
;
92 scoped_refptr
<AwGLSurface
> gl_surface_
;
94 scoped_ptr
<cc::LayerTreeHost
> layer_tree_host_
;
95 scoped_refptr
<cc::Layer
> root_layer_
;
97 scoped_refptr
<cc::DelegatedFrameResourceCollection
> resource_collection_
;
98 scoped_refptr
<cc::DelegatedFrameProvider
> frame_provider_
;
99 scoped_refptr
<cc::DelegatedRendererLayer
> delegated_layer_
;
101 // This is owned indirectly by |layer_tree_host_|.
102 ParentOutputSurface
* output_surface_
;
104 ParentCompositorDrawConstraints draw_constraints_
;
106 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer
);
109 } // namespace android_webview
111 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_