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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11316128: Send compositor frame IPC with metadata. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clean up and rebase to 173167 Created 8 years 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
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_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "cc/append_quads_data.h" 12 #include "cc/append_quads_data.h"
13 #include "cc/compositor_frame_metadata.h"
13 #include "cc/damage_tracker.h" 14 #include "cc/damage_tracker.h"
14 #include "cc/debug_rect_history.h" 15 #include "cc/debug_rect_history.h"
15 #include "cc/delay_based_time_source.h" 16 #include "cc/delay_based_time_source.h"
16 #include "cc/delegating_renderer.h" 17 #include "cc/delegating_renderer.h"
17 #include "cc/frame_rate_counter.h" 18 #include "cc/frame_rate_counter.h"
19 #include "cc/gl_compositor_frame.h"
18 #include "cc/gl_renderer.h" 20 #include "cc/gl_renderer.h"
19 #include "cc/heads_up_display_layer_impl.h" 21 #include "cc/heads_up_display_layer_impl.h"
20 #include "cc/layer_iterator.h" 22 #include "cc/layer_iterator.h"
21 #include "cc/layer_tree_host.h" 23 #include "cc/layer_tree_host.h"
22 #include "cc/layer_tree_host_common.h" 24 #include "cc/layer_tree_host_common.h"
23 #include "cc/layer_tree_impl.h" 25 #include "cc/layer_tree_impl.h"
24 #include "cc/math_util.h" 26 #include "cc/math_util.h"
25 #include "cc/overdraw_metrics.h" 27 #include "cc/overdraw_metrics.h"
26 #include "cc/page_scale_animation.h" 28 #include "cc/page_scale_animation.h"
27 #include "cc/prioritized_resource_manager.h" 29 #include "cc/prioritized_resource_manager.h"
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 863
862 // TODO(piman): We may need to do some validation on this ack before process ing it. 864 // TODO(piman): We may need to do some validation on this ack before process ing it.
863 m_renderer->receiveCompositorFrameAck(ack); 865 m_renderer->receiveCompositorFrameAck(ack);
864 } 866 }
865 867
866 void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) 868 void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*)
867 { 869 {
868 m_client->onCanDrawStateChanged(canDraw()); 870 m_client->onCanDrawStateChanged(canDraw());
869 } 871 }
870 872
873 CompositorFrameMetadata LayerTreeHostImpl::makeCompositorFrameMetadata() const
874 {
875 if (!rootScrollLayer())
876 return CompositorFrameMetadata();
piman 2012/12/14 22:02:22 nit: (I know it sucks) consistency for indents? +4
aelias_OOO_until_Jul13 2012/12/15 00:06:17 Done.
877
878 CompositorFrameMetadata metadata;
danakj 2012/12/14 22:23:34 How about making a constructor that takes all thes
879 metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScroll Layer()->scrollDelta();
880 metadata.page_scale_factor = m_pinchZoomViewport.totalPageScaleFactor();
881 metadata.viewport_size = m_pinchZoomViewport.bounds().size();
882 metadata.root_layer_size = rootScrollLayer()->bounds();
883 metadata.min_page_scale_factor = m_pinchZoomViewport.minPageScaleFactor();
884 metadata.max_page_scale_factor = m_pinchZoomViewport.maxPageScaleFactor();
885 if (!m_settings.pageScalePinchZoomEnabled) {
886 metadata.root_scroll_offset.Scale(1 / m_pinchZoomViewport.pageScaleFacto r());
887 metadata.root_layer_size.Scale(1 / m_pinchZoomViewport.pageScaleFactor() );
888 }
889
890 return metadata;
891 }
892
871 void LayerTreeHostImpl::drawLayers(FrameData& frame) 893 void LayerTreeHostImpl::drawLayers(FrameData& frame)
872 { 894 {
873 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); 895 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers");
874 DCHECK(canDraw()); 896 DCHECK(canDraw());
875 DCHECK(!frame.renderPasses.empty()); 897 DCHECK(!frame.renderPasses.empty());
876 898
877 // FIXME: use the frame begin time from the overall compositor scheduler. 899 // FIXME: use the frame begin time from the overall compositor scheduler.
878 // This value is currently inaccessible because it is up in Chromium's 900 // This value is currently inaccessible because it is up in Chromium's
879 // RenderWidget. 901 // RenderWidget.
880 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); 902 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now());
881 903
882 if (m_debugState.showHudRects()) 904 if (m_debugState.showHudRects())
883 m_debugRectHistory->saveDebugRectsForCurrentFrame(rootLayer(), *frame.re nderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOccludingScreenS paceRects, m_debugState); 905 m_debugRectHistory->saveDebugRectsForCurrentFrame(rootLayer(), *frame.re nderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOccludingScreenS paceRects, m_debugState);
884 906
885 // Because the contents of the HUD depend on everything else in the frame, t he contents 907 // Because the contents of the HUD depend on everything else in the frame, t he contents
886 // of its texture are updated as the last thing before the frame is drawn. 908 // of its texture are updated as the last thing before the frame is drawn.
887 if (m_activeTree->hud_layer()) 909 if (m_activeTree->hud_layer())
888 m_activeTree->hud_layer()->updateHudTexture(m_resourceProvider.get()); 910 m_activeTree->hud_layer()->updateHudTexture(m_resourceProvider.get());
889 911
890 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); 912 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById);
891 913
892 // The render passes should be consumed by the renderer. 914 // The render passes should be consumed by the renderer.
893 DCHECK(frame.renderPasses.empty()); 915 DCHECK(frame.renderPasses.empty());
894 DCHECK(frame.renderPassesById.empty()); 916 DCHECK(frame.renderPassesById.empty());
895 917
896 // The next frame should start by assuming nothing has changed, and changes are noted as they occur. 918 // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
897 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) 919 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++)
898 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di dDrawDamagedArea(); 920 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di dDrawDamagedArea();
899 rootLayer()->resetAllChangeTrackingForSubtree(); 921 rootLayer()->resetAllChangeTrackingForSubtree();
922
923 if (settings().compositorFrameMessage && outputSurface()->Context3D()) {
piman 2012/12/14 22:02:22 Shouldn't this happen in GLRenderer::drawFrame ins
aelias_OOO_until_Jul13 2012/12/15 00:06:17 Done. I gave the GLRenderer an OutputSurface in t
924 GLCompositorFrame compositor_frame;
925 compositor_frame.metadata = makeCompositorFrameMetadata();
926 outputSurface()->SendFrameToParentCompositor(compositor_frame);
927 }
900 } 928 }
901 929
902 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) 930 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame)
903 { 931 {
904 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) 932 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i)
905 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); 933 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get());
906 934
907 // Once all layers have been drawn, pending texture uploads should no 935 // Once all layers have been drawn, pending texture uploads should no
908 // longer block future uploads. 936 // longer block future uploads.
909 m_resourceProvider->markPendingUploadsAsNonBlocking(); 937 m_resourceProvider->markPendingUploadsAsNonBlocking();
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1751 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1724 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1752 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1725 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1753 if (scrollbarController && scrollbarController->animate(monotonicTime))
1726 m_client->setNeedsRedrawOnImplThread(); 1754 m_client->setNeedsRedrawOnImplThread();
1727 1755
1728 for (size_t i = 0; i < layer->children().size(); ++i) 1756 for (size_t i = 0; i < layer->children().size(); ++i)
1729 animateScrollbarsRecursive(layer->children()[i], time); 1757 animateScrollbarsRecursive(layer->children()[i], time);
1730 } 1758 }
1731 1759
1732 } // namespace cc 1760 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698