OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 switches::kDisableOverscrollEdgeEffect)), | 194 switches::kDisableOverscrollEdgeEffect)), |
195 gesture_provider_(CreateGestureProviderConfig(), this), | 195 gesture_provider_(CreateGestureProviderConfig(), this), |
196 gesture_text_selector_(this), | 196 gesture_text_selector_(this), |
197 touch_scrolling_(false), | 197 touch_scrolling_(false), |
198 potentially_active_fling_count_(0), | 198 potentially_active_fling_count_(0), |
199 flush_input_requested_(false), | 199 flush_input_requested_(false), |
200 accelerated_surface_route_id_(0), | 200 accelerated_surface_route_id_(0), |
201 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( | 201 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( |
202 widget_host->GetProcess()->GetID(), | 202 widget_host->GetProcess()->GetID(), |
203 widget_host->GetRoutingID()) != NULL), | 203 widget_host->GetRoutingID()) != NULL), |
204 vsync_subscribers_(0), | |
204 frame_evictor_(new DelegatedFrameEvictor(this)), | 205 frame_evictor_(new DelegatedFrameEvictor(this)), |
205 locks_on_frame_count_(0), | 206 locks_on_frame_count_(0), |
206 observing_root_window_(false) { | 207 observing_root_window_(false) { |
boliu
2014/08/20 02:54:16
vsync_subscribers_ can replace observing_root_wind
hush (inactive)
2014/08/20 03:47:21
yes indeed.
| |
207 host_->SetView(this); | 208 host_->SetView(this); |
208 SetContentViewCore(content_view_core); | 209 SetContentViewCore(content_view_core); |
209 ImageTransportFactoryAndroid::AddObserver(this); | 210 ImageTransportFactoryAndroid::AddObserver(this); |
210 } | 211 } |
211 | 212 |
212 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 213 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
213 ImageTransportFactoryAndroid::RemoveObserver(this); | 214 ImageTransportFactoryAndroid::RemoveObserver(this); |
214 SetContentViewCore(NULL); | 215 SetContentViewCore(NULL); |
215 DCHECK(ack_callbacks_.empty()); | 216 DCHECK(ack_callbacks_.empty()); |
216 if (resource_collection_.get()) | 217 if (resource_collection_.get()) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 return host_; | 254 return host_; |
254 } | 255 } |
255 | 256 |
256 void RenderWidgetHostViewAndroid::WasShown() { | 257 void RenderWidgetHostViewAndroid::WasShown() { |
257 if (!host_ || !host_->is_hidden()) | 258 if (!host_ || !host_->is_hidden()) |
258 return; | 259 return; |
259 | 260 |
260 host_->WasShown(ui::LatencyInfo()); | 261 host_->WasShown(ui::LatencyInfo()); |
261 | 262 |
262 if (content_view_core_ && !using_synchronous_compositor_) { | 263 if (content_view_core_ && !using_synchronous_compositor_) { |
263 content_view_core_->GetWindowAndroid()->AddObserver(this); | 264 SubscribeToVSync(INPUT | BEGIN_FRAME); |
264 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); | 265 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); |
265 observing_root_window_ = true; | |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 void RenderWidgetHostViewAndroid::WasHidden() { | 269 void RenderWidgetHostViewAndroid::WasHidden() { |
270 RunAckCallbacks(); | 270 RunAckCallbacks(); |
271 | 271 |
272 if (!host_ || host_->is_hidden()) | 272 if (!host_ || host_->is_hidden()) |
273 return; | 273 return; |
274 | 274 |
275 // Inform the renderer that we are being hidden so it can reduce its resource | 275 // Inform the renderer that we are being hidden so it can reduce its resource |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 void RenderWidgetHostViewAndroid::ShowDisambiguationPopup( | 804 void RenderWidgetHostViewAndroid::ShowDisambiguationPopup( |
805 const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) { | 805 const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) { |
806 if (!content_view_core_) | 806 if (!content_view_core_) |
807 return; | 807 return; |
808 | 808 |
809 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); | 809 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); |
810 } | 810 } |
811 | 811 |
812 scoped_ptr<SyntheticGestureTarget> | 812 scoped_ptr<SyntheticGestureTarget> |
813 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { | 813 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { |
814 DCHECK(content_view_core_); | |
815 if (using_synchronous_compositor_) | |
816 SubscribeToVSync(INPUT); | |
817 | |
814 return scoped_ptr<SyntheticGestureTarget>(new SyntheticGestureTargetAndroid( | 818 return scoped_ptr<SyntheticGestureTarget>(new SyntheticGestureTargetAndroid( |
815 host_, content_view_core_->CreateTouchEventSynthesizer())); | 819 host_, content_view_core_->CreateTouchEventSynthesizer())); |
816 } | 820 } |
817 | 821 |
818 void RenderWidgetHostViewAndroid::SendDelegatedFrameAck( | 822 void RenderWidgetHostViewAndroid::SendDelegatedFrameAck( |
819 uint32 output_surface_id) { | 823 uint32 output_surface_id) { |
820 DCHECK(host_); | 824 DCHECK(host_); |
821 cc::CompositorFrameAck ack; | 825 cc::CompositorFrameAck ack; |
822 if (resource_collection_.get()) | 826 if (resource_collection_.get()) |
823 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); | 827 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1463 obj = content_view_core_->GetJavaObject(); | 1467 obj = content_view_core_->GetJavaObject(); |
1464 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); | 1468 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); |
1465 } | 1469 } |
1466 | 1470 |
1467 AttachLayers(); | 1471 AttachLayers(); |
1468 | 1472 |
1469 if (!content_view_core_) | 1473 if (!content_view_core_) |
1470 return; | 1474 return; |
1471 | 1475 |
1472 if (!using_synchronous_compositor_) { | 1476 if (!using_synchronous_compositor_) { |
1473 content_view_core_->GetWindowAndroid()->AddObserver(this); | 1477 SubscribeToVSync(INPUT | BEGIN_FRAME); |
1474 observing_root_window_ = true; | |
1475 if (needs_begin_frame_) | 1478 if (needs_begin_frame_) |
1476 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); | 1479 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); |
1477 } | 1480 } |
1478 | 1481 |
1479 if (resize) | 1482 if (resize) |
1480 WasResized(); | 1483 WasResized(); |
1481 | 1484 |
1482 if (!selection_controller_) | 1485 if (!selection_controller_) |
1483 selection_controller_.reset(new TouchSelectionController(this)); | 1486 selection_controller_.reset(new TouchSelectionController(this)); |
1484 | 1487 |
(...skipping 26 matching lines...) Expand all Loading... | |
1511 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1514 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
1512 RunAckCallbacks(); | 1515 RunAckCallbacks(); |
1513 } | 1516 } |
1514 | 1517 |
1515 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1518 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
1516 DCHECK(content_view_core_); | 1519 DCHECK(content_view_core_); |
1517 DCHECK(!using_synchronous_compositor_); | 1520 DCHECK(!using_synchronous_compositor_); |
1518 RunAckCallbacks(); | 1521 RunAckCallbacks(); |
1519 } | 1522 } |
1520 | 1523 |
1524 void RenderWidgetHostViewAndroid::SubscribeToVSync(int type) { | |
boliu
2014/08/20 02:54:16
Where is Unsubscribe?
hush (inactive)
2014/08/20 03:47:21
Will add it...
On 2014/08/20 02:54:16, boliu wrote
| |
1525 if (!observing_root_window_) { | |
1526 content_view_core_->GetWindowAndroid()->AddObserver(this); | |
1527 observing_root_window_ = true; | |
1528 } | |
1529 | |
1530 vsync_subscribers_ |= type; | |
1531 // Synchronous compositor does not request begin frames OnVSync. | |
1532 DCHECK(using_synchronous_compositor_ && !(vsync_subscribers_ & BEGIN_FRAME)); | |
boliu
2014/08/20 02:54:16
This DCHECK can't be right. It fails if using_sync
hush (inactive)
2014/08/20 03:47:21
yeah.. you are right.
Done
On 2014/08/20 02:54:16,
| |
1533 } | |
1534 | |
1521 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1535 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
1522 base::TimeDelta vsync_period) { | 1536 base::TimeDelta vsync_period) { |
1523 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::OnVSync"); | 1537 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::OnVSync"); |
1524 if (!host_) | 1538 if (!host_) |
1525 return; | 1539 return; |
1526 | 1540 |
1527 if (flush_input_requested_) { | 1541 if (vsync_subscribers_ & INPUT & flush_input_requested_) { |
1528 flush_input_requested_ = false; | 1542 flush_input_requested_ = false; |
1529 host_->FlushInput(); | 1543 host_->FlushInput(); |
1530 } | 1544 } |
1531 | 1545 |
1546 if (!(vsync_subscribers_ & BEGIN_FRAME)) | |
1547 return; | |
1548 | |
1532 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::SendBeginFrame"); | 1549 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::SendBeginFrame"); |
1533 base::TimeTicks display_time = frame_time + vsync_period; | 1550 base::TimeTicks display_time = frame_time + vsync_period; |
1534 | 1551 |
1535 // TODO(brianderson): Use adaptive draw-time estimation. | 1552 // TODO(brianderson): Use adaptive draw-time estimation. |
1536 base::TimeDelta estimated_browser_composite_time = | 1553 base::TimeDelta estimated_browser_composite_time = |
1537 base::TimeDelta::FromMicroseconds( | 1554 base::TimeDelta::FromMicroseconds( |
1538 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)); | 1555 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)); |
1539 | 1556 |
1540 base::TimeTicks deadline = display_time - estimated_browser_composite_time; | 1557 base::TimeTicks deadline = display_time - estimated_browser_composite_time; |
1541 | 1558 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1691 results->orientationAngle = display.RotationAsDegree(); | 1708 results->orientationAngle = display.RotationAsDegree(); |
1692 results->orientationType = | 1709 results->orientationType = |
1693 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1710 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
1694 gfx::DeviceDisplayInfo info; | 1711 gfx::DeviceDisplayInfo info; |
1695 results->depth = info.GetBitsPerPixel(); | 1712 results->depth = info.GetBitsPerPixel(); |
1696 results->depthPerComponent = info.GetBitsPerComponent(); | 1713 results->depthPerComponent = info.GetBitsPerComponent(); |
1697 results->isMonochrome = (results->depthPerComponent == 0); | 1714 results->isMonochrome = (results->depthPerComponent == 0); |
1698 } | 1715 } |
1699 | 1716 |
1700 } // namespace content | 1717 } // namespace content |
OLD | NEW |