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

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

Powered by Google App Engine
This is Rietveld 408576698