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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_impl.cc

Issue 256303006: Make LayerScrollOffsetDelegate updates consistent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: less jni Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/android/in_process/synchronous_compositor_impl.h" 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/input/input_handler.h" 9 #include "cc/input/input_handler.h"
10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h" 10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 contents_->GetRenderWidgetHostView()); 218 contents_->GetRenderWidgetHostView());
219 if (rwhv) 219 if (rwhv)
220 rwhv->SynchronousFrameMetadata(frame_metadata); 220 rwhv->SynchronousFrameMetadata(frame_metadata);
221 } 221 }
222 222
223 void SynchronousCompositorImpl::DidActivatePendingTree() { 223 void SynchronousCompositorImpl::DidActivatePendingTree() {
224 if (compositor_client_) 224 if (compositor_client_)
225 compositor_client_->DidUpdateContent(); 225 compositor_client_->DidUpdateContent();
226 } 226 }
227 227
228 void SynchronousCompositorImpl::SetMaxScrollOffset(
229 const gfx::Vector2dF& max_scroll_offset) {
230 DCHECK(CalledOnValidThread());
231 if (compositor_client_)
232 compositor_client_->SetMaxRootLayerScrollOffset(max_scroll_offset);
233 }
234
235 void SynchronousCompositorImpl::SetTotalScrollOffset( 228 void SynchronousCompositorImpl::SetTotalScrollOffset(
236 const gfx::Vector2dF& new_value) { 229 const gfx::Vector2dF& new_value) {
237 DCHECK(CalledOnValidThread()); 230 DCHECK(CalledOnValidThread());
238 if (compositor_client_) 231 if (compositor_client_)
239 compositor_client_->SetTotalRootLayerScrollOffset(new_value); 232 compositor_client_->SetTotalRootLayerScrollOffset(new_value);
240 } 233 }
241 234
242 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { 235 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() {
243 DCHECK(CalledOnValidThread()); 236 DCHECK(CalledOnValidThread());
244 if (compositor_client_) 237 if (compositor_client_)
245 return compositor_client_->GetTotalRootLayerScrollOffset(); 238 return compositor_client_->GetTotalRootLayerScrollOffset();
246 return gfx::Vector2dF(); 239 return gfx::Vector2dF();
247 } 240 }
248 241
249 bool SynchronousCompositorImpl::IsExternalFlingActive() const { 242 bool SynchronousCompositorImpl::IsExternalFlingActive() const {
250 DCHECK(CalledOnValidThread()); 243 DCHECK(CalledOnValidThread());
251 if (compositor_client_) 244 if (compositor_client_)
252 return compositor_client_->IsExternalFlingActive(); 245 return compositor_client_->IsExternalFlingActive();
253 return false; 246 return false;
254 } 247 }
255 248
256 void SynchronousCompositorImpl::SetTotalPageScaleFactorAndLimits( 249 void SynchronousCompositorImpl::UpdateRootLayerState(
250 const gfx::Vector2dF& total_scroll_offset,
251 const gfx::Vector2dF& max_scroll_offset,
252 const gfx::SizeF& scrollable_size,
257 float page_scale_factor, 253 float page_scale_factor,
258 float min_page_scale_factor, 254 float min_page_scale_factor,
259 float max_page_scale_factor) { 255 float max_page_scale_factor) {
260 DCHECK(CalledOnValidThread()); 256 DCHECK(CalledOnValidThread());
261 if (compositor_client_) 257 if (!compositor_client_)
262 compositor_client_->SetRootLayerPageScaleFactorAndLimits( 258 return;
263 page_scale_factor, min_page_scale_factor, max_page_scale_factor);
264 }
265 259
266 void SynchronousCompositorImpl::SetScrollableSize( 260 compositor_client_->UpdateRootLayerState(total_scroll_offset,
267 const gfx::SizeF& scrollable_size) { 261 max_scroll_offset,
268 DCHECK(CalledOnValidThread()); 262 scrollable_size,
269 if (compositor_client_) 263 page_scale_factor,
270 compositor_client_->SetRootLayerScrollableSize(scrollable_size); 264 min_page_scale_factor,
265 max_page_scale_factor);
271 } 266 }
272 267
273 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 268 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
274 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. 269 // requirement: SynchronousCompositorImpl() must only be used on the UI thread.
275 bool SynchronousCompositorImpl::CalledOnValidThread() const { 270 bool SynchronousCompositorImpl::CalledOnValidThread() const {
276 return BrowserThread::CurrentlyOn(BrowserThread::UI); 271 return BrowserThread::CurrentlyOn(BrowserThread::UI);
277 } 272 }
278 273
279 // static 274 // static
280 void SynchronousCompositor::SetClientForWebContents( 275 void SynchronousCompositor::SetClientForWebContents(
281 WebContents* contents, 276 WebContents* contents,
282 SynchronousCompositorClient* client) { 277 SynchronousCompositorClient* client) {
283 DCHECK(contents); 278 DCHECK(contents);
284 if (client) { 279 if (client) {
285 g_factory.Get(); // Ensure it's initialized. 280 g_factory.Get(); // Ensure it's initialized.
286 SynchronousCompositorImpl::CreateForWebContents(contents); 281 SynchronousCompositorImpl::CreateForWebContents(contents);
287 } 282 }
288 if (SynchronousCompositorImpl* instance = 283 if (SynchronousCompositorImpl* instance =
289 SynchronousCompositorImpl::FromWebContents(contents)) { 284 SynchronousCompositorImpl::FromWebContents(contents)) {
290 instance->SetClient(client); 285 instance->SetClient(client);
291 } 286 }
292 } 287 }
293 288
294 } // namespace content 289 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698