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

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: fix build break 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 contents_->GetRenderWidgetHostView()); 217 contents_->GetRenderWidgetHostView());
218 if (rwhv) 218 if (rwhv)
219 rwhv->SynchronousFrameMetadata(frame_metadata); 219 rwhv->SynchronousFrameMetadata(frame_metadata);
220 } 220 }
221 221
222 void SynchronousCompositorImpl::DidActivatePendingTree() { 222 void SynchronousCompositorImpl::DidActivatePendingTree() {
223 if (compositor_client_) 223 if (compositor_client_)
224 compositor_client_->DidUpdateContent(); 224 compositor_client_->DidUpdateContent();
225 } 225 }
226 226
227 void SynchronousCompositorImpl::SetMaxScrollOffset(
228 const gfx::Vector2dF& max_scroll_offset) {
229 DCHECK(CalledOnValidThread());
230 if (compositor_client_)
231 compositor_client_->SetMaxRootLayerScrollOffset(max_scroll_offset);
232 }
233
234 void SynchronousCompositorImpl::SetTotalScrollOffset(
235 const gfx::Vector2dF& new_value) {
236 DCHECK(CalledOnValidThread());
237 if (compositor_client_)
238 compositor_client_->SetTotalRootLayerScrollOffset(new_value);
239 }
240
241 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { 227 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() {
242 DCHECK(CalledOnValidThread()); 228 DCHECK(CalledOnValidThread());
243 if (compositor_client_) 229 if (compositor_client_)
244 return compositor_client_->GetTotalRootLayerScrollOffset(); 230 return compositor_client_->GetTotalRootLayerScrollOffset();
245 return gfx::Vector2dF(); 231 return gfx::Vector2dF();
246 } 232 }
247 233
248 bool SynchronousCompositorImpl::IsExternalFlingActive() const { 234 bool SynchronousCompositorImpl::IsExternalFlingActive() const {
249 DCHECK(CalledOnValidThread()); 235 DCHECK(CalledOnValidThread());
250 if (compositor_client_) 236 if (compositor_client_)
251 return compositor_client_->IsExternalFlingActive(); 237 return compositor_client_->IsExternalFlingActive();
252 return false; 238 return false;
253 } 239 }
254 240
255 void SynchronousCompositorImpl::SetTotalPageScaleFactorAndLimits( 241 void SynchronousCompositorImpl::UpdateRootLayerState(
242 const gfx::Vector2dF& total_scroll_offset,
243 const gfx::Vector2dF& max_scroll_offset,
244 const gfx::SizeF& scrollable_size,
256 float page_scale_factor, 245 float page_scale_factor,
257 float min_page_scale_factor, 246 float min_page_scale_factor,
258 float max_page_scale_factor) { 247 float max_page_scale_factor) {
259 DCHECK(CalledOnValidThread()); 248 DCHECK(CalledOnValidThread());
260 if (compositor_client_) 249 if (!compositor_client_)
261 compositor_client_->SetRootLayerPageScaleFactorAndLimits( 250 return;
262 page_scale_factor, min_page_scale_factor, max_page_scale_factor);
263 }
264 251
265 void SynchronousCompositorImpl::SetScrollableSize( 252 compositor_client_->UpdateRootLayerState(total_scroll_offset,
266 const gfx::SizeF& scrollable_size) { 253 max_scroll_offset,
267 DCHECK(CalledOnValidThread()); 254 scrollable_size,
268 if (compositor_client_) 255 page_scale_factor,
269 compositor_client_->SetRootLayerScrollableSize(scrollable_size); 256 min_page_scale_factor,
257 max_page_scale_factor);
270 } 258 }
271 259
272 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 260 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
273 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. 261 // requirement: SynchronousCompositorImpl() must only be used on the UI thread.
274 bool SynchronousCompositorImpl::CalledOnValidThread() const { 262 bool SynchronousCompositorImpl::CalledOnValidThread() const {
275 return BrowserThread::CurrentlyOn(BrowserThread::UI); 263 return BrowserThread::CurrentlyOn(BrowserThread::UI);
276 } 264 }
277 265
278 // static 266 // static
279 void SynchronousCompositor::SetClientForWebContents( 267 void SynchronousCompositor::SetClientForWebContents(
280 WebContents* contents, 268 WebContents* contents,
281 SynchronousCompositorClient* client) { 269 SynchronousCompositorClient* client) {
282 DCHECK(contents); 270 DCHECK(contents);
283 if (client) { 271 if (client) {
284 g_factory.Get(); // Ensure it's initialized. 272 g_factory.Get(); // Ensure it's initialized.
285 SynchronousCompositorImpl::CreateForWebContents(contents); 273 SynchronousCompositorImpl::CreateForWebContents(contents);
286 } 274 }
287 if (SynchronousCompositorImpl* instance = 275 if (SynchronousCompositorImpl* instance =
288 SynchronousCompositorImpl::FromWebContents(contents)) { 276 SynchronousCompositorImpl::FromWebContents(contents)) {
289 instance->SetClient(client); 277 instance->SetClient(client);
290 } 278 }
291 } 279 }
292 280
293 } // namespace content 281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698