Chromium Code Reviews| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 is_showing_(!widget_host->is_hidden()), | 321 is_showing_(!widget_host->is_hidden()), |
| 322 content_view_core_(nullptr), | 322 content_view_core_(nullptr), |
| 323 content_view_core_window_android_(nullptr), | 323 content_view_core_window_android_(nullptr), |
| 324 ime_adapter_android_(this), | 324 ime_adapter_android_(this), |
| 325 cached_background_color_(SK_ColorWHITE), | 325 cached_background_color_(SK_ColorWHITE), |
| 326 last_output_surface_id_(kUndefinedOutputSurfaceId), | 326 last_output_surface_id_(kUndefinedOutputSurfaceId), |
| 327 gesture_provider_(ui::GetGestureProviderConfig( | 327 gesture_provider_(ui::GetGestureProviderConfig( |
| 328 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 328 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 329 this), | 329 this), |
| 330 stylus_text_selector_(this), | 330 stylus_text_selector_(this), |
| 331 using_browser_compositor_(CompositorImpl::IsInitialized()), | |
| 332 frame_evictor_(new DelegatedFrameEvictor(this)), | 331 frame_evictor_(new DelegatedFrameEvictor(this)), |
| 333 locks_on_frame_count_(0), | 332 locks_on_frame_count_(0), |
| 334 observing_root_window_(false), | 333 observing_root_window_(false), |
| 335 weak_ptr_factory_(this) { | 334 weak_ptr_factory_(this) { |
| 336 if (CompositorImpl::GetSurfaceManager()) | 335 if (CompositorImpl::GetSurfaceManager()) |
| 337 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator(); | 336 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator(); |
| 338 host_->SetView(this); | 337 host_->SetView(this); |
| 339 SetContentViewCore(content_view_core); | 338 SetContentViewCore(content_view_core); |
| 340 } | 339 } |
| 341 | 340 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 const gfx::Rect& src_subrect, | 864 const gfx::Rect& src_subrect, |
| 866 const gfx::Size& dst_size, | 865 const gfx::Size& dst_size, |
| 867 const ReadbackRequestCallback& callback, | 866 const ReadbackRequestCallback& callback, |
| 868 const SkColorType preferred_color_type) { | 867 const SkColorType preferred_color_type) { |
| 869 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); | 868 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); |
| 870 if (!host_ || host_->is_hidden()) { | 869 if (!host_ || host_->is_hidden()) { |
| 871 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 870 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
| 872 return; | 871 return; |
| 873 } | 872 } |
| 874 base::TimeTicks start_time = base::TimeTicks::Now(); | 873 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 875 if (using_browser_compositor_ && !IsSurfaceAvailableForCopy()) { | 874 if (!sync_compositor_ && !IsSurfaceAvailableForCopy()) { |
|
no sievers
2015/10/07 18:52:58
nit: Actually even better would be to remove the s
boliu
2015/10/08 03:14:44
Done.
| |
| 876 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 875 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
| 877 return; | 876 return; |
| 878 } | 877 } |
| 879 const gfx::Display& display = | 878 const gfx::Display& display = |
| 880 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 879 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 881 float device_scale_factor = display.device_scale_factor(); | 880 float device_scale_factor = display.device_scale_factor(); |
| 882 gfx::Size dst_size_in_pixel = | 881 gfx::Size dst_size_in_pixel = |
| 883 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); | 882 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); |
| 884 gfx::Rect src_subrect_in_pixel = | 883 gfx::Rect src_subrect_in_pixel = |
| 885 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); | 884 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); |
| 886 | 885 |
| 887 if (!using_browser_compositor_) { | 886 if (sync_compositor_) { |
| 888 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, | 887 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, |
| 889 preferred_color_type); | 888 preferred_color_type); |
| 890 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", | 889 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", |
| 891 base::TimeTicks::Now() - start_time); | 890 base::TimeTicks::Now() - start_time); |
| 892 return; | 891 return; |
| 893 } | 892 } |
| 894 | 893 |
| 895 scoped_ptr<cc::CopyOutputRequest> request; | 894 scoped_ptr<cc::CopyOutputRequest> request; |
| 896 scoped_refptr<cc::Layer> readback_layer; | 895 scoped_refptr<cc::Layer> readback_layer; |
| 897 DCHECK(content_view_core_window_android_); | 896 DCHECK(content_view_core_window_android_); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1169 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, | 1168 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, |
| 1170 weak_ptr_factory_.GetWeakPtr(), | 1169 weak_ptr_factory_.GetWeakPtr(), |
| 1171 last_frame_info_->output_surface_id); | 1170 last_frame_info_->output_surface_id); |
| 1172 | 1171 |
| 1173 ack_callbacks_.push(ack_callback); | 1172 ack_callbacks_.push(ack_callback); |
| 1174 } | 1173 } |
| 1175 | 1174 |
| 1176 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); | 1175 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); |
| 1177 } | 1176 } |
| 1178 | 1177 |
| 1178 SynchronousCompositorImpl* | |
| 1179 RenderWidgetHostViewAndroid::GetSynchronousCompositorImpl() { | |
| 1180 return sync_compositor_.get(); | |
| 1181 } | |
| 1182 | |
| 1179 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( | 1183 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( |
| 1180 const cc::CompositorFrameMetadata& frame_metadata) { | 1184 const cc::CompositorFrameMetadata& frame_metadata) { |
| 1181 if (!content_view_core_) | 1185 if (!content_view_core_) |
| 1182 return; | 1186 return; |
| 1183 | 1187 |
| 1184 // This is a subset of OnSwapCompositorFrame() used in the synchronous | 1188 // This is a subset of OnSwapCompositorFrame() used in the synchronous |
| 1185 // compositor flow. | 1189 // compositor flow. |
| 1186 OnFrameMetadataUpdated(frame_metadata); | 1190 OnFrameMetadataUpdated(frame_metadata); |
| 1187 | 1191 |
| 1188 // DevTools ScreenCast support for Android WebView. | 1192 // DevTools ScreenCast support for Android WebView. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1201 } | 1205 } |
| 1202 | 1206 |
| 1203 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) { | 1207 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) { |
| 1204 if (layer_.get()) | 1208 if (layer_.get()) |
| 1205 layer_->SetContentsOpaque(!enabled); | 1209 layer_->SetContentsOpaque(!enabled); |
| 1206 } | 1210 } |
| 1207 | 1211 |
| 1208 bool RenderWidgetHostViewAndroid::SupportsAnimation() const { | 1212 bool RenderWidgetHostViewAndroid::SupportsAnimation() const { |
| 1209 // The synchronous (WebView) compositor does not have a proper browser | 1213 // The synchronous (WebView) compositor does not have a proper browser |
| 1210 // compositor with which to drive animations. | 1214 // compositor with which to drive animations. |
| 1211 return using_browser_compositor_; | 1215 return !sync_compositor_; |
| 1212 } | 1216 } |
| 1213 | 1217 |
| 1214 void RenderWidgetHostViewAndroid::SetNeedsAnimate() { | 1218 void RenderWidgetHostViewAndroid::SetNeedsAnimate() { |
| 1215 DCHECK(content_view_core_window_android_); | 1219 DCHECK(content_view_core_window_android_); |
| 1216 DCHECK(using_browser_compositor_); | 1220 DCHECK(!sync_compositor_); |
| 1217 content_view_core_window_android_->SetNeedsAnimate(); | 1221 content_view_core_window_android_->SetNeedsAnimate(); |
| 1218 } | 1222 } |
| 1219 | 1223 |
| 1220 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::PointF& position) { | 1224 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::PointF& position) { |
| 1221 MoveCaret(gfx::Point(position.x(), position.y())); | 1225 MoveCaret(gfx::Point(position.x(), position.y())); |
| 1222 } | 1226 } |
| 1223 | 1227 |
| 1224 void RenderWidgetHostViewAndroid::MoveRangeSelectionExtent( | 1228 void RenderWidgetHostViewAndroid::MoveRangeSelectionExtent( |
| 1225 const gfx::PointF& extent) { | 1229 const gfx::PointF& extent) { |
| 1226 DCHECK(content_view_core_); | 1230 DCHECK(content_view_core_); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1244 if (event == ui::SELECTION_HANDLES_SHOWN) | 1248 if (event == ui::SELECTION_HANDLES_SHOWN) |
| 1245 ResetGestureDetection(); | 1249 ResetGestureDetection(); |
| 1246 content_view_core_->OnSelectionEvent( | 1250 content_view_core_->OnSelectionEvent( |
| 1247 event, selection_controller_->GetStartPosition(), | 1251 event, selection_controller_->GetStartPosition(), |
| 1248 GetSelectionRect(*selection_controller_)); | 1252 GetSelectionRect(*selection_controller_)); |
| 1249 } | 1253 } |
| 1250 | 1254 |
| 1251 scoped_ptr<ui::TouchHandleDrawable> | 1255 scoped_ptr<ui::TouchHandleDrawable> |
| 1252 RenderWidgetHostViewAndroid::CreateDrawable() { | 1256 RenderWidgetHostViewAndroid::CreateDrawable() { |
| 1253 DCHECK(content_view_core_); | 1257 DCHECK(content_view_core_); |
| 1254 if (!using_browser_compositor_) | 1258 if (sync_compositor_) |
| 1255 return PopupTouchHandleDrawable::Create(content_view_core_); | 1259 return PopupTouchHandleDrawable::Create(content_view_core_); |
| 1256 | 1260 |
| 1257 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( | 1261 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( |
| 1258 content_view_core_->GetLayer().get(), | 1262 content_view_core_->GetLayer().get(), |
| 1259 content_view_core_->GetDpiScale(), | 1263 content_view_core_->GetDpiScale(), |
| 1260 // Use the activity context (instead of the application context) to ensure | 1264 // Use the activity context (instead of the application context) to ensure |
| 1261 // proper handle theming. | 1265 // proper handle theming. |
| 1262 content_view_core_->GetContext().obj())); | 1266 content_view_core_->GetContext().obj())); |
| 1263 } | 1267 } |
| 1264 | 1268 |
| 1265 void RenderWidgetHostViewAndroid::SynchronousCopyContents( | 1269 void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| 1266 const gfx::Rect& src_subrect_in_pixel, | 1270 const gfx::Rect& src_subrect_in_pixel, |
| 1267 const gfx::Size& dst_size_in_pixel, | 1271 const gfx::Size& dst_size_in_pixel, |
| 1268 const ReadbackRequestCallback& callback, | 1272 const ReadbackRequestCallback& callback, |
| 1269 const SkColorType color_type) { | 1273 const SkColorType color_type) { |
| 1274 DCHECK(sync_compositor_); | |
| 1270 gfx::Size input_size_in_pixel; | 1275 gfx::Size input_size_in_pixel; |
| 1271 if (src_subrect_in_pixel.IsEmpty()) | 1276 if (src_subrect_in_pixel.IsEmpty()) |
| 1272 input_size_in_pixel = texture_size_in_layer_; | 1277 input_size_in_pixel = texture_size_in_layer_; |
| 1273 else | 1278 else |
| 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 = | |
| 1285 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), | |
| 1286 host_->GetRoutingID()); | |
| 1287 if (!compositor) { | |
| 1288 callback.Run(SkBitmap(), READBACK_FAILED); | |
| 1289 return; | |
| 1290 } | |
| 1291 | |
| 1292 SkBitmap bitmap; | 1289 SkBitmap bitmap; |
| 1293 bitmap.allocPixels(SkImageInfo::Make(output_width, | 1290 bitmap.allocPixels(SkImageInfo::Make(output_width, |
| 1294 output_height, | 1291 output_height, |
| 1295 color_type, | 1292 color_type, |
| 1296 kPremul_SkAlphaType)); | 1293 kPremul_SkAlphaType)); |
| 1297 SkCanvas canvas(bitmap); | 1294 SkCanvas canvas(bitmap); |
| 1298 canvas.scale( | 1295 canvas.scale( |
| 1299 (float)output_width / (float)input_size_in_pixel.width(), | 1296 (float)output_width / (float)input_size_in_pixel.width(), |
| 1300 (float)output_height / (float)input_size_in_pixel.height()); | 1297 (float)output_height / (float)input_size_in_pixel.height()); |
| 1301 compositor->DemandDrawSw(&canvas); | 1298 sync_compositor_->DemandDrawSw(&canvas); |
| 1302 callback.Run(bitmap, READBACK_SUCCESS); | 1299 callback.Run(bitmap, READBACK_SUCCESS); |
| 1303 } | 1300 } |
| 1304 | 1301 |
| 1305 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( | 1302 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( |
| 1306 const cc::CompositorFrameMetadata& frame_metadata) { | 1303 const cc::CompositorFrameMetadata& frame_metadata) { |
| 1307 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); | 1304 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); |
| 1308 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); | 1305 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); |
| 1309 | 1306 |
| 1310 if (!content_view_core_) | 1307 if (!content_view_core_) |
| 1311 return; | 1308 return; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1466 | 1463 |
| 1467 observing_root_window_ = false; | 1464 observing_root_window_ = false; |
| 1468 content_view_core_window_android_->RemoveObserver(this); | 1465 content_view_core_window_android_->RemoveObserver(this); |
| 1469 } | 1466 } |
| 1470 | 1467 |
| 1471 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, | 1468 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, |
| 1472 base::TimeDelta vsync_period) { | 1469 base::TimeDelta vsync_period) { |
| 1473 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", | 1470 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", |
| 1474 "frame_time_us", frame_time.ToInternalValue()); | 1471 "frame_time_us", frame_time.ToInternalValue()); |
| 1475 | 1472 |
| 1476 if (using_browser_compositor_) { | 1473 if (!sync_compositor_) { |
| 1477 // TODO(brianderson): Replace this hardcoded deadline after Android | 1474 // TODO(brianderson): Replace this hardcoded deadline after Android |
| 1478 // switches to Surfaces and the Browser's commit isn't in the critcal path. | 1475 // switches to Surfaces and the Browser's commit isn't in the critcal path. |
| 1479 base::TimeTicks deadline = frame_time + (vsync_period * 0.6); | 1476 base::TimeTicks deadline = frame_time + (vsync_period * 0.6); |
| 1480 | 1477 |
| 1481 host_->Send(new ViewMsg_BeginFrame( | 1478 host_->Send(new ViewMsg_BeginFrame( |
| 1482 host_->GetRoutingID(), | 1479 host_->GetRoutingID(), |
| 1483 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 1480 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
| 1484 vsync_period, cc::BeginFrameArgs::NORMAL))); | 1481 vsync_period, cc::BeginFrameArgs::NORMAL))); |
| 1485 } else { | 1482 } else { |
| 1486 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID( | 1483 // The synchronous compositor synchronously does it's work in this call. |
| 1487 host_->GetProcess()->GetID(), host_->GetRoutingID()); | 1484 // It does not use a deadline. |
| 1488 if (compositor) { | 1485 sync_compositor_->BeginFrame(cc::BeginFrameArgs::Create( |
| 1489 // The synchronous compositor synchronously does it's work in this call. | 1486 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period, |
| 1490 // It does not use a deadline. | 1487 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 } | 1488 } |
| 1496 } | 1489 } |
| 1497 | 1490 |
| 1498 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1491 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
| 1499 bool needs_animate = false; | 1492 bool needs_animate = false; |
| 1500 if (overscroll_controller_) { | 1493 if (overscroll_controller_) { |
| 1501 needs_animate |= overscroll_controller_->Animate( | 1494 needs_animate |= overscroll_controller_->Animate( |
| 1502 frame_time, content_view_core_->GetLayer().get()); | 1495 frame_time, content_view_core_->GetLayer().get()); |
| 1503 } | 1496 } |
| 1504 if (selection_controller_) | 1497 if (selection_controller_) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1602 | 1595 |
| 1603 if (input_event.type == blink::WebInputEvent::GestureTapDown || | 1596 if (input_event.type == blink::WebInputEvent::GestureTapDown || |
| 1604 input_event.type == blink::WebInputEvent::TouchStart) { | 1597 input_event.type == blink::WebInputEvent::TouchStart) { |
| 1605 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance(); | 1598 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance(); |
| 1606 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | 1599 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); |
| 1607 if (shim && gpu_data && | 1600 if (shim && gpu_data && |
| 1608 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING)) | 1601 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING)) |
| 1609 shim->Send(new GpuMsg_WakeUpGpu); | 1602 shim->Send(new GpuMsg_WakeUpGpu); |
| 1610 } | 1603 } |
| 1611 | 1604 |
| 1612 SynchronousCompositorImpl* compositor = | 1605 if (sync_compositor_.get()) |
| 1613 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), | 1606 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; | 1607 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1618 } | 1608 } |
| 1619 | 1609 |
| 1620 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { | 1610 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { |
| 1621 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); | 1611 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); |
| 1622 RequestVSyncUpdate(FLUSH_INPUT); | 1612 RequestVSyncUpdate(FLUSH_INPUT); |
| 1623 } | 1613 } |
| 1624 | 1614 |
| 1625 BrowserAccessibilityManager* | 1615 BrowserAccessibilityManager* |
| 1626 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager( | 1616 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1738 } | 1728 } |
| 1739 | 1729 |
| 1740 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() { | 1730 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() { |
| 1741 if (id_allocator_) | 1731 if (id_allocator_) |
| 1742 return id_allocator_->id_namespace(); | 1732 return id_allocator_->id_namespace(); |
| 1743 return 0; | 1733 return 0; |
| 1744 } | 1734 } |
| 1745 | 1735 |
| 1746 void RenderWidgetHostViewAndroid::SetContentViewCore( | 1736 void RenderWidgetHostViewAndroid::SetContentViewCore( |
| 1747 ContentViewCoreImpl* content_view_core) { | 1737 ContentViewCoreImpl* content_view_core) { |
| 1738 // Android webview does not currently support switching ContentViewCoreImpl. | |
| 1739 DCHECK_IMPLIES(sync_compositor_, | |
| 1740 !content_view_core || !content_view_core_); | |
|
no sievers
2015/10/07 18:52:58
So this is what I think we support here:
- settin
boliu
2015/10/08 03:14:44
That case sounds the same as normally creating CVC
no sievers
2015/10/08 22:39:29
Maybe splitting up this function into AttachToCont
boliu
2015/10/09 02:22:16
Yes. But that never happens (yet) in webview, sinc
| |
| 1748 RemoveLayers(); | 1741 RemoveLayers(); |
| 1749 StopObservingRootWindow(); | 1742 StopObservingRootWindow(); |
| 1750 | 1743 |
| 1751 bool resize = false; | 1744 bool resize = false; |
| 1752 if (content_view_core != content_view_core_) { | 1745 if (content_view_core != content_view_core_) { |
| 1753 overscroll_controller_.reset(); | 1746 overscroll_controller_.reset(); |
| 1754 selection_controller_.reset(); | 1747 selection_controller_.reset(); |
| 1755 ReleaseLocksOnSurface(); | 1748 ReleaseLocksOnSurface(); |
| 1756 resize = true; | 1749 resize = true; |
| 1757 } | 1750 } |
| 1758 | 1751 |
| 1759 content_view_core_ = content_view_core; | 1752 content_view_core_ = content_view_core; |
| 1760 content_view_core_window_android_ = | 1753 content_view_core_window_android_ = |
| 1761 content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; | 1754 content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; |
| 1762 DCHECK_EQ(!!content_view_core_, !!content_view_core_window_android_); | 1755 DCHECK_EQ(!!content_view_core_, !!content_view_core_window_android_); |
| 1763 | 1756 |
| 1764 BrowserAccessibilityManager* manager = NULL; | 1757 BrowserAccessibilityManager* manager = NULL; |
| 1765 if (host_) | 1758 if (host_) |
| 1766 manager = host_->GetRootBrowserAccessibilityManager(); | 1759 manager = host_->GetRootBrowserAccessibilityManager(); |
| 1767 if (manager) { | 1760 if (manager) { |
| 1768 base::android::ScopedJavaLocalRef<jobject> obj; | 1761 base::android::ScopedJavaLocalRef<jobject> obj; |
| 1769 if (content_view_core_) | 1762 if (content_view_core_) |
| 1770 obj = content_view_core_->GetJavaObject(); | 1763 obj = content_view_core_->GetJavaObject(); |
| 1771 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); | 1764 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); |
| 1772 } | 1765 } |
| 1773 | 1766 |
| 1774 AttachLayers(); | 1767 AttachLayers(); |
| 1775 | 1768 if (!content_view_core_) { |
| 1776 if (!content_view_core_) | 1769 sync_compositor_.reset(); |
|
no sievers
2015/10/07 18:52:57
Actually I missed that if you do this, then some o
boliu
2015/10/08 03:14:44
Hmm, you are right. CVC can be set much later afte
no sievers
2015/10/08 22:39:29
Ok. Maybe we can revisit later. For example, maybe
boliu
2015/10/09 02:22:16
Maybe don't need that. I think most RVHWA is creat
| |
| 1777 return; | 1770 return; |
| 1771 } | |
| 1778 | 1772 |
| 1779 if (is_showing_) | 1773 if (is_showing_) |
| 1780 StartObservingRootWindow(); | 1774 StartObservingRootWindow(); |
| 1781 | 1775 |
| 1782 if (resize) | 1776 if (resize) |
| 1783 WasResized(); | 1777 WasResized(); |
| 1784 | 1778 |
| 1785 if (!selection_controller_) | 1779 if (!selection_controller_) |
| 1786 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1780 selection_controller_ = CreateSelectionController(this, content_view_core_); |
| 1787 | 1781 |
| 1788 if (!overscroll_controller_ && | 1782 if (!overscroll_controller_ && |
| 1789 content_view_core_window_android_->GetCompositor()) { | 1783 content_view_core_window_android_->GetCompositor()) { |
| 1790 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1784 overscroll_controller_ = CreateOverscrollController(content_view_core_); |
| 1791 } | 1785 } |
| 1786 | |
| 1787 if (!sync_compositor_) { | |
| 1788 sync_compositor_ = SynchronousCompositorImpl::Create( | |
| 1789 this, content_view_core_->GetWebContents()); | |
| 1790 } | |
| 1792 } | 1791 } |
| 1793 | 1792 |
| 1794 void RenderWidgetHostViewAndroid::RunAckCallbacks( | 1793 void RenderWidgetHostViewAndroid::RunAckCallbacks( |
| 1795 cc::SurfaceDrawStatus status) { | 1794 cc::SurfaceDrawStatus status) { |
| 1796 while (!ack_callbacks_.empty()) { | 1795 while (!ack_callbacks_.empty()) { |
| 1797 ack_callbacks_.front().Run(); | 1796 ack_callbacks_.front().Run(); |
| 1798 ack_callbacks_.pop(); | 1797 ack_callbacks_.pop(); |
| 1799 } | 1798 } |
| 1800 } | 1799 } |
| 1801 | 1800 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1830 } | 1829 } |
| 1831 | 1830 |
| 1832 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1831 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1833 DCHECK(content_view_core_); | 1832 DCHECK(content_view_core_); |
| 1834 if (!overscroll_controller_) | 1833 if (!overscroll_controller_) |
| 1835 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1834 overscroll_controller_ = CreateOverscrollController(content_view_core_); |
| 1836 } | 1835 } |
| 1837 | 1836 |
| 1838 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1837 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1839 DCHECK(content_view_core_); | 1838 DCHECK(content_view_core_); |
| 1840 DCHECK(using_browser_compositor_); | 1839 DCHECK(!sync_compositor_); |
| 1841 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1840 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
| 1842 overscroll_controller_.reset(); | 1841 overscroll_controller_.reset(); |
| 1843 } | 1842 } |
| 1844 | 1843 |
| 1845 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1844 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
| 1846 base::TimeDelta vsync_period) { | 1845 base::TimeDelta vsync_period) { |
| 1847 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1846 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
| 1848 if (!host_ || host_->is_hidden()) | 1847 if (!host_ || host_->is_hidden()) |
| 1849 return; | 1848 return; |
| 1850 | 1849 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2012 results->orientationAngle = display.RotationAsDegree(); | 2011 results->orientationAngle = display.RotationAsDegree(); |
| 2013 results->orientationType = | 2012 results->orientationType = |
| 2014 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2013 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 2015 gfx::DeviceDisplayInfo info; | 2014 gfx::DeviceDisplayInfo info; |
| 2016 results->depth = info.GetBitsPerPixel(); | 2015 results->depth = info.GetBitsPerPixel(); |
| 2017 results->depthPerComponent = info.GetBitsPerComponent(); | 2016 results->depthPerComponent = info.GetBitsPerComponent(); |
| 2018 results->isMonochrome = (results->depthPerComponent == 0); | 2017 results->isMonochrome = (results->depthPerComponent == 0); |
| 2019 } | 2018 } |
| 2020 | 2019 |
| 2021 } // namespace content | 2020 } // namespace content |
| OLD | NEW |