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

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

Powered by Google App Engine
This is Rietveld 408576698