OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "web/tests/sim/SimCompositor.h" | 5 #include "web/tests/sim/SimCompositor.h" |
6 | 6 |
| 7 #include "core/exported/WebViewBase.h" |
7 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
8 #include "core/layout/api/LayoutViewItem.h" | 9 #include "core/layout/api/LayoutViewItem.h" |
9 #include "core/layout/compositing/CompositedLayerMapping.h" | 10 #include "core/layout/compositing/CompositedLayerMapping.h" |
10 #include "core/layout/compositing/PaintLayerCompositor.h" | 11 #include "core/layout/compositing/PaintLayerCompositor.h" |
11 #include "core/paint/PaintLayer.h" | 12 #include "core/paint/PaintLayer.h" |
12 #include "platform/graphics/ContentLayerDelegate.h" | 13 #include "platform/graphics/ContentLayerDelegate.h" |
13 #include "platform/graphics/GraphicsLayer.h" | 14 #include "platform/graphics/GraphicsLayer.h" |
14 #include "platform/wtf/CurrentTime.h" | 15 #include "platform/wtf/CurrentTime.h" |
15 #include "public/platform/WebRect.h" | 16 #include "public/platform/WebRect.h" |
16 #include "web/WebLocalFrameImpl.h" | 17 #include "web/WebLocalFrameImpl.h" |
17 #include "web/WebViewImpl.h" | |
18 #include "web/tests/sim/SimDisplayItemList.h" | 18 #include "web/tests/sim/SimDisplayItemList.h" |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 static void PaintLayers(GraphicsLayer& layer, | 22 static void PaintLayers(GraphicsLayer& layer, |
23 SimDisplayItemList& display_list) { | 23 SimDisplayItemList& display_list) { |
24 if (layer.DrawsContent() && layer.HasTrackedRasterInvalidations()) { | 24 if (layer.DrawsContent() && layer.HasTrackedRasterInvalidations()) { |
25 ContentLayerDelegate* delegate = layer.ContentLayerDelegateForTesting(); | 25 ContentLayerDelegate* delegate = layer.ContentLayerDelegateForTesting(); |
26 delegate->PaintContents(&display_list); | 26 delegate->PaintContents(&display_list); |
27 layer.ResetTrackedRasterInvalidations(); | 27 layer.ResetTrackedRasterInvalidations(); |
(...skipping 12 matching lines...) Expand all Loading... |
40 static void PaintFrames(LocalFrame& root, SimDisplayItemList& display_list) { | 40 static void PaintFrames(LocalFrame& root, SimDisplayItemList& display_list) { |
41 GraphicsLayer* layer = | 41 GraphicsLayer* layer = |
42 root.View()->GetLayoutViewItem().Compositor()->RootGraphicsLayer(); | 42 root.View()->GetLayoutViewItem().Compositor()->RootGraphicsLayer(); |
43 PaintLayers(*layer, display_list); | 43 PaintLayers(*layer, display_list); |
44 } | 44 } |
45 | 45 |
46 SimCompositor::SimCompositor() | 46 SimCompositor::SimCompositor() |
47 : needs_begin_frame_(false), | 47 : needs_begin_frame_(false), |
48 defer_commits_(true), | 48 defer_commits_(true), |
49 has_selection_(false), | 49 has_selection_(false), |
50 web_view_impl_(0), | 50 web_view_(0), |
51 last_frame_time_monotonic_(0) { | 51 last_frame_time_monotonic_(0) { |
52 FrameView::SetInitialTracksPaintInvalidationsForTesting(true); | 52 FrameView::SetInitialTracksPaintInvalidationsForTesting(true); |
53 } | 53 } |
54 | 54 |
55 SimCompositor::~SimCompositor() { | 55 SimCompositor::~SimCompositor() { |
56 FrameView::SetInitialTracksPaintInvalidationsForTesting(false); | 56 FrameView::SetInitialTracksPaintInvalidationsForTesting(false); |
57 } | 57 } |
58 | 58 |
59 void SimCompositor::SetWebViewImpl(WebViewImpl& web_view_impl) { | 59 void SimCompositor::SetWebView(WebViewBase& web_view) { |
60 web_view_impl_ = &web_view_impl; | 60 web_view_ = &web_view; |
61 } | 61 } |
62 | 62 |
63 void SimCompositor::SetNeedsBeginFrame() { | 63 void SimCompositor::SetNeedsBeginFrame() { |
64 needs_begin_frame_ = true; | 64 needs_begin_frame_ = true; |
65 } | 65 } |
66 | 66 |
67 void SimCompositor::SetDeferCommits(bool defer_commits) { | 67 void SimCompositor::SetDeferCommits(bool defer_commits) { |
68 defer_commits_ = defer_commits; | 68 defer_commits_ = defer_commits; |
69 } | 69 } |
70 | 70 |
71 void SimCompositor::RegisterSelection(const WebSelection&) { | 71 void SimCompositor::RegisterSelection(const WebSelection&) { |
72 has_selection_ = true; | 72 has_selection_ = true; |
73 } | 73 } |
74 | 74 |
75 void SimCompositor::ClearSelection() { | 75 void SimCompositor::ClearSelection() { |
76 has_selection_ = false; | 76 has_selection_ = false; |
77 } | 77 } |
78 | 78 |
79 SimDisplayItemList SimCompositor::BeginFrame(double time_delta_in_seconds) { | 79 SimDisplayItemList SimCompositor::BeginFrame(double time_delta_in_seconds) { |
80 DCHECK(web_view_impl_); | 80 DCHECK(web_view_); |
81 DCHECK(!defer_commits_); | 81 DCHECK(!defer_commits_); |
82 DCHECK(needs_begin_frame_); | 82 DCHECK(needs_begin_frame_); |
83 DCHECK_GT(time_delta_in_seconds, 0); | 83 DCHECK_GT(time_delta_in_seconds, 0); |
84 needs_begin_frame_ = false; | 84 needs_begin_frame_ = false; |
85 | 85 |
86 last_frame_time_monotonic_ += time_delta_in_seconds; | 86 last_frame_time_monotonic_ += time_delta_in_seconds; |
87 | 87 |
88 web_view_impl_->BeginFrame(last_frame_time_monotonic_); | 88 web_view_->BeginFrame(last_frame_time_monotonic_); |
89 web_view_impl_->UpdateAllLifecyclePhases(); | 89 web_view_->UpdateAllLifecyclePhases(); |
90 | 90 |
91 LocalFrame* root = web_view_impl_->MainFrameImpl()->GetFrame(); | 91 LocalFrame* root = web_view_->MainFrameImpl()->GetFrame(); |
92 | 92 |
93 SimDisplayItemList display_list; | 93 SimDisplayItemList display_list; |
94 PaintFrames(*root, display_list); | 94 PaintFrames(*root, display_list); |
95 | 95 |
96 return display_list; | 96 return display_list; |
97 } | 97 } |
98 | 98 |
99 } // namespace blink | 99 } // namespace blink |
OLD | NEW |