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 {
26 class ParentOutputSurface;
28 class HardwareRenderer : public cc::LayerTreeHostClient,
29 public cc::LayerTreeHostSingleThreadClient,
30 public cc::DelegatedFrameResourceCollectionClient {
32 explicit HardwareRenderer(SharedRendererState* state);
33 virtual ~HardwareRenderer();
35 void DrawGL(bool stencil_enabled,
36 int framebuffer_binding_ext,
37 AwDrawGLInfo* draw_info);
40 // cc::LayerTreeHostClient overrides.
41 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
42 virtual void DidBeginMainFrame() OVERRIDE;
43 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {}
44 virtual void Layout() OVERRIDE {}
45 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
46 float page_scale) OVERRIDE {}
47 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
48 bool fallback) OVERRIDE;
49 virtual void DidInitializeOutputSurface() OVERRIDE {}
50 virtual void WillCommit() OVERRIDE {}
51 virtual void DidCommit() OVERRIDE {}
52 virtual void DidCommitAndDrawFrame() OVERRIDE {}
53 virtual void DidCompleteSwapBuffers() OVERRIDE {}
55 // cc::LayerTreeHostSingleThreadClient overrides.
56 virtual void ScheduleComposite() OVERRIDE {}
57 virtual void ScheduleAnimation() OVERRIDE {}
58 virtual void DidPostSwapBuffers() OVERRIDE {}
59 virtual void DidAbortSwapBuffers() OVERRIDE {}
61 // cc::DelegatedFrameResourceCollectionClient overrides.
62 virtual void UnusedResourcesAreAvailable() OVERRIDE;
65 SharedRendererState* shared_renderer_state_;
67 typedef void* EGLContext;
68 EGLContext last_egl_context_;
70 // Information about last delegated frame.
71 gfx::Size frame_size_;
72 gfx::Vector2d scroll_offset_;
74 // Information from draw.
77 bool stencil_enabled_;
78 bool viewport_clip_valid_for_dcheck_;
80 scoped_refptr<AwGLSurface> gl_surface_;
82 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
83 scoped_refptr<cc::Layer> root_layer_;
85 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
86 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
87 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
89 // This is owned indirectly by |layer_tree_host_|.
90 ParentOutputSurface* output_surface_;
92 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer);
95 } // namespace android_webview
97 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_