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/hardware_renderer_interface.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 HardwareRendererInterface
,
30 public cc::LayerTreeHostClient
,
31 public cc::LayerTreeHostSingleThreadClient
,
32 public cc::DelegatedFrameResourceCollectionClient
{
34 explicit HardwareRenderer(SharedRendererState
* state
);
35 virtual ~HardwareRenderer();
37 // HardwareRendererInterface overrides.
38 virtual bool DrawGL(bool stencil_enabled
,
39 int framebuffer_binding_ext
,
40 AwDrawGLInfo
* draw_info
,
41 DrawGLResult
* result
) OVERRIDE
;
43 // cc::LayerTreeHostClient overrides.
44 virtual void WillBeginMainFrame(int frame_id
) OVERRIDE
{}
45 virtual void DidBeginMainFrame() OVERRIDE
;
46 virtual void Animate(base::TimeTicks frame_begin_time
) OVERRIDE
{}
47 virtual void Layout() OVERRIDE
{}
48 virtual void ApplyScrollAndScale(const gfx::Vector2d
& scroll_delta
,
49 float page_scale
) OVERRIDE
{}
50 virtual scoped_ptr
<cc::OutputSurface
> CreateOutputSurface(
51 bool fallback
) OVERRIDE
;
52 virtual void DidInitializeOutputSurface() OVERRIDE
{}
53 virtual void WillCommit() OVERRIDE
{}
54 virtual void DidCommit() OVERRIDE
{}
55 virtual void DidCommitAndDrawFrame() OVERRIDE
{}
56 virtual void DidCompleteSwapBuffers() OVERRIDE
{}
58 // cc::LayerTreeHostSingleThreadClient overrides.
59 virtual void ScheduleComposite() OVERRIDE
{}
60 virtual void ScheduleAnimation() OVERRIDE
{}
61 virtual void DidPostSwapBuffers() OVERRIDE
{}
62 virtual void DidAbortSwapBuffers() OVERRIDE
{}
64 // cc::DelegatedFrameResourceCollectionClient overrides.
65 virtual void UnusedResourcesAreAvailable() OVERRIDE
;
68 SharedRendererState
* shared_renderer_state_
;
70 typedef void* EGLContext
;
71 EGLContext last_egl_context_
;
73 // Information about last delegated frame.
76 gfx::Vector2d scroll_offset_
;
78 // Information from draw.
81 bool viewport_clip_valid_for_dcheck_
;
83 scoped_refptr
<AwGLSurface
> gl_surface_
;
85 scoped_ptr
<cc::LayerTreeHost
> layer_tree_host_
;
86 scoped_refptr
<cc::Layer
> root_layer_
;
88 scoped_refptr
<cc::DelegatedFrameResourceCollection
> resource_collection_
;
89 scoped_refptr
<cc::DelegatedFrameProvider
> frame_provider_
;
90 scoped_refptr
<cc::DelegatedRendererLayer
> delegated_layer_
;
92 // This is owned indirectly by |layer_tree_host_|.
93 ParentOutputSurface
* output_surface_
;
95 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer
);
98 } // namespace android_webview
100 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_