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

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

Issue 2118653005: Android: Remove some dead code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android: Remove some dead code 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 last_output_surface_id_(kUndefinedOutputSurfaceId), 318 last_output_surface_id_(kUndefinedOutputSurfaceId),
319 gesture_provider_(ui::GetGestureProviderConfig( 319 gesture_provider_(ui::GetGestureProviderConfig(
320 ui::GestureProviderConfigType::CURRENT_PLATFORM), 320 ui::GestureProviderConfigType::CURRENT_PLATFORM),
321 this), 321 this),
322 stylus_text_selector_(this), 322 stylus_text_selector_(this),
323 using_browser_compositor_(CompositorImpl::IsInitialized()), 323 using_browser_compositor_(CompositorImpl::IsInitialized()),
324 frame_evictor_(new DelegatedFrameEvictor(this)), 324 frame_evictor_(new DelegatedFrameEvictor(this)),
325 locks_on_frame_count_(0), 325 locks_on_frame_count_(0),
326 observing_root_window_(false), 326 observing_root_window_(false),
327 weak_ptr_factory_(this) { 327 weak_ptr_factory_(this) {
328 if (CompositorImpl::GetSurfaceManager()) 328 if (CompositorImpl::GetSurfaceManager())
danakj 2016/07/01 23:15:37 should this be a DCHECK or go away?
no sievers 2016/07/01 23:29:06 I removed it in ps1 but then remembered there is W
329 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator(); 329 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator();
330 host_->SetView(this); 330 host_->SetView(this);
331 SetContentViewCore(content_view_core); 331 SetContentViewCore(content_view_core);
332 } 332 }
333 333
334 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 334 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
335 if (content_view_core_) 335 if (content_view_core_)
336 content_view_core_->RemoveObserver(this); 336 content_view_core_->RemoveObserver(this);
337 SetContentViewCore(NULL); 337 SetContentViewCore(NULL);
338 DCHECK(ack_callbacks_.empty()); 338 DCHECK(ack_callbacks_.empty());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 float device_scale_factor = display.device_scale_factor(); 423 float device_scale_factor = display.device_scale_factor();
424 DCHECK_GT(device_scale_factor, 0); 424 DCHECK_GT(device_scale_factor, 0);
425 gfx::Size dst_size( 425 gfx::Size dst_size(
426 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); 426 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor));
427 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); 427 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect);
428 428
429 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, 429 CopyFromCompositingSurface(src_subrect, dst_size, result_callback,
430 preferred_color_type); 430 preferred_color_type);
431 } 431 }
432 432
433 scoped_refptr<cc::Layer> RenderWidgetHostViewAndroid::CreateDelegatedLayer() 433 scoped_refptr<cc::Layer> RenderWidgetHostViewAndroid::CreateSurfaceLayer()
danakj 2016/07/01 23:15:37 perhaps this return type can be SurfaceLayer?
no sievers 2016/07/01 23:29:06 Done.
434 const { 434 const {
435 scoped_refptr<cc::Layer> delegated_layer; 435 scoped_refptr<cc::Layer> delegated_layer;
danakj 2016/07/01 23:15:37 this variable can go
no sievers 2016/07/01 23:29:06 Done.
436 DCHECK(!surface_id_.is_null()); 436 DCHECK(!surface_id_.is_null());
437 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); 437 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager();
438 DCHECK(manager); 438 DCHECK(manager);
439 // manager must outlive compositors using it. 439 // manager must outlive compositors using it.
440 scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create( 440 scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create(
441 base::Bind(&SatisfyCallback, base::Unretained(manager)), 441 base::Bind(&SatisfyCallback, base::Unretained(manager)),
442 base::Bind(&RequireCallback, base::Unretained(manager))); 442 base::Bind(&RequireCallback, base::Unretained(manager)));
443 surface_layer->SetSurfaceId(surface_id_, 1.f, texture_size_in_layer_); 443 surface_layer->SetSurfaceId(surface_id_, 1.f, texture_size_in_layer_);
444 delegated_layer = surface_layer; 444 delegated_layer = surface_layer;
445 delegated_layer->SetBounds(texture_size_in_layer_); 445 delegated_layer->SetBounds(texture_size_in_layer_);
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 if (surface_id_.is_null() || 1002 if (surface_id_.is_null() ||
1003 texture_size_in_layer_ != current_surface_size_ || 1003 texture_size_in_layer_ != current_surface_size_ ||
1004 location_bar_content_translation_ != 1004 location_bar_content_translation_ !=
1005 frame.metadata.location_bar_content_translation || 1005 frame.metadata.location_bar_content_translation ||
1006 current_viewport_selection_ != frame.metadata.selection) { 1006 current_viewport_selection_ != frame.metadata.selection) {
1007 RemoveLayers(); 1007 RemoveLayers();
1008 if (!surface_id_.is_null()) 1008 if (!surface_id_.is_null())
1009 surface_factory_->Destroy(surface_id_); 1009 surface_factory_->Destroy(surface_id_);
1010 surface_id_ = id_allocator_->GenerateId(); 1010 surface_id_ = id_allocator_->GenerateId();
1011 surface_factory_->Create(surface_id_); 1011 surface_factory_->Create(surface_id_);
1012 layer_ = CreateDelegatedLayer(); 1012 layer_ = CreateSurfaceLayer();
1013 1013
1014 DCHECK(layer_); 1014 DCHECK(layer_);
1015 1015
1016 current_surface_size_ = texture_size_in_layer_; 1016 current_surface_size_ = texture_size_in_layer_;
1017 location_bar_content_translation_ = 1017 location_bar_content_translation_ =
1018 frame.metadata.location_bar_content_translation; 1018 frame.metadata.location_bar_content_translation;
1019 current_viewport_selection_ = frame.metadata.selection; 1019 current_viewport_selection_ = frame.metadata.selection;
1020 AttachLayers(); 1020 AttachLayers();
1021 } 1021 }
1022 1022
1023 cc::SurfaceFactory::DrawCallback ack_callback = 1023 cc::SurfaceFactory::DrawCallback ack_callback =
1024 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, 1024 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks,
1025 weak_ptr_factory_.GetWeakPtr()); 1025 weak_ptr_factory_.GetWeakPtr());
1026 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 1026 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
1027 ack_callback); 1027 ack_callback);
1028 } 1028 }
1029 1029
1030 void RenderWidgetHostViewAndroid::SwapDelegatedFrame( 1030 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
1031 uint32_t output_surface_id, 1031 uint32_t output_surface_id,
1032 cc::CompositorFrame frame) { 1032 cc::CompositorFrame frame) {
1033 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1034 DCHECK(frame.delegated_frame_data);
1035 DCHECK(CompositorImpl::GetSurfaceManager());
danakj 2016/07/01 23:15:37 Then does this add value if we DCHECK in construct
1036
1037 if (locks_on_frame_count_ > 0) {
1038 DCHECK(HasValidFrame());
1039 RetainFrame(output_surface_id, std::move(frame));
1040 return;
1041 }
1042
1043 DCHECK(!frame.delegated_frame_data->render_pass_list.empty());
1044
1045 cc::RenderPass* root_pass =
1046 frame.delegated_frame_data->render_pass_list.back().get();
1047 texture_size_in_layer_ = root_pass->output_rect.size();
1048
1049 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1050
1033 CheckOutputSurfaceChanged(output_surface_id); 1051 CheckOutputSurfaceChanged(output_surface_id);
1034 bool has_content = !texture_size_in_layer_.IsEmpty(); 1052 bool has_content = !texture_size_in_layer_.IsEmpty();
1035 1053
1036 base::Closure ack_callback = 1054 base::Closure ack_callback =
1037 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, 1055 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck,
1038 weak_ptr_factory_.GetWeakPtr(), 1056 weak_ptr_factory_.GetWeakPtr(),
1039 output_surface_id); 1057 output_surface_id);
1040 1058
1041 ack_callbacks_.push(ack_callback); 1059 ack_callbacks_.push(ack_callback);
1042 1060
1043 if (!has_content) { 1061 if (!has_content) {
1044 DestroyDelegatedContent(); 1062 DestroyDelegatedContent();
1045 } else { 1063 } else {
1046 SubmitCompositorFrame(std::move(frame)); 1064 SubmitCompositorFrame(std::move(frame));
1047 }
1048
1049 if (layer_.get()) {
1050 layer_->SetIsDrawable(true); 1065 layer_->SetIsDrawable(true);
1051 layer_->SetContentsOpaque(true); 1066 layer_->SetContentsOpaque(true);
1052 layer_->SetBounds(texture_size_in_layer_); 1067 layer_->SetBounds(texture_size_in_layer_);
1053 } 1068 }
1054 1069
1055 if (host_->is_hidden()) 1070 if (host_->is_hidden())
1056 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); 1071 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED);
1057 }
1058
1059 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
1060 uint32_t output_surface_id,
1061 cc::CompositorFrame frame) {
1062 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1063 if (!frame.delegated_frame_data) {
1064 LOG(ERROR) << "Non-delegated renderer path no longer supported";
1065 return;
1066 }
1067
1068 if (locks_on_frame_count_ > 0) {
1069 DCHECK(HasValidFrame());
1070 RetainFrame(output_surface_id, std::move(frame));
1071 return;
1072 }
1073
1074 if (!CompositorImpl::GetSurfaceManager() && layer_.get() &&
1075 layer_->layer_tree_host()) {
1076 for (size_t i = 0; i < frame.metadata.latency_info.size(); i++) {
1077 std::unique_ptr<cc::SwapPromise> swap_promise(
1078 new cc::LatencyInfoSwapPromise(frame.metadata.latency_info[i]));
1079 layer_->layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
1080 }
1081 }
1082
1083 DCHECK(!frame.delegated_frame_data->render_pass_list.empty());
1084
1085 cc::RenderPass* root_pass =
1086 frame.delegated_frame_data->render_pass_list.back().get();
1087 texture_size_in_layer_ = root_pass->output_rect.size();
1088
1089 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1090
1091 SwapDelegatedFrame(output_surface_id, std::move(frame));
1092 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1072 frame_evictor_->SwappedFrame(!host_->is_hidden());
1093 1073
1094 // As the metadata update may trigger view invalidation, always call it after 1074 // As the metadata update may trigger view invalidation, always call it after
1095 // any potential compositor scheduling. 1075 // any potential compositor scheduling.
1096 OnFrameMetadataUpdated(std::move(metadata)); 1076 OnFrameMetadataUpdated(std::move(metadata));
1097 } 1077 }
1098 1078
1099 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( 1079 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
1100 uint32_t output_surface_id, 1080 uint32_t output_surface_id,
1101 cc::CompositorFrame frame) { 1081 cc::CompositorFrame frame) {
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 case ui::MotionEvent::ACTION_UP: 1991 case ui::MotionEvent::ACTION_UP:
2012 case ui::MotionEvent::ACTION_POINTER_UP: 1992 case ui::MotionEvent::ACTION_POINTER_UP:
2013 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 1993 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
2014 delta.InMicroseconds(), 1, 1000000, 50); 1994 delta.InMicroseconds(), 1, 1000000, 50);
2015 default: 1995 default:
2016 return; 1996 return;
2017 } 1997 }
2018 } 1998 }
2019 1999
2020 } // namespace content 2000 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698