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

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

Issue 2190033002: content: Add ContextProviderFactory to create a render ContextProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: .. Created 4 years, 4 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "content/public/common/content_switches.h" 69 #include "content/public/common/content_switches.h"
70 #include "gpu/command_buffer/client/gles2_implementation.h" 70 #include "gpu/command_buffer/client/gles2_implementation.h"
71 #include "gpu/command_buffer/client/gles2_interface.h" 71 #include "gpu/command_buffer/client/gles2_interface.h"
72 #include "gpu/config/gpu_driver_bug_workaround_type.h" 72 #include "gpu/config/gpu_driver_bug_workaround_type.h"
73 #include "ipc/ipc_message_macros.h" 73 #include "ipc/ipc_message_macros.h"
74 #include "ipc/ipc_message_start.h" 74 #include "ipc/ipc_message_start.h"
75 #include "skia/ext/image_operations.h" 75 #include "skia/ext/image_operations.h"
76 #include "third_party/khronos/GLES2/gl2.h" 76 #include "third_party/khronos/GLES2/gl2.h"
77 #include "third_party/khronos/GLES2/gl2ext.h" 77 #include "third_party/khronos/GLES2/gl2ext.h"
78 #include "third_party/skia/include/core/SkCanvas.h" 78 #include "third_party/skia/include/core/SkCanvas.h"
79 #include "ui/android/context_provider_factory.h"
79 #include "ui/android/window_android.h" 80 #include "ui/android/window_android.h"
80 #include "ui/android/window_android_compositor.h" 81 #include "ui/android/window_android_compositor.h"
81 #include "ui/base/layout.h" 82 #include "ui/base/layout.h"
82 #include "ui/display/display.h" 83 #include "ui/display/display.h"
83 #include "ui/display/screen.h" 84 #include "ui/display/screen.h"
84 #include "ui/events/blink/blink_event_util.h" 85 #include "ui/events/blink/blink_event_util.h"
85 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" 86 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
86 #include "ui/events/gesture_detection/motion_event.h" 87 #include "ui/events/gesture_detection/motion_event.h"
87 #include "ui/gfx/android/device_display_info.h" 88 #include "ui/gfx/android/device_display_info.h"
88 #include "ui/gfx/android/java_bitmap.h" 89 #include "ui/gfx/android/java_bitmap.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 284
284 rect.Union(controller.GetStartHandleRect()); 285 rect.Union(controller.GetStartHandleRect());
285 rect.Union(controller.GetEndHandleRect()); 286 rect.Union(controller.GetEndHandleRect());
286 return rect; 287 return rect;
287 } 288 }
288 289
289 scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer( 290 scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer(
290 const cc::SurfaceId& surface_id, 291 const cc::SurfaceId& surface_id,
291 const gfx::Size& size) { 292 const gfx::Size& size) {
292 DCHECK(!surface_id.is_null()); 293 DCHECK(!surface_id.is_null());
293 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); 294 cc::SurfaceManager* manager =
295 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
294 DCHECK(manager); 296 DCHECK(manager);
295 // manager must outlive compositors using it. 297 // manager must outlive compositors using it.
296 scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create( 298 scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create(
297 base::Bind(&SatisfyCallback, base::Unretained(manager)), 299 base::Bind(&SatisfyCallback, base::Unretained(manager)),
298 base::Bind(&RequireCallback, base::Unretained(manager))); 300 base::Bind(&RequireCallback, base::Unretained(manager)));
299 surface_layer->SetSurfaceId(surface_id, 1.f, size); 301 surface_layer->SetSurfaceId(surface_id, 1.f, size);
300 surface_layer->SetBounds(size); 302 surface_layer->SetBounds(size);
301 surface_layer->SetIsDrawable(true); 303 surface_layer->SetIsDrawable(true);
302 surface_layer->SetContentsOpaque(true); 304 surface_layer->SetContentsOpaque(true);
303 305
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 last_output_surface_id_(kUndefinedOutputSurfaceId), 340 last_output_surface_id_(kUndefinedOutputSurfaceId),
339 gesture_provider_(ui::GetGestureProviderConfig( 341 gesture_provider_(ui::GetGestureProviderConfig(
340 ui::GestureProviderConfigType::CURRENT_PLATFORM), 342 ui::GestureProviderConfigType::CURRENT_PLATFORM),
341 this), 343 this),
342 stylus_text_selector_(this), 344 stylus_text_selector_(this),
343 using_browser_compositor_(CompositorImpl::IsInitialized()), 345 using_browser_compositor_(CompositorImpl::IsInitialized()),
344 frame_evictor_(new DelegatedFrameEvictor(this)), 346 frame_evictor_(new DelegatedFrameEvictor(this)),
345 locks_on_frame_count_(0), 347 locks_on_frame_count_(0),
346 observing_root_window_(false), 348 observing_root_window_(false),
347 weak_ptr_factory_(this) { 349 weak_ptr_factory_(this) {
348 id_allocator_.reset( 350 id_allocator_.reset(new cc::SurfaceIdAllocator(
no sievers 2016/08/02 20:44:34 This can probably all be behind |using_browser_com
Khushal 2016/08/02 22:22:16 Done.
349 new cc::SurfaceIdAllocator(CompositorImpl::AllocateSurfaceClientId())); 351 ui::ContextProviderFactory::GetInstance()->AllocateSurfaceClientId()));
350 CompositorImpl::GetSurfaceManager()->RegisterSurfaceClientId( 352 ui::ContextProviderFactory::GetInstance()
351 id_allocator_->client_id()); 353 ->GetSurfaceManager()
354 ->RegisterSurfaceClientId(id_allocator_->client_id());
352 host_->SetView(this); 355 host_->SetView(this);
353 SetContentViewCore(content_view_core); 356 SetContentViewCore(content_view_core);
354 } 357 }
355 358
356 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 359 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
357 if (content_view_core_) 360 if (content_view_core_)
358 content_view_core_->RemoveObserver(this); 361 content_view_core_->RemoveObserver(this);
359 SetContentViewCore(NULL); 362 SetContentViewCore(NULL);
360 DCHECK(ack_callbacks_.empty()); 363 DCHECK(ack_callbacks_.empty());
361 DCHECK(!surface_factory_); 364 DCHECK(!surface_factory_);
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 host_->ViewDestroyed(); 794 host_->ViewDestroyed();
792 RemoveLayers(); 795 RemoveLayers();
793 SetContentViewCore(NULL); 796 SetContentViewCore(NULL);
794 797
795 if (!surface_id_.is_null()) { 798 if (!surface_id_.is_null()) {
796 DCHECK(surface_factory_.get()); 799 DCHECK(surface_factory_.get());
797 surface_factory_->Destroy(surface_id_); 800 surface_factory_->Destroy(surface_id_);
798 surface_id_ = cc::SurfaceId(); 801 surface_id_ = cc::SurfaceId();
799 } 802 }
800 surface_factory_.reset(); 803 surface_factory_.reset();
801 CompositorImpl::GetSurfaceManager()->InvalidateSurfaceClientId( 804 ui::ContextProviderFactory::GetInstance()
802 id_allocator_->client_id()); 805 ->GetSurfaceManager()
806 ->InvalidateSurfaceClientId(id_allocator_->client_id());
803 807
804 // The RenderWidgetHost's destruction led here, so don't call it. 808 // The RenderWidgetHost's destruction led here, so don't call it.
805 host_ = NULL; 809 host_ = NULL;
806 810
807 delete this; 811 delete this;
808 } 812 }
809 813
810 void RenderWidgetHostViewAndroid::SetTooltipText( 814 void RenderWidgetHostViewAndroid::SetTooltipText(
811 const base::string16& tooltip_text) { 815 const base::string16& tooltip_text) {
812 // Tooltips don't makes sense on Android. 816 // Tooltips don't makes sense on Android.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 surface_factory_.reset(); 973 surface_factory_.reset();
970 if (!surface_returned_resources_.empty()) 974 if (!surface_returned_resources_.empty())
971 SendReclaimCompositorResources(last_output_surface_id_, 975 SendReclaimCompositorResources(last_output_surface_id_,
972 false /* is_swap_ack */); 976 false /* is_swap_ack */);
973 977
974 last_output_surface_id_ = output_surface_id; 978 last_output_surface_id_ = output_surface_id;
975 } 979 }
976 980
977 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( 981 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
978 cc::CompositorFrame frame) { 982 cc::CompositorFrame frame) {
979 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); 983 cc::SurfaceManager* manager =
984 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
980 if (!surface_factory_) { 985 if (!surface_factory_) {
981 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); 986 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this));
982 } 987 }
983 if (surface_id_.is_null() || 988 if (surface_id_.is_null() ||
984 texture_size_in_layer_ != current_surface_size_ || 989 texture_size_in_layer_ != current_surface_size_ ||
985 location_bar_content_translation_ != 990 location_bar_content_translation_ !=
986 frame.metadata.location_bar_content_translation || 991 frame.metadata.location_bar_content_translation ||
987 current_viewport_selection_ != frame.metadata.selection) { 992 current_viewport_selection_ != frame.metadata.selection) {
988 RemoveLayers(); 993 RemoveLayers();
989 if (!surface_id_.is_null()) 994 if (!surface_id_.is_null())
(...skipping 16 matching lines...) Expand all
1006 weak_ptr_factory_.GetWeakPtr()); 1011 weak_ptr_factory_.GetWeakPtr());
1007 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 1012 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
1008 ack_callback); 1013 ack_callback);
1009 } 1014 }
1010 1015
1011 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( 1016 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
1012 uint32_t output_surface_id, 1017 uint32_t output_surface_id,
1013 cc::CompositorFrame frame) { 1018 cc::CompositorFrame frame) {
1014 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1019 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1015 DCHECK(frame.delegated_frame_data); 1020 DCHECK(frame.delegated_frame_data);
1016 DCHECK(CompositorImpl::GetSurfaceManager());
1017 1021
1018 if (locks_on_frame_count_ > 0) { 1022 if (locks_on_frame_count_ > 0) {
1019 DCHECK(HasValidFrame()); 1023 DCHECK(HasValidFrame());
1020 RetainFrame(output_surface_id, std::move(frame)); 1024 RetainFrame(output_surface_id, std::move(frame));
1021 return; 1025 return;
1022 } 1026 }
1023 1027
1024 DCHECK(!frame.delegated_frame_data->render_pass_list.empty()); 1028 DCHECK(!frame.delegated_frame_data->render_pass_list.empty());
1025 1029
1026 cc::RenderPass* root_pass = 1030 cc::RenderPass* root_pass =
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 case ui::MotionEvent::ACTION_UP: 1988 case ui::MotionEvent::ACTION_UP:
1985 case ui::MotionEvent::ACTION_POINTER_UP: 1989 case ui::MotionEvent::ACTION_POINTER_UP:
1986 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 1990 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1987 delta.InMicroseconds(), 1, 1000000, 50); 1991 delta.InMicroseconds(), 1, 1000000, 50);
1988 default: 1992 default:
1989 return; 1993 return;
1990 } 1994 }
1991 } 1995 }
1992 1996
1993 } // namespace content 1997 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698