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/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, | 1169 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, |
1170 weak_ptr_factory_.GetWeakPtr(), | 1170 weak_ptr_factory_.GetWeakPtr(), |
1171 last_frame_info_->output_surface_id); | 1171 last_frame_info_->output_surface_id); |
1172 | 1172 |
1173 ack_callbacks_.push(ack_callback); | 1173 ack_callbacks_.push(ack_callback); |
1174 } | 1174 } |
1175 | 1175 |
1176 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); | 1176 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); |
1177 } | 1177 } |
1178 | 1178 |
1179 SynchronousCompositorImpl* | |
1180 RenderWidgetHostViewAndroid::GetSynchronousCompositorImpl() { | |
1181 return sync_compositor_.get(); | |
1182 } | |
1183 | |
1179 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( | 1184 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( |
1180 const cc::CompositorFrameMetadata& frame_metadata) { | 1185 const cc::CompositorFrameMetadata& frame_metadata) { |
1181 if (!content_view_core_) | 1186 if (!content_view_core_) |
1182 return; | 1187 return; |
1183 | 1188 |
1184 // This is a subset of OnSwapCompositorFrame() used in the synchronous | 1189 // This is a subset of OnSwapCompositorFrame() used in the synchronous |
1185 // compositor flow. | 1190 // compositor flow. |
1186 OnFrameMetadataUpdated(frame_metadata); | 1191 OnFrameMetadataUpdated(frame_metadata); |
1187 | 1192 |
1188 // DevTools ScreenCast support for Android WebView. | 1193 // DevTools ScreenCast support for Android WebView. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1274 input_size_in_pixel = src_subrect_in_pixel.size(); | 1279 input_size_in_pixel = src_subrect_in_pixel.size(); |
1275 | 1280 |
1276 gfx::Size output_size_in_pixel; | 1281 gfx::Size output_size_in_pixel; |
1277 if (dst_size_in_pixel.IsEmpty()) | 1282 if (dst_size_in_pixel.IsEmpty()) |
1278 output_size_in_pixel = input_size_in_pixel; | 1283 output_size_in_pixel = input_size_in_pixel; |
1279 else | 1284 else |
1280 output_size_in_pixel = dst_size_in_pixel; | 1285 output_size_in_pixel = dst_size_in_pixel; |
1281 int output_width = output_size_in_pixel.width(); | 1286 int output_width = output_size_in_pixel.width(); |
1282 int output_height = output_size_in_pixel.height(); | 1287 int output_height = output_size_in_pixel.height(); |
1283 | 1288 |
1284 SynchronousCompositor* compositor = | 1289 if (!sync_compositor_) { |
1285 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), | |
1286 host_->GetRoutingID()); | |
1287 if (!compositor) { | |
1288 callback.Run(SkBitmap(), READBACK_FAILED); | 1290 callback.Run(SkBitmap(), READBACK_FAILED); |
1289 return; | 1291 return; |
1290 } | 1292 } |
1291 | 1293 |
1292 SkBitmap bitmap; | 1294 SkBitmap bitmap; |
1293 bitmap.allocPixels(SkImageInfo::Make(output_width, | 1295 bitmap.allocPixels(SkImageInfo::Make(output_width, |
1294 output_height, | 1296 output_height, |
1295 color_type, | 1297 color_type, |
1296 kPremul_SkAlphaType)); | 1298 kPremul_SkAlphaType)); |
1297 SkCanvas canvas(bitmap); | 1299 SkCanvas canvas(bitmap); |
1298 canvas.scale( | 1300 canvas.scale( |
1299 (float)output_width / (float)input_size_in_pixel.width(), | 1301 (float)output_width / (float)input_size_in_pixel.width(), |
1300 (float)output_height / (float)input_size_in_pixel.height()); | 1302 (float)output_height / (float)input_size_in_pixel.height()); |
1301 compositor->DemandDrawSw(&canvas); | 1303 sync_compositor_->DemandDrawSw(&canvas); |
1302 callback.Run(bitmap, READBACK_SUCCESS); | 1304 callback.Run(bitmap, READBACK_SUCCESS); |
1303 } | 1305 } |
1304 | 1306 |
1305 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( | 1307 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( |
1306 const cc::CompositorFrameMetadata& frame_metadata) { | 1308 const cc::CompositorFrameMetadata& frame_metadata) { |
1307 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); | 1309 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); |
1308 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); | 1310 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); |
1309 | 1311 |
1310 if (!content_view_core_) | 1312 if (!content_view_core_) |
1311 return; | 1313 return; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 | 1477 |
1476 if (using_browser_compositor_) { | 1478 if (using_browser_compositor_) { |
1477 // TODO(brianderson): Replace this hardcoded deadline after Android | 1479 // TODO(brianderson): Replace this hardcoded deadline after Android |
1478 // switches to Surfaces and the Browser's commit isn't in the critcal path. | 1480 // switches to Surfaces and the Browser's commit isn't in the critcal path. |
1479 base::TimeTicks deadline = frame_time + (vsync_period * 0.6); | 1481 base::TimeTicks deadline = frame_time + (vsync_period * 0.6); |
1480 | 1482 |
1481 host_->Send(new ViewMsg_BeginFrame( | 1483 host_->Send(new ViewMsg_BeginFrame( |
1482 host_->GetRoutingID(), | 1484 host_->GetRoutingID(), |
1483 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 1485 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
1484 vsync_period, cc::BeginFrameArgs::NORMAL))); | 1486 vsync_period, cc::BeginFrameArgs::NORMAL))); |
1485 } else { | 1487 } else if (sync_compositor_.get()) { |
1486 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID( | 1488 // The synchronous compositor synchronously does it's work in this call. |
1487 host_->GetProcess()->GetID(), host_->GetRoutingID()); | 1489 // It does not use a deadline. |
1488 if (compositor) { | 1490 sync_compositor_->BeginFrame(cc::BeginFrameArgs::Create( |
1489 // The synchronous compositor synchronously does it's work in this call. | 1491 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period, |
1490 // It does not use a deadline. | 1492 cc::BeginFrameArgs::NORMAL)); |
1491 compositor->BeginFrame(cc::BeginFrameArgs::Create( | |
1492 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period, | |
1493 cc::BeginFrameArgs::NORMAL)); | |
1494 } | |
1495 } | 1493 } |
1496 } | 1494 } |
1497 | 1495 |
1498 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1496 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
1499 bool needs_animate = false; | 1497 bool needs_animate = false; |
1500 if (overscroll_controller_) { | 1498 if (overscroll_controller_) { |
1501 needs_animate |= overscroll_controller_->Animate( | 1499 needs_animate |= overscroll_controller_->Animate( |
1502 frame_time, content_view_core_->GetLayer().get()); | 1500 frame_time, content_view_core_->GetLayer().get()); |
1503 } | 1501 } |
1504 if (selection_controller_) | 1502 if (selection_controller_) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1602 | 1600 |
1603 if (input_event.type == blink::WebInputEvent::GestureTapDown || | 1601 if (input_event.type == blink::WebInputEvent::GestureTapDown || |
1604 input_event.type == blink::WebInputEvent::TouchStart) { | 1602 input_event.type == blink::WebInputEvent::TouchStart) { |
1605 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance(); | 1603 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance(); |
1606 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | 1604 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); |
1607 if (shim && gpu_data && | 1605 if (shim && gpu_data && |
1608 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING)) | 1606 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING)) |
1609 shim->Send(new GpuMsg_WakeUpGpu); | 1607 shim->Send(new GpuMsg_WakeUpGpu); |
1610 } | 1608 } |
1611 | 1609 |
1612 SynchronousCompositorImpl* compositor = | 1610 if (sync_compositor_.get()) |
1613 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), | 1611 return sync_compositor_->HandleInputEvent(input_event); |
1614 host_->GetRoutingID()); | |
1615 if (compositor) | |
1616 return compositor->HandleInputEvent(input_event); | |
1617 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1612 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
1618 } | 1613 } |
1619 | 1614 |
1620 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { | 1615 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { |
1621 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); | 1616 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); |
1622 RequestVSyncUpdate(FLUSH_INPUT); | 1617 RequestVSyncUpdate(FLUSH_INPUT); |
1623 } | 1618 } |
1624 | 1619 |
1625 BrowserAccessibilityManager* | 1620 BrowserAccessibilityManager* |
1626 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager( | 1621 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1765 if (host_) | 1760 if (host_) |
1766 manager = host_->GetRootBrowserAccessibilityManager(); | 1761 manager = host_->GetRootBrowserAccessibilityManager(); |
1767 if (manager) { | 1762 if (manager) { |
1768 base::android::ScopedJavaLocalRef<jobject> obj; | 1763 base::android::ScopedJavaLocalRef<jobject> obj; |
1769 if (content_view_core_) | 1764 if (content_view_core_) |
1770 obj = content_view_core_->GetJavaObject(); | 1765 obj = content_view_core_->GetJavaObject(); |
1771 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); | 1766 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); |
1772 } | 1767 } |
1773 | 1768 |
1774 AttachLayers(); | 1769 AttachLayers(); |
1775 | 1770 if (!content_view_core_) { |
1776 if (!content_view_core_) | 1771 sync_compositor_.reset(); |
jdduke (slow)
2015/10/05 19:56:03
What about the case where we transition from one v
boliu
2015/10/06 00:05:30
Assume for now there will be only one RenderView p
boliu
2015/10/06 01:28:04
Let me re-phrase that a bit better, now that I'm n
| |
1777 return; | 1772 return; |
1773 } | |
1778 | 1774 |
1779 if (is_showing_) | 1775 if (is_showing_) |
1780 StartObservingRootWindow(); | 1776 StartObservingRootWindow(); |
1781 | 1777 |
1782 if (resize) | 1778 if (resize) |
1783 WasResized(); | 1779 WasResized(); |
1784 | 1780 |
1785 if (!selection_controller_) | 1781 if (!selection_controller_) |
1786 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1782 selection_controller_ = CreateSelectionController(this, content_view_core_); |
1787 | 1783 |
1788 if (!overscroll_controller_ && | 1784 if (!overscroll_controller_ && |
1789 content_view_core_window_android_->GetCompositor()) { | 1785 content_view_core_window_android_->GetCompositor()) { |
1790 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1786 overscroll_controller_ = CreateOverscrollController(content_view_core_); |
1791 } | 1787 } |
1788 | |
1789 if (!using_browser_compositor_ && !sync_compositor_.get()) { | |
1790 sync_compositor_ = SynchronousCompositorImpl::Create( | |
1791 this, content_view_core_->GetWebContents()); | |
1792 } | |
1792 } | 1793 } |
1793 | 1794 |
1794 void RenderWidgetHostViewAndroid::RunAckCallbacks( | 1795 void RenderWidgetHostViewAndroid::RunAckCallbacks( |
1795 cc::SurfaceDrawStatus status) { | 1796 cc::SurfaceDrawStatus status) { |
1796 while (!ack_callbacks_.empty()) { | 1797 while (!ack_callbacks_.empty()) { |
1797 ack_callbacks_.front().Run(); | 1798 ack_callbacks_.front().Run(); |
1798 ack_callbacks_.pop(); | 1799 ack_callbacks_.pop(); |
1799 } | 1800 } |
1800 } | 1801 } |
1801 | 1802 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2012 results->orientationAngle = display.RotationAsDegree(); | 2013 results->orientationAngle = display.RotationAsDegree(); |
2013 results->orientationType = | 2014 results->orientationType = |
2014 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2015 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
2015 gfx::DeviceDisplayInfo info; | 2016 gfx::DeviceDisplayInfo info; |
2016 results->depth = info.GetBitsPerPixel(); | 2017 results->depth = info.GetBitsPerPixel(); |
2017 results->depthPerComponent = info.GetBitsPerComponent(); | 2018 results->depthPerComponent = info.GetBitsPerComponent(); |
2018 results->isMonochrome = (results->depthPerComponent == 0); | 2019 results->isMonochrome = (results->depthPerComponent == 0); |
2019 } | 2020 } |
2020 | 2021 |
2021 } // namespace content | 2022 } // namespace content |
OLD | NEW |