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

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: format for realz 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 if (using_browser_compositor_) {
349 new cc::SurfaceIdAllocator(CompositorImpl::AllocateSurfaceClientId())); 351 id_allocator_.reset(new cc::SurfaceIdAllocator(
350 CompositorImpl::GetSurfaceManager()->RegisterSurfaceClientId( 352 ui::ContextProviderFactory::GetInstance()->AllocateSurfaceClientId()));
351 id_allocator_->client_id()); 353 ui::ContextProviderFactory::GetInstance()
354 ->GetSurfaceManager()
355 ->RegisterSurfaceClientId(id_allocator_->client_id());
356 }
357
352 host_->SetView(this); 358 host_->SetView(this);
353 SetContentViewCore(content_view_core); 359 SetContentViewCore(content_view_core);
354 } 360 }
355 361
356 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 362 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
357 if (content_view_core_) 363 if (content_view_core_)
358 content_view_core_->RemoveObserver(this); 364 content_view_core_->RemoveObserver(this);
359 SetContentViewCore(NULL); 365 SetContentViewCore(NULL);
360 DCHECK(ack_callbacks_.empty()); 366 DCHECK(ack_callbacks_.empty());
361 DCHECK(!surface_factory_); 367 DCHECK(!surface_factory_);
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 host_->ViewDestroyed(); 797 host_->ViewDestroyed();
792 RemoveLayers(); 798 RemoveLayers();
793 SetContentViewCore(NULL); 799 SetContentViewCore(NULL);
794 800
795 if (!surface_id_.is_null()) { 801 if (!surface_id_.is_null()) {
796 DCHECK(surface_factory_.get()); 802 DCHECK(surface_factory_.get());
797 surface_factory_->Destroy(surface_id_); 803 surface_factory_->Destroy(surface_id_);
798 surface_id_ = cc::SurfaceId(); 804 surface_id_ = cc::SurfaceId();
799 } 805 }
800 surface_factory_.reset(); 806 surface_factory_.reset();
801 CompositorImpl::GetSurfaceManager()->InvalidateSurfaceClientId( 807 ui::ContextProviderFactory::GetInstance()
no sievers 2016/08/02 22:47:36 this needs an if-check whether the id_allocator_ e
Khushal 2016/08/02 23:31:54 Done. In my next change I'm moving all the surface
no sievers 2016/08/03 23:13:25 Yes, I think WebView could possibly not instantiat
802 id_allocator_->client_id()); 808 ->GetSurfaceManager()
809 ->InvalidateSurfaceClientId(id_allocator_->client_id());
803 810
804 // The RenderWidgetHost's destruction led here, so don't call it. 811 // The RenderWidgetHost's destruction led here, so don't call it.
805 host_ = NULL; 812 host_ = NULL;
806 813
807 delete this; 814 delete this;
808 } 815 }
809 816
810 void RenderWidgetHostViewAndroid::SetTooltipText( 817 void RenderWidgetHostViewAndroid::SetTooltipText(
811 const base::string16& tooltip_text) { 818 const base::string16& tooltip_text) {
812 // Tooltips don't makes sense on Android. 819 // Tooltips don't makes sense on Android.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 surface_factory_.reset(); 976 surface_factory_.reset();
970 if (!surface_returned_resources_.empty()) 977 if (!surface_returned_resources_.empty())
971 SendReclaimCompositorResources(last_output_surface_id_, 978 SendReclaimCompositorResources(last_output_surface_id_,
972 false /* is_swap_ack */); 979 false /* is_swap_ack */);
973 980
974 last_output_surface_id_ = output_surface_id; 981 last_output_surface_id_ = output_surface_id;
975 } 982 }
976 983
977 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( 984 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
978 cc::CompositorFrame frame) { 985 cc::CompositorFrame frame) {
979 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); 986 cc::SurfaceManager* manager =
987 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
980 if (!surface_factory_) { 988 if (!surface_factory_) {
981 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); 989 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this));
982 } 990 }
983 if (surface_id_.is_null() || 991 if (surface_id_.is_null() ||
984 texture_size_in_layer_ != current_surface_size_ || 992 texture_size_in_layer_ != current_surface_size_ ||
985 location_bar_content_translation_ != 993 location_bar_content_translation_ !=
986 frame.metadata.location_bar_content_translation || 994 frame.metadata.location_bar_content_translation ||
987 current_viewport_selection_ != frame.metadata.selection) { 995 current_viewport_selection_ != frame.metadata.selection) {
988 RemoveLayers(); 996 RemoveLayers();
989 if (!surface_id_.is_null()) 997 if (!surface_id_.is_null())
(...skipping 16 matching lines...) Expand all
1006 weak_ptr_factory_.GetWeakPtr()); 1014 weak_ptr_factory_.GetWeakPtr());
1007 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 1015 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
1008 ack_callback); 1016 ack_callback);
1009 } 1017 }
1010 1018
1011 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( 1019 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
1012 uint32_t output_surface_id, 1020 uint32_t output_surface_id,
1013 cc::CompositorFrame frame) { 1021 cc::CompositorFrame frame) {
1014 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1022 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1015 DCHECK(frame.delegated_frame_data); 1023 DCHECK(frame.delegated_frame_data);
1016 DCHECK(CompositorImpl::GetSurfaceManager());
1017 1024
1018 if (locks_on_frame_count_ > 0) { 1025 if (locks_on_frame_count_ > 0) {
1019 DCHECK(HasValidFrame()); 1026 DCHECK(HasValidFrame());
1020 RetainFrame(output_surface_id, std::move(frame)); 1027 RetainFrame(output_surface_id, std::move(frame));
1021 return; 1028 return;
1022 } 1029 }
1023 1030
1024 DCHECK(!frame.delegated_frame_data->render_pass_list.empty()); 1031 DCHECK(!frame.delegated_frame_data->render_pass_list.empty());
1025 1032
1026 cc::RenderPass* root_pass = 1033 cc::RenderPass* root_pass =
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 case ui::MotionEvent::ACTION_UP: 1991 case ui::MotionEvent::ACTION_UP:
1985 case ui::MotionEvent::ACTION_POINTER_UP: 1992 case ui::MotionEvent::ACTION_POINTER_UP:
1986 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 1993 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1987 delta.InMicroseconds(), 1, 1000000, 50); 1994 delta.InMicroseconds(), 1, 1000000, 50);
1988 default: 1995 default:
1989 return; 1996 return;
1990 } 1997 }
1991 } 1998 }
1992 1999
1993 } // namespace content 2000 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698