Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.h

Issue 285373008: Android: Decouple animate from vsync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/cancelable_callback.h"
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 11 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "cc/resources/ui_resource_client.h" 13 #include "cc/resources/ui_resource_client.h"
14 #include "cc/trees/layer_tree_host_client.h" 14 #include "cc/trees/layer_tree_host_client.h"
15 #include "cc/trees/layer_tree_host_single_thread_client.h" 15 #include "cc/trees/layer_tree_host_single_thread_client.h"
16 #include "content/browser/renderer_host/image_transport_factory_android.h" 16 #include "content/browser/renderer_host/image_transport_factory_android.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/public/browser/android/compositor.h" 18 #include "content/public/browser/android/compositor.h"
19 #include "third_party/khronos/GLES2/gl2.h" 19 #include "third_party/khronos/GLES2/gl2.h"
20 #include "ui/base/android/window_android_compositor.h" 20 #include "ui/base/android/window_android_compositor.h"
21 21
22 class SkBitmap; 22 class SkBitmap;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RequestCopyOfOutputOnRootLayer( 103 virtual void RequestCopyOfOutputOnRootLayer(
104 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; 104 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE;
105 virtual void OnVSync(base::TimeTicks frame_time, 105 virtual void OnVSync(base::TimeTicks frame_time,
106 base::TimeDelta vsync_period) OVERRIDE; 106 base::TimeDelta vsync_period) OVERRIDE;
107 virtual void SetNeedsAnimate() OVERRIDE;
107 108
108 void PostComposite(base::TimeDelta delay);
109 enum CompositingTrigger { 109 enum CompositingTrigger {
110 DO_NOT_COMPOSITE,
110 COMPOSITE_IMMEDIATELY, 111 COMPOSITE_IMMEDIATELY,
111 COMPOSITE_ON_VSYNC 112 COMPOSITE_EVENTUALLY,
112 }; 113 };
114 void PostComposite(CompositingTrigger trigger);
113 void Composite(CompositingTrigger trigger); 115 void Composite(CompositingTrigger trigger);
116
117 bool WillCompositeThisFrame() {
Sami 2014/05/27 19:54:05 nit: These three methods could be const.
no sievers 2014/05/27 20:05:17 Done.
118 return current_composite_task_ &&
119 !current_composite_task_->callback().is_null();
120 }
121 bool DidCompositeThisFrame() {
122 return current_composite_task_ &&
123 current_composite_task_->callback().is_null();
124 }
125 bool WillComposite() {
126 return WillCompositeThisFrame() ||
127 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE;
128 }
129 void CancelComposite() {
130 DCHECK(WillComposite());
131 if (WillCompositeThisFrame())
132 current_composite_task_->Cancel();
133 current_composite_task_.reset();
134 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE;
135 will_composite_immediately_ = false;
136 }
114 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( 137 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap(
115 const cc::UIResourceBitmap& bitmap, 138 const cc::UIResourceBitmap& bitmap,
116 bool is_transient); 139 bool is_transient);
117 140
118 scoped_refptr<cc::Layer> root_layer_; 141 scoped_refptr<cc::Layer> root_layer_;
119 scoped_ptr<cc::LayerTreeHost> host_; 142 scoped_ptr<cc::LayerTreeHost> host_;
120 143
121 gfx::Size size_; 144 gfx::Size size_;
122 bool has_transparent_background_; 145 bool has_transparent_background_;
123 float device_scale_factor_; 146 float device_scale_factor_;
(...skipping 13 matching lines...) Expand all
137 // a posted SwapBuffers(). 160 // a posted SwapBuffers().
138 bool did_post_swapbuffers_; 161 bool did_post_swapbuffers_;
139 162
140 // Used locally to inhibit ScheduleComposite() during Layout(). 163 // Used locally to inhibit ScheduleComposite() during Layout().
141 bool ignore_schedule_composite_; 164 bool ignore_schedule_composite_;
142 165
143 // Whether we need to composite in general because of any invalidation or 166 // Whether we need to composite in general because of any invalidation or
144 // explicit request. 167 // explicit request.
145 bool needs_composite_; 168 bool needs_composite_;
146 169
147 // When SetNeedsComposite() is getting called, we will try to schedule 170 // Whether we need to update animations on the next composite.
148 // regularly during vsync. 171 bool needs_animate_;
149 bool should_composite_on_vsync_;
150 172
151 // Whether we composited already in the current vsync interval. 173 // Whether we posted a task and are about to composite.
152 bool did_composite_this_frame_; 174 bool will_composite_immediately_;
175
176 // How we should schedule Composite during the next vsync.
177 CompositingTrigger composite_on_vsync_trigger_;
178
179 // The Composite operation scheduled for the current vsync interval.
180 scoped_ptr<base::CancelableClosure> current_composite_task_;
153 181
154 // The number of SwapBuffer calls that have not returned and ACK'd from 182 // The number of SwapBuffer calls that have not returned and ACK'd from
155 // the GPU thread. 183 // the GPU thread.
156 unsigned int pending_swapbuffers_; 184 unsigned int pending_swapbuffers_;
157 185
158 base::TimeDelta vsync_period_; 186 base::TimeDelta vsync_period_;
159 187 base::TimeTicks last_vsync_;
160 base::WeakPtrFactory<CompositorImpl> weak_factory_;
161 188
162 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); 189 DISALLOW_COPY_AND_ASSIGN(CompositorImpl);
163 }; 190 };
164 191
165 } // namespace content 192 } // namespace content
166 193
167 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 194 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698