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

Side by Side Diff: cc/layer_tree_host.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revised architecture - complete cl for comments on approach. Created 7 years, 10 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "cc/animation_registrar.h" 12 #include "cc/animation_registrar.h"
13 #include "cc/font_atlas.h" 13 #include "cc/font_atlas.h"
14 #include "cc/heads_up_display_layer.h" 14 #include "cc/heads_up_display_layer.h"
15 #include "cc/heads_up_display_layer_impl.h" 15 #include "cc/heads_up_display_layer_impl.h"
16 #include "cc/layer.h" 16 #include "cc/layer.h"
17 #include "cc/layer_animation_controller.h" 17 #include "cc/layer_animation_controller.h"
18 #include "cc/layer_iterator.h" 18 #include "cc/layer_iterator.h"
19 #include "cc/layer_tree_host_client.h" 19 #include "cc/layer_tree_host_client.h"
20 #include "cc/layer_tree_host_common.h" 20 #include "cc/layer_tree_host_common.h"
21 #include "cc/layer_tree_host_impl.h" 21 #include "cc/layer_tree_host_impl.h"
22 #include "cc/layer_tree_impl.h" 22 #include "cc/layer_tree_impl.h"
23 #include "cc/math_util.h" 23 #include "cc/math_util.h"
24 #include "cc/occlusion_tracker.h" 24 #include "cc/occlusion_tracker.h"
25 #include "cc/overdraw_metrics.h" 25 #include "cc/overdraw_metrics.h"
26 #include "cc/pinch_zoom_scrollbar.h"
27 #include "cc/pinch_zoom_scrollbar_painter.h"
26 #include "cc/prioritized_resource_manager.h" 28 #include "cc/prioritized_resource_manager.h"
29 #include "cc/scrollbar_layer.h"
27 #include "cc/single_thread_proxy.h" 30 #include "cc/single_thread_proxy.h"
28 #include "cc/switches.h" 31 #include "cc/switches.h"
29 #include "cc/thread.h" 32 #include "cc/thread.h"
30 #include "cc/thread_proxy.h" 33 #include "cc/thread_proxy.h"
31 #include "cc/top_controls_manager.h" 34 #include "cc/top_controls_manager.h"
32 #include "cc/tree_synchronizer.h" 35 #include "cc/tree_synchronizer.h"
33 36
34 namespace { 37 namespace {
35 static int numLayerTreeInstances; 38 static int numLayerTreeInstances;
36 } 39 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 hostImpl->savePaintTime(m_renderingStats.totalPaintTime); 328 hostImpl->savePaintTime(m_renderingStats.totalPaintTime);
326 329
327 if (newImplTreeHasNoEvictedResources) { 330 if (newImplTreeHasNoEvictedResources) {
328 if (syncTree->ContentsTexturesPurged()) 331 if (syncTree->ContentsTexturesPurged())
329 syncTree->ResetContentsTexturesPurged(); 332 syncTree->ResetContentsTexturesPurged();
330 } 333 }
331 334
332 m_commitNumber++; 335 m_commitNumber++;
333 } 336 }
334 337
338 void LayerTreeHost::setPinchZoomScrollbarPropertiesIfNeeded()
339 {
340 gfx::Size size = layoutViewportSize();
341 int trackWidth = PinchZoomScrollbar::kTrackWidth;
342 Layer* rootScrollLayer = this->rootScrollLayer();
343 int rootScrollLayerId = rootScrollLayer ? rootScrollLayer->id() : 0;
344 if (m_pinchZoomScrollbarHorizontal) {
345 m_pinchZoomScrollbarHorizontal->setBounds(gfx::Size(size.width() - track Width, trackWidth));
346 m_pinchZoomScrollbarHorizontal->setPosition(gfx::PointF(0, size.height() - trackWidth));
347 m_pinchZoomScrollbarHorizontal->setIsDrawable(true);
348 m_pinchZoomScrollbarHorizontal->setOpacity(0.5);
349 m_pinchZoomScrollbarHorizontal->setNeedsDisplay();
350 m_pinchZoomScrollbarHorizontal->setScrollLayerId(rootScrollLayerId);
351 }
352 if (m_pinchZoomScrollbarVertical) {
353 m_pinchZoomScrollbarVertical->setBounds(gfx::Size(10, size.height() - 10 ));
354 m_pinchZoomScrollbarVertical->setPosition(gfx::PointF(size.width() - 10, 0));
355 m_pinchZoomScrollbarVertical->setIsDrawable(true);
356 m_pinchZoomScrollbarVertical->setOpacity(0.5);
357 m_pinchZoomScrollbarVertical->setNeedsDisplay();
358 m_pinchZoomScrollbarVertical->setScrollLayerId(rootScrollLayerId);
359 }
360 }
361
335 void LayerTreeHost::willCommit() 362 void LayerTreeHost::willCommit()
336 { 363 {
337 m_client->willCommit(); 364 m_client->willCommit();
338 365
339 if (m_debugState.showHudInfo()) { 366 if (m_debugState.showHudInfo()) {
340 if (!m_hudLayer) 367 if (!m_hudLayer)
341 m_hudLayer = HeadsUpDisplayLayer::create(); 368 m_hudLayer = HeadsUpDisplayLayer::create();
342 369
343 if (m_debugState.hudNeedsFont() && !m_hudLayer->hasFontAtlas()) 370 if (m_debugState.hudNeedsFont() && !m_hudLayer->hasFontAtlas())
344 m_hudLayer->setFontAtlas(m_client->createFontAtlas()); 371 m_hudLayer->setFontAtlas(m_client->createFontAtlas());
345 372
346 if (m_rootLayer && !m_hudLayer->parent()) 373 if (m_rootLayer && !m_hudLayer->parent())
347 m_rootLayer->addChild(m_hudLayer); 374 m_rootLayer->addChild(m_hudLayer);
348 } else if (m_hudLayer) { 375 } else if (m_hudLayer) {
349 m_hudLayer->removeFromParent(); 376 m_hudLayer->removeFromParent();
350 m_hudLayer = 0; 377 m_hudLayer = 0;
351 } 378 }
379
380 // Setup pinch-zoom scrollbars if required.
381 if (m_settings.pageScalePinchZoomEnabled && rootScrollLayer() &&
382 !ScrollbarLayer::defaultUsesOverlayScrollbars()) {
383 if (!m_pinchZoomScrollbarHorizontal)
384 m_pinchZoomScrollbarHorizontal = ScrollbarLayer::create(
385 make_scoped_ptr(
386 new PinchZoomScrollbar(
387 WebKit::WebScrollbar::Horizontal, this)).PassAs<WebKit:: WebScrollbar>(),
388 make_scoped_ptr(new PinchZoomScrollbarPainter).PassAs<ScrollbarT hemePainter>(),
389 0);
390
391 DCHECK(m_pinchZoomScrollbarHorizontal);
392 if (!m_pinchZoomScrollbarHorizontal->parent())
393 m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal);
394
395 if (!m_pinchZoomScrollbarVertical)
396 m_pinchZoomScrollbarVertical = ScrollbarLayer::create(
397 make_scoped_ptr(
398 new PinchZoomScrollbar(
399 WebKit::WebScrollbar::Vertical, this)).PassAs<WebKit::We bScrollbar>(),
400 make_scoped_ptr(new PinchZoomScrollbarPainter).PassAs<ScrollbarT hemePainter>(),
401 0);
402
403 DCHECK(m_pinchZoomScrollbarVertical);
404 if (!m_pinchZoomScrollbarVertical->parent())
405 m_rootLayer->addChild(m_pinchZoomScrollbarVertical);
406
407 setPinchZoomScrollbarPropertiesIfNeeded();
408 }
352 } 409 }
353 410
354 void LayerTreeHost::commitComplete() 411 void LayerTreeHost::commitComplete()
355 { 412 {
356 m_client->didCommit(); 413 m_client->didCommit();
357 } 414 }
358 415
359 scoped_ptr<OutputSurface> LayerTreeHost::createOutputSurface() 416 scoped_ptr<OutputSurface> LayerTreeHost::createOutputSurface()
360 { 417 {
361 return m_client->createOutputSurface(); 418 return m_client->createOutputSurface();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 541 }
485 542
486 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) 543 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize)
487 { 544 {
488 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) 545 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize)
489 return; 546 return;
490 547
491 m_layoutViewportSize = layoutViewportSize; 548 m_layoutViewportSize = layoutViewportSize;
492 m_deviceViewportSize = deviceViewportSize; 549 m_deviceViewportSize = deviceViewportSize;
493 550
551 setPinchZoomScrollbarPropertiesIfNeeded();
494 setNeedsCommit(); 552 setNeedsCommit();
495 } 553 }
496 554
497 void LayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float min PageScaleFactor, float maxPageScaleFactor) 555 void LayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float min PageScaleFactor, float maxPageScaleFactor)
498 { 556 {
499 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor) 557 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor)
500 return; 558 return;
501 559
502 m_pageScaleFactor = pageScaleFactor; 560 m_pageScaleFactor = pageScaleFactor;
503 m_minPageScaleFactor = minPageScaleFactor; 561 m_minPageScaleFactor = minPageScaleFactor;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 635
578 for (size_t i = 0; i < layer->children().size(); ++i) { 636 for (size_t i = 0; i < layer->children().size(); ++i) {
579 Layer* found = findFirstScrollableLayer(layer->children()[i].get()); 637 Layer* found = findFirstScrollableLayer(layer->children()[i].get());
580 if (found) 638 if (found)
581 return found; 639 return found;
582 } 640 }
583 641
584 return 0; 642 return 0;
585 } 643 }
586 644
645 Layer* LayerTreeHost::rootScrollLayer() const
646 {
647 return findFirstScrollableLayer(m_rootLayer.get());
648 }
649
587 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) 650 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue)
588 { 651 {
589 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); 652 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers");
590 653
591 LayerList updateList; 654 LayerList updateList;
592 655
593 { 656 {
594 if (m_settings.pageScalePinchZoomEnabled) { 657 if (m_settings.pageScalePinchZoomEnabled) {
595 Layer* rootScroll = findFirstScrollableLayer(rootLayer); 658 Layer* rootScroll = findFirstScrollableLayer(rootLayer);
596 if (rootScroll) 659 if (rootScroll)
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 931 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
869 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 932 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
870 } 933 }
871 934
872 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() 935 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture()
873 { 936 {
874 return m_proxy->capturePicture(); 937 return m_proxy->capturePicture();
875 } 938 }
876 939
877 } // namespace cc 940 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698