OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
12 #include "cc/resources/ui_resource_client.h" | 13 #include "cc/resources/ui_resource_client.h" |
13 #include "cc/trees/layer_tree_host_client.h" | 14 #include "cc/trees/layer_tree_host_client.h" |
14 #include "cc/trees/layer_tree_host_single_thread_client.h" | 15 #include "cc/trees/layer_tree_host_single_thread_client.h" |
15 #include "content/browser/renderer_host/image_transport_factory_android.h" | 16 #include "content/browser/renderer_host/image_transport_factory_android.h" |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 #include "content/public/browser/android/compositor.h" | 18 #include "content/public/browser/android/compositor.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
19 #include "ui/base/android/window_android_compositor.h" | 20 #include "ui/base/android/window_android_compositor.h" |
20 | 21 |
21 class SkBitmap; | 22 class SkBitmap; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Compositor implementation. | 57 // Compositor implementation. |
57 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 58 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
58 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 59 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
59 virtual void SetSurface(jobject surface) OVERRIDE; | 60 virtual void SetSurface(jobject surface) OVERRIDE; |
60 virtual void SetVisible(bool visible) OVERRIDE; | 61 virtual void SetVisible(bool visible) OVERRIDE; |
61 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 62 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
62 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 63 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
63 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 64 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
64 virtual bool CompositeAndReadback( | 65 virtual bool CompositeAndReadback( |
65 void *pixels, const gfx::Rect& rect) OVERRIDE; | 66 void *pixels, const gfx::Rect& rect) OVERRIDE; |
66 virtual void Composite() OVERRIDE; | |
67 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, | 67 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, |
68 bool is_transient) OVERRIDE; | 68 bool is_transient) OVERRIDE; |
69 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, | 69 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, |
70 void* pixels, | 70 void* pixels, |
71 bool is_transient) | 71 bool is_transient) |
72 OVERRIDE; | 72 OVERRIDE; |
73 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; | 73 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; |
74 | 74 |
75 // LayerTreeHostClient implementation. | 75 // LayerTreeHostClient implementation. |
76 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 76 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
77 virtual void DidBeginMainFrame() OVERRIDE {} | 77 virtual void DidBeginMainFrame() OVERRIDE {} |
78 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 78 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} |
79 virtual void Layout() OVERRIDE {} | 79 virtual void Layout() OVERRIDE; |
80 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 80 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
81 float page_scale) OVERRIDE {} | 81 float page_scale) OVERRIDE {} |
82 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 82 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
83 OVERRIDE; | 83 OVERRIDE; |
84 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} | 84 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} |
85 virtual void WillCommit() OVERRIDE {} | 85 virtual void WillCommit() OVERRIDE {} |
86 virtual void DidCommit() OVERRIDE; | 86 virtual void DidCommit() OVERRIDE; |
87 virtual void DidCommitAndDrawFrame() OVERRIDE {} | 87 virtual void DidCommitAndDrawFrame() OVERRIDE {} |
88 virtual void DidCompleteSwapBuffers() OVERRIDE; | 88 virtual void DidCompleteSwapBuffers() OVERRIDE; |
89 virtual scoped_refptr<cc::ContextProvider> | 89 virtual scoped_refptr<cc::ContextProvider> |
90 OffscreenContextProvider() OVERRIDE; | 90 OffscreenContextProvider() OVERRIDE; |
91 | 91 |
92 // LayerTreeHostSingleThreadClient implementation. | 92 // LayerTreeHostSingleThreadClient implementation. |
93 virtual void ScheduleComposite() OVERRIDE; | 93 virtual void ScheduleComposite() OVERRIDE; |
94 virtual void ScheduleAnimation() OVERRIDE; | 94 virtual void ScheduleAnimation() OVERRIDE; |
95 virtual void DidPostSwapBuffers() OVERRIDE; | 95 virtual void DidPostSwapBuffers() OVERRIDE; |
96 virtual void DidAbortSwapBuffers() OVERRIDE; | 96 virtual void DidAbortSwapBuffers() OVERRIDE; |
97 | 97 |
98 // ImageTransportFactoryAndroidObserver implementation. | 98 // ImageTransportFactoryAndroidObserver implementation. |
99 virtual void OnLostResources() OVERRIDE; | 99 virtual void OnLostResources() OVERRIDE; |
100 | 100 |
101 // WindowAndroidCompositor implementation. | 101 // WindowAndroidCompositor implementation. |
102 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 102 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
| 103 virtual void OnVSync(base::TimeTicks frame_time, |
| 104 base::TimeDelta vsync_period) OVERRIDE; |
103 | 105 |
104 private: | 106 private: |
| 107 void Composite(bool is_vsync); |
105 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | 108 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
106 const cc::UIResourceBitmap& bitmap, | 109 const cc::UIResourceBitmap& bitmap, |
107 bool is_transient); | 110 bool is_transient); |
108 | 111 |
109 scoped_refptr<cc::Layer> root_layer_; | 112 scoped_refptr<cc::Layer> root_layer_; |
110 scoped_ptr<cc::LayerTreeHost> host_; | 113 scoped_ptr<cc::LayerTreeHost> host_; |
111 | 114 |
112 gfx::Size size_; | 115 gfx::Size size_; |
113 bool has_transparent_background_; | 116 bool has_transparent_background_; |
114 float device_scale_factor_; | 117 float device_scale_factor_; |
115 | 118 |
116 ANativeWindow* window_; | 119 ANativeWindow* window_; |
117 int surface_id_; | 120 int surface_id_; |
118 | 121 |
119 CompositorClient* client_; | 122 CompositorClient* client_; |
120 | 123 |
121 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; | 124 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; |
122 | 125 |
123 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> | 126 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> |
124 UIResourceMap; | 127 UIResourceMap; |
125 UIResourceMap ui_resource_map_; | 128 UIResourceMap ui_resource_map_; |
126 | 129 |
127 gfx::NativeWindow root_window_; | 130 gfx::NativeWindow root_window_; |
128 | 131 |
| 132 bool did_post_swapbuffers_; |
| 133 bool need_to_composite_; |
| 134 bool can_composite_outside_vsync_; |
| 135 unsigned int pending_swapbuffers_; |
| 136 |
| 137 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
| 138 |
129 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 139 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
130 }; | 140 }; |
131 | 141 |
132 } // namespace content | 142 } // namespace content |
133 | 143 |
134 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 144 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |