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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2122403002: Android: Extend ViewAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months 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 (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 <utility> 9 #include <utility>
10 10
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( 425 void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
426 float scale, 426 float scale,
427 SkColorType preferred_color_type, 427 SkColorType preferred_color_type,
428 gfx::Rect src_subrect, 428 gfx::Rect src_subrect,
429 const ReadbackRequestCallback& result_callback) { 429 const ReadbackRequestCallback& result_callback) {
430 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { 430 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) {
431 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); 431 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE);
432 return; 432 return;
433 } 433 }
434 gfx::Size bounds = layer_->bounds(); 434 gfx::Size bounds = view_.GetLayer()->bounds();
435 if (src_subrect.IsEmpty()) 435 if (src_subrect.IsEmpty())
436 src_subrect = gfx::Rect(bounds); 436 src_subrect = gfx::Rect(bounds);
437 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); 437 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width());
438 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); 438 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height());
439 const display::Display& display = 439 const display::Display& display =
440 display::Screen::GetScreen()->GetPrimaryDisplay(); 440 display::Screen::GetScreen()->GetPrimaryDisplay();
441 float device_scale_factor = display.device_scale_factor(); 441 float device_scale_factor = display.device_scale_factor();
442 DCHECK_GT(device_scale_factor, 0); 442 DCHECK_GT(device_scale_factor, 0);
443 gfx::Size dst_size( 443 gfx::Size dst_size(
444 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); 444 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor));
445 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); 445 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect);
446 446
447 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, 447 CopyFromCompositingSurface(src_subrect, dst_size, result_callback,
448 preferred_color_type); 448 preferred_color_type);
449 } 449 }
450 450
451 bool RenderWidgetHostViewAndroid::HasValidFrame() const { 451 bool RenderWidgetHostViewAndroid::HasValidFrame() const {
452 if (!content_view_core_) 452 if (!content_view_core_)
453 return false; 453 return false;
454 if (!layer_.get()) 454 if (!view_.GetLayer())
455 return false; 455 return false;
456 456
457 if (texture_size_in_layer_.IsEmpty()) 457 if (texture_size_in_layer_.IsEmpty())
458 return false; 458 return false;
459 // This tell us whether a valid frame has arrived or not. 459 // This tell us whether a valid frame has arrived or not.
460 if (!frame_evictor_->HasFrame()) 460 if (!frame_evictor_->HasFrame())
461 return false; 461 return false;
462 462
463 return true; 463 return true;
464 } 464 }
465 465
466 gfx::Vector2dF RenderWidgetHostViewAndroid::GetLastScrollOffset() const { 466 gfx::Vector2dF RenderWidgetHostViewAndroid::GetLastScrollOffset() const {
467 return last_scroll_offset_; 467 return last_scroll_offset_;
468 } 468 }
469 469
470 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { 470 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
471 return content_view_core_; 471 return &view_;
472 } 472 }
473 473
474 gfx::NativeViewAccessible 474 gfx::NativeViewAccessible
475 RenderWidgetHostViewAndroid::GetNativeViewAccessible() { 475 RenderWidgetHostViewAndroid::GetNativeViewAccessible() {
476 NOTIMPLEMENTED(); 476 NOTIMPLEMENTED();
477 return NULL; 477 return NULL;
478 } 478 }
479 479
480 void RenderWidgetHostViewAndroid::Focus() { 480 void RenderWidgetHostViewAndroid::Focus() {
481 host_->Focus(); 481 host_->Focus();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 locks_on_frame_count_--; 541 locks_on_frame_count_--;
542 frame_evictor_->UnlockFrame(); 542 frame_evictor_->UnlockFrame();
543 543
544 if (locks_on_frame_count_ == 0) { 544 if (locks_on_frame_count_ == 0) {
545 if (last_frame_info_) { 545 if (last_frame_info_) {
546 InternalSwapCompositorFrame(last_frame_info_->output_surface_id, 546 InternalSwapCompositorFrame(last_frame_info_->output_surface_id,
547 std::move(last_frame_info_->frame)); 547 std::move(last_frame_info_->frame));
548 last_frame_info_.reset(); 548 last_frame_info_.reset();
549 } 549 }
550 550
551 if (!is_showing_ && layer_.get()) 551 if (!is_showing_ && view_.GetLayer())
552 layer_->SetHideLayerAndSubtree(true); 552 view_.GetLayer()->SetHideLayerAndSubtree(true);
553 } 553 }
554 } 554 }
555 555
556 void RenderWidgetHostViewAndroid::SetTextSurroundingSelectionCallback( 556 void RenderWidgetHostViewAndroid::SetTextSurroundingSelectionCallback(
557 const TextSurroundingSelectionCallback& callback) { 557 const TextSurroundingSelectionCallback& callback) {
558 // Only one outstanding request is allowed at any given time. 558 // Only one outstanding request is allowed at any given time.
559 DCHECK(!callback.is_null()); 559 DCHECK(!callback.is_null());
560 text_surrounding_selection_callback_ = callback; 560 text_surrounding_selection_callback_ = callback;
561 } 561 }
562 562
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 DCHECK(compositor); 897 DCHECK(compositor);
898 DCHECK(!surface_id_.is_null()); 898 DCHECK(!surface_id_.is_null());
899 std::unique_ptr<cc::CopyOutputRequest> request = 899 std::unique_ptr<cc::CopyOutputRequest> request =
900 cc::CopyOutputRequest::CreateRequest(base::Bind( 900 cc::CopyOutputRequest::CreateRequest(base::Bind(
901 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(), 901 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(),
902 dst_size_in_pixel, preferred_color_type, start_time, callback)); 902 dst_size_in_pixel, preferred_color_type, start_time, callback));
903 if (!src_subrect_in_pixel.IsEmpty()) 903 if (!src_subrect_in_pixel.IsEmpty())
904 request->set_area(src_subrect_in_pixel); 904 request->set_area(src_subrect_in_pixel);
905 // Make sure the layer doesn't get deleted until we fulfill the request. 905 // Make sure the layer doesn't get deleted until we fulfill the request.
906 LockCompositingSurface(); 906 LockCompositingSurface();
907 layer_->RequestCopyOfOutput(std::move(request)); 907 view_.GetLayer()->RequestCopyOfOutput(std::move(request));
908 } 908 }
909 909
910 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 910 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
911 const gfx::Rect& src_subrect, 911 const gfx::Rect& src_subrect,
912 const scoped_refptr<media::VideoFrame>& target, 912 const scoped_refptr<media::VideoFrame>& target,
913 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 913 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
914 NOTIMPLEMENTED(); 914 NOTIMPLEMENTED();
915 callback.Run(gfx::Rect(), false); 915 callback.Run(gfx::Rect(), false);
916 } 916 }
917 917
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 // TODO(tansell): Hook this up. 970 // TODO(tansell): Hook this up.
971 } 971 }
972 972
973 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { 973 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
974 RemoveLayers(); 974 RemoveLayers();
975 if (!surface_id_.is_null()) { 975 if (!surface_id_.is_null()) {
976 DCHECK(surface_factory_.get()); 976 DCHECK(surface_factory_.get());
977 surface_factory_->Destroy(surface_id_); 977 surface_factory_->Destroy(surface_id_);
978 surface_id_ = cc::SurfaceId(); 978 surface_id_ = cc::SurfaceId();
979 } 979 }
980 layer_ = NULL; 980 view_.SetLayer(nullptr);
981 } 981 }
982 982
983 void RenderWidgetHostViewAndroid::CheckOutputSurfaceChanged( 983 void RenderWidgetHostViewAndroid::CheckOutputSurfaceChanged(
984 uint32_t output_surface_id) { 984 uint32_t output_surface_id) {
985 if (output_surface_id == last_output_surface_id_) 985 if (output_surface_id == last_output_surface_id_)
986 return; 986 return;
987 DestroyDelegatedContent(); 987 DestroyDelegatedContent();
988 surface_factory_.reset(); 988 surface_factory_.reset();
989 if (!surface_returned_resources_.empty()) 989 if (!surface_returned_resources_.empty())
990 SendReturnedDelegatedResources(last_output_surface_id_); 990 SendReturnedDelegatedResources(last_output_surface_id_);
(...skipping 10 matching lines...) Expand all
1001 if (surface_id_.is_null() || 1001 if (surface_id_.is_null() ||
1002 texture_size_in_layer_ != current_surface_size_ || 1002 texture_size_in_layer_ != current_surface_size_ ||
1003 location_bar_content_translation_ != 1003 location_bar_content_translation_ !=
1004 frame.metadata.location_bar_content_translation || 1004 frame.metadata.location_bar_content_translation ||
1005 current_viewport_selection_ != frame.metadata.selection) { 1005 current_viewport_selection_ != frame.metadata.selection) {
1006 RemoveLayers(); 1006 RemoveLayers();
1007 if (!surface_id_.is_null()) 1007 if (!surface_id_.is_null())
1008 surface_factory_->Destroy(surface_id_); 1008 surface_factory_->Destroy(surface_id_);
1009 surface_id_ = id_allocator_->GenerateId(); 1009 surface_id_ = id_allocator_->GenerateId();
1010 surface_factory_->Create(surface_id_); 1010 surface_factory_->Create(surface_id_);
1011 layer_ = CreateSurfaceLayer(surface_id_, texture_size_in_layer_); 1011 view_.SetLayer(CreateSurfaceLayer(surface_id_, texture_size_in_layer_));
1012 1012
1013 DCHECK(layer_); 1013 DCHECK(view_.GetLayer());
1014 1014
1015 current_surface_size_ = texture_size_in_layer_; 1015 current_surface_size_ = texture_size_in_layer_;
1016 location_bar_content_translation_ = 1016 location_bar_content_translation_ =
1017 frame.metadata.location_bar_content_translation; 1017 frame.metadata.location_bar_content_translation;
1018 current_viewport_selection_ = frame.metadata.selection; 1018 current_viewport_selection_ = frame.metadata.selection;
1019 AttachLayers(); 1019 AttachLayers();
1020 } 1020 }
1021 1021
1022 cc::SurfaceFactory::DrawCallback ack_callback = 1022 cc::SurfaceFactory::DrawCallback ack_callback =
1023 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, 1023 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks,
(...skipping 30 matching lines...) Expand all
1054 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, 1054 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck,
1055 weak_ptr_factory_.GetWeakPtr(), 1055 weak_ptr_factory_.GetWeakPtr(),
1056 output_surface_id); 1056 output_surface_id);
1057 1057
1058 ack_callbacks_.push(ack_callback); 1058 ack_callbacks_.push(ack_callback);
1059 1059
1060 if (!has_content) { 1060 if (!has_content) {
1061 DestroyDelegatedContent(); 1061 DestroyDelegatedContent();
1062 } else { 1062 } else {
1063 SubmitCompositorFrame(std::move(frame)); 1063 SubmitCompositorFrame(std::move(frame));
1064 layer_->SetIsDrawable(true); 1064 view_.GetLayer()->SetIsDrawable(true);
1065 layer_->SetContentsOpaque(true); 1065 view_.GetLayer()->SetContentsOpaque(true);
1066 layer_->SetBounds(texture_size_in_layer_); 1066 view_.GetLayer()->SetBounds(texture_size_in_layer_);
1067 } 1067 }
1068 1068
1069 if (host_->is_hidden()) 1069 if (host_->is_hidden())
1070 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); 1070 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED);
1071 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1071 frame_evictor_->SwappedFrame(!host_->is_hidden());
1072 1072
1073 // As the metadata update may trigger view invalidation, always call it after 1073 // As the metadata update may trigger view invalidation, always call it after
1074 // any potential compositor scheduling. 1074 // any potential compositor scheduling.
1075 OnFrameMetadataUpdated(std::move(metadata)); 1075 OnFrameMetadataUpdated(std::move(metadata));
1076 } 1076 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 BrowserThread::PostTask( 1124 BrowserThread::PostTask(
1125 BrowserThread::UI, FROM_HERE, 1125 BrowserThread::UI, FROM_HERE,
1126 base::Bind( 1126 base::Bind(
1127 &RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame, 1127 &RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame,
1128 static_cast<RenderFrameDevToolsAgentHost*>(dtah.get()), 1128 static_cast<RenderFrameDevToolsAgentHost*>(dtah.get()),
1129 base::Passed(&frame_metadata))); 1129 base::Passed(&frame_metadata)));
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) { 1133 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) {
1134 if (layer_.get()) 1134 if (view_.GetLayer())
1135 layer_->SetContentsOpaque(!enabled); 1135 view_.GetLayer()->SetContentsOpaque(!enabled);
1136 } 1136 }
1137 1137
1138 bool RenderWidgetHostViewAndroid::SupportsAnimation() const { 1138 bool RenderWidgetHostViewAndroid::SupportsAnimation() const {
1139 // The synchronous (WebView) compositor does not have a proper browser 1139 // The synchronous (WebView) compositor does not have a proper browser
1140 // compositor with which to drive animations. 1140 // compositor with which to drive animations.
1141 return using_browser_compositor_; 1141 return using_browser_compositor_;
1142 } 1142 }
1143 1143
1144 void RenderWidgetHostViewAndroid::SetNeedsAnimate() { 1144 void RenderWidgetHostViewAndroid::SetNeedsAnimate() {
1145 DCHECK(content_view_core_ && content_view_core_->GetWindowAndroid()); 1145 DCHECK(content_view_core_ && content_view_core_->GetWindowAndroid());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1181 }
1182 1182
1183 std::unique_ptr<ui::TouchHandleDrawable> 1183 std::unique_ptr<ui::TouchHandleDrawable>
1184 RenderWidgetHostViewAndroid::CreateDrawable() { 1184 RenderWidgetHostViewAndroid::CreateDrawable() {
1185 DCHECK(content_view_core_); 1185 DCHECK(content_view_core_);
1186 if (!using_browser_compositor_) 1186 if (!using_browser_compositor_)
1187 return PopupTouchHandleDrawable::Create(content_view_core_); 1187 return PopupTouchHandleDrawable::Create(content_view_core_);
1188 1188
1189 return std::unique_ptr< 1189 return std::unique_ptr<
1190 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( 1190 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable(
1191 content_view_core_->GetLayer().get(), content_view_core_->GetDpiScale(), 1191 content_view_core_->GetLayer(), content_view_core_->GetDpiScale(),
1192 // Use the activity context (instead of the application context) to ensure 1192 // Use the activity context (instead of the application context) to ensure
1193 // proper handle theming. 1193 // proper handle theming.
1194 content_view_core_->GetContext().obj())); 1194 content_view_core_->GetContext().obj()));
1195 } 1195 }
1196 1196
1197 void RenderWidgetHostViewAndroid::SynchronousCopyContents( 1197 void RenderWidgetHostViewAndroid::SynchronousCopyContents(
1198 const gfx::Rect& src_subrect_in_pixel, 1198 const gfx::Rect& src_subrect_in_pixel,
1199 const gfx::Size& dst_size_in_pixel, 1199 const gfx::Size& dst_size_in_pixel,
1200 const ReadbackRequestCallback& callback, 1200 const ReadbackRequestCallback& callback,
1201 const SkColorType color_type) { 1201 const SkColorType color_type) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 } 1287 }
1288 1288
1289 void RenderWidgetHostViewAndroid::ShowInternal() { 1289 void RenderWidgetHostViewAndroid::ShowInternal() {
1290 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_; 1290 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_;
1291 if (!show) 1291 if (!show)
1292 return; 1292 return;
1293 1293
1294 if (!host_ || !host_->is_hidden()) 1294 if (!host_ || !host_->is_hidden())
1295 return; 1295 return;
1296 1296
1297 if (layer_.get()) 1297 if (view_.GetLayer())
1298 layer_->SetHideLayerAndSubtree(false); 1298 view_.GetLayer()->SetHideLayerAndSubtree(false);
1299 1299
1300 frame_evictor_->SetVisible(true); 1300 frame_evictor_->SetVisible(true);
1301 1301
1302 if (overscroll_controller_) 1302 if (overscroll_controller_)
1303 overscroll_controller_->Enable(); 1303 overscroll_controller_->Enable();
1304 1304
1305 host_->WasShown(ui::LatencyInfo()); 1305 host_->WasShown(ui::LatencyInfo());
1306 1306
1307 if (content_view_core_) { 1307 if (content_view_core_) {
1308 StartObservingRootWindow(); 1308 StartObservingRootWindow();
1309 RequestVSyncUpdate(BEGIN_FRAME); 1309 RequestVSyncUpdate(BEGIN_FRAME);
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 void RenderWidgetHostViewAndroid::HideInternal() { 1313 void RenderWidgetHostViewAndroid::HideInternal() {
1314 DCHECK(!is_showing_ || !is_window_activity_started_ || !is_window_visible_) 1314 DCHECK(!is_showing_ || !is_window_activity_started_ || !is_window_visible_)
1315 << "Hide called when the widget should be shown."; 1315 << "Hide called when the widget should be shown.";
1316 1316
1317 // Only preserve the frontbuffer if the activity was stopped while the 1317 // Only preserve the frontbuffer if the activity was stopped while the
1318 // window is still visible. This avoids visual artificts when transitioning 1318 // window is still visible. This avoids visual artificts when transitioning
1319 // between activities. 1319 // between activities.
1320 bool hide_frontbuffer = is_window_activity_started_ || !is_window_visible_; 1320 bool hide_frontbuffer = is_window_activity_started_ || !is_window_visible_;
1321 1321
1322 // Only stop observing the root window if the widget has been explicitly 1322 // Only stop observing the root window if the widget has been explicitly
1323 // hidden and the frontbuffer is being cleared. This allows window visibility 1323 // hidden and the frontbuffer is being cleared. This allows window visibility
1324 // notifications to eventually clear the frontbuffer. 1324 // notifications to eventually clear the frontbuffer.
1325 bool stop_observing_root_window = !is_showing_ && hide_frontbuffer; 1325 bool stop_observing_root_window = !is_showing_ && hide_frontbuffer;
1326 1326
1327 if (hide_frontbuffer) { 1327 if (hide_frontbuffer) {
1328 if (layer_.get() && locks_on_frame_count_ == 0) 1328 if (view_.GetLayer() && locks_on_frame_count_ == 0)
1329 layer_->SetHideLayerAndSubtree(true); 1329 view_.GetLayer()->SetHideLayerAndSubtree(true);
1330 1330
1331 frame_evictor_->SetVisible(false); 1331 frame_evictor_->SetVisible(false);
1332 } 1332 }
1333 1333
1334 if (stop_observing_root_window) { 1334 if (stop_observing_root_window) {
1335 DCHECK(!is_showing_); 1335 DCHECK(!is_showing_);
1336 StopObservingRootWindow(); 1336 StopObservingRootWindow();
1337 } 1337 }
1338 1338
1339 if (!host_ || host_->is_hidden()) 1339 if (!host_ || host_->is_hidden())
1340 return; 1340 return;
1341 1341
1342 if (overscroll_controller_) 1342 if (overscroll_controller_)
1343 overscroll_controller_->Disable(); 1343 overscroll_controller_->Disable();
1344 1344
1345 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); 1345 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED);
1346 1346
1347 // Inform the renderer that we are being hidden so it can reduce its resource 1347 // Inform the renderer that we are being hidden so it can reduce its resource
1348 // utilization. 1348 // utilization.
1349 host_->WasHidden(); 1349 host_->WasHidden();
1350 } 1350 }
1351 1351
1352 void RenderWidgetHostViewAndroid::AttachLayers() { 1352 void RenderWidgetHostViewAndroid::AttachLayers() {
1353 if (!content_view_core_) 1353 if (!content_view_core_)
1354 return; 1354 return;
1355 if (!layer_.get()) 1355 if (!view_.GetLayer())
1356 return; 1356 return;
1357 1357
1358 content_view_core_->AttachLayer(layer_); 1358 content_view_core_->AttachLayer(view_.GetLayer());
1359 layer_->SetHideLayerAndSubtree(!is_showing_); 1359 view_.GetLayer()->SetHideLayerAndSubtree(!is_showing_);
1360 } 1360 }
1361 1361
1362 void RenderWidgetHostViewAndroid::RemoveLayers() { 1362 void RenderWidgetHostViewAndroid::RemoveLayers() {
1363 if (!content_view_core_) 1363 if (!content_view_core_)
1364 return; 1364 return;
1365 1365
1366 if (!layer_.get()) 1366 if (!view_.GetLayer())
1367 return; 1367 return;
1368 1368
1369 content_view_core_->RemoveLayer(layer_); 1369 content_view_core_->RemoveLayer(view_.GetLayer());
1370 } 1370 }
1371 1371
1372 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32_t requests) { 1372 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32_t requests) {
1373 bool should_request_vsync = !outstanding_vsync_requests_ && requests; 1373 bool should_request_vsync = !outstanding_vsync_requests_ && requests;
1374 outstanding_vsync_requests_ |= requests; 1374 outstanding_vsync_requests_ |= requests;
1375 1375
1376 // Note that if we're not currently observing the root window, outstanding 1376 // Note that if we're not currently observing the root window, outstanding
1377 // vsync requests will be pushed if/when we resume observing in 1377 // vsync requests will be pushed if/when we resume observing in
1378 // |StartObservingRootWindow()|. 1378 // |StartObservingRootWindow()|.
1379 if (observing_root_window_ && should_request_vsync) 1379 if (observing_root_window_ && should_request_vsync)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, 1433 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
1434 vsync_period, cc::BeginFrameArgs::NORMAL))); 1434 vsync_period, cc::BeginFrameArgs::NORMAL)));
1435 if (sync_compositor_) 1435 if (sync_compositor_)
1436 sync_compositor_->DidSendBeginFrame(); 1436 sync_compositor_->DidSendBeginFrame();
1437 } 1437 }
1438 1438
1439 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { 1439 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
1440 bool needs_animate = false; 1440 bool needs_animate = false;
1441 if (overscroll_controller_) { 1441 if (overscroll_controller_) {
1442 needs_animate |= overscroll_controller_->Animate( 1442 needs_animate |= overscroll_controller_->Animate(
1443 frame_time, content_view_core_->GetLayer().get()); 1443 frame_time, content_view_core_->GetLayer());
1444 } 1444 }
1445 if (selection_controller_) 1445 if (selection_controller_)
1446 needs_animate |= selection_controller_->Animate(frame_time); 1446 needs_animate |= selection_controller_->Animate(frame_time);
1447 return needs_animate; 1447 return needs_animate;
1448 } 1448 }
1449 1449
1450 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { 1450 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() {
1451 if (content_view_core_) 1451 if (content_view_core_)
1452 content_view_core_->RequestDisallowInterceptTouchEvent(); 1452 content_view_core_->RequestDisallowInterceptTouchEvent();
1453 } 1453 }
1454 1454
1455 void RenderWidgetHostViewAndroid::EvictDelegatedFrame() { 1455 void RenderWidgetHostViewAndroid::EvictDelegatedFrame() {
1456 DCHECK_EQ(locks_on_frame_count_, 0u); 1456 DCHECK_EQ(locks_on_frame_count_, 0u);
1457 frame_evictor_->DiscardedFrame(); 1457 frame_evictor_->DiscardedFrame();
1458 if (layer_.get()) 1458 if (view_.GetLayer())
1459 DestroyDelegatedContent(); 1459 DestroyDelegatedContent();
1460 } 1460 }
1461 1461
1462 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 1462 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
1463 const gfx::Size& desired_size) { 1463 const gfx::Size& desired_size) {
1464 NOTREACHED(); 1464 NOTREACHED();
1465 return false; 1465 return false;
1466 } 1466 }
1467 1467
1468 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { 1468 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 1659
1660 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { 1660 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
1661 return cached_background_color_; 1661 return cached_background_color_;
1662 } 1662 }
1663 1663
1664 void RenderWidgetHostViewAndroid::DidOverscroll( 1664 void RenderWidgetHostViewAndroid::DidOverscroll(
1665 const DidOverscrollParams& params) { 1665 const DidOverscrollParams& params) {
1666 if (sync_compositor_) 1666 if (sync_compositor_)
1667 sync_compositor_->DidOverscroll(params); 1667 sync_compositor_->DidOverscroll(params);
1668 1668
1669 if (!content_view_core_ || !layer_.get() || !is_showing_) 1669 if (!content_view_core_ || !view_.GetLayer() || !is_showing_)
1670 return; 1670 return;
1671 1671
1672 if (overscroll_controller_) 1672 if (overscroll_controller_)
1673 overscroll_controller_->OnOverscrolled(params); 1673 overscroll_controller_->OnOverscrolled(params);
1674 } 1674 }
1675 1675
1676 void RenderWidgetHostViewAndroid::DidStopFlinging() { 1676 void RenderWidgetHostViewAndroid::DidStopFlinging() {
1677 if (content_view_core_) 1677 if (content_view_core_)
1678 content_view_core_->DidStopFlinging(); 1678 content_view_core_->DidStopFlinging();
1679 } 1679 }
(...skipping 10 matching lines...) Expand all
1690 (content_view_core_ == content_view_core)); 1690 (content_view_core_ == content_view_core));
1691 RemoveLayers(); 1691 RemoveLayers();
1692 StopObservingRootWindow(); 1692 StopObservingRootWindow();
1693 1693
1694 bool resize = false; 1694 bool resize = false;
1695 if (content_view_core != content_view_core_) { 1695 if (content_view_core != content_view_core_) {
1696 overscroll_controller_.reset(); 1696 overscroll_controller_.reset();
1697 selection_controller_.reset(); 1697 selection_controller_.reset();
1698 ReleaseLocksOnSurface(); 1698 ReleaseLocksOnSurface();
1699 resize = true; 1699 resize = true;
1700 if (content_view_core_) 1700 if (content_view_core_) {
1701 content_view_core_->RemoveObserver(this); 1701 content_view_core_->RemoveObserver(this);
1702 if (content_view_core) 1702 content_view_core_->GetViewAndroid()->RemoveChild(&view_);
1703 }
1704 if (content_view_core) {
1703 content_view_core->AddObserver(this); 1705 content_view_core->AddObserver(this);
1706 content_view_core->GetViewAndroid()->AddChild(&view_);
1707 }
1708 content_view_core_ = content_view_core;
1704 } 1709 }
1705 1710
1706 content_view_core_ = content_view_core;
1707
1708 BrowserAccessibilityManager* manager = NULL; 1711 BrowserAccessibilityManager* manager = NULL;
1709 if (host_) 1712 if (host_)
1710 manager = host_->GetRootBrowserAccessibilityManager(); 1713 manager = host_->GetRootBrowserAccessibilityManager();
1711 if (manager) { 1714 if (manager) {
1712 base::android::ScopedJavaLocalRef<jobject> obj; 1715 base::android::ScopedJavaLocalRef<jobject> obj;
1713 if (content_view_core_) 1716 if (content_view_core_)
1714 obj = content_view_core_->GetJavaObject(); 1717 obj = content_view_core_->GetJavaObject();
1715 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); 1718 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj);
1716 } 1719 }
1717 1720
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 1855
1853 void RenderWidgetHostViewAndroid::OnActivityStarted() { 1856 void RenderWidgetHostViewAndroid::OnActivityStarted() {
1854 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityStarted"); 1857 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityStarted");
1855 DCHECK(observing_root_window_); 1858 DCHECK(observing_root_window_);
1856 is_window_activity_started_ = true; 1859 is_window_activity_started_ = true;
1857 ShowInternal(); 1860 ShowInternal();
1858 } 1861 }
1859 1862
1860 void RenderWidgetHostViewAndroid::OnLostResources() { 1863 void RenderWidgetHostViewAndroid::OnLostResources() {
1861 ReleaseLocksOnSurface(); 1864 ReleaseLocksOnSurface();
1862 if (layer_.get()) 1865 if (view_.GetLayer())
1863 DestroyDelegatedContent(); 1866 DestroyDelegatedContent();
1864 DCHECK(ack_callbacks_.empty()); 1867 DCHECK(ack_callbacks_.empty());
1865 } 1868 }
1866 1869
1867 // TODO(wjmaclean): There is significant overlap between 1870 // TODO(wjmaclean): There is significant overlap between
1868 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in 1871 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in
1869 // this file, and the versions in surface_utils.cc. They should 1872 // this file, and the versions in surface_utils.cc. They should
1870 // be merged. See https://crbug.com/582955 1873 // be merged. See https://crbug.com/582955
1871 1874
1872 // static 1875 // static
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 case ui::MotionEvent::ACTION_UP: 1993 case ui::MotionEvent::ACTION_UP:
1991 case ui::MotionEvent::ACTION_POINTER_UP: 1994 case ui::MotionEvent::ACTION_POINTER_UP:
1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 1995 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1993 delta.InMicroseconds(), 1, 1000000, 50); 1996 delta.InMicroseconds(), 1, 1000000, 50);
1994 default: 1997 default:
1995 return; 1998 return;
1996 } 1999 }
1997 } 2000 }
1998 2001
1999 } // namespace content 2002 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698