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

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

Issue 2694273002: Revert of Refactor ContentViewClient (4/6) (Closed)
Patch Set: Created 3 years, 10 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 gl_helper->CropScaleReadbackAndCleanMailbox( 394 gl_helper->CropScaleReadbackAndCleanMailbox(
395 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), 395 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(),
396 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, 396 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
397 base::Bind(&CopyFromCompositingSurfaceFinished, callback, 397 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
398 base::Passed(&release_callback), base::Passed(&bitmap), 398 base::Passed(&release_callback), base::Passed(&bitmap),
399 start_time, base::Passed(&bitmap_pixels_lock), readback_lock), 399 start_time, base::Passed(&bitmap_pixels_lock), readback_lock),
400 display_compositor::GLHelper::SCALER_QUALITY_GOOD); 400 display_compositor::GLHelper::SCALER_QUALITY_GOOD);
401 } 401 }
402 402
403 bool FloatEquals(float a, float b) {
404 return std::abs(a - b) < FLT_EPSILON;
405 }
406
407 } // namespace 403 } // namespace
408 404
409 void RenderWidgetHostViewAndroid::OnContextLost() { 405 void RenderWidgetHostViewAndroid::OnContextLost() {
410 std::unique_ptr<RenderWidgetHostIterator> widgets( 406 std::unique_ptr<RenderWidgetHostIterator> widgets(
411 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 407 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
412 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 408 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
413 if (widget->GetView()) { 409 if (widget->GetView()) {
414 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) 410 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView())
415 ->OnLostResources(); 411 ->OnLostResources();
416 } 412 }
(...skipping 15 matching lines...) Expand all
432 cached_background_color_(SK_ColorWHITE), 428 cached_background_color_(SK_ColorWHITE),
433 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), 429 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId),
434 gesture_provider_(ui::GetGestureProviderConfig( 430 gesture_provider_(ui::GetGestureProviderConfig(
435 ui::GestureProviderConfigType::CURRENT_PLATFORM), 431 ui::GestureProviderConfigType::CURRENT_PLATFORM),
436 this), 432 this),
437 stylus_text_selector_(this), 433 stylus_text_selector_(this),
438 using_browser_compositor_(CompositorImpl::IsInitialized()), 434 using_browser_compositor_(CompositorImpl::IsInitialized()),
439 synchronous_compositor_client_(nullptr), 435 synchronous_compositor_client_(nullptr),
440 frame_evictor_(new DelegatedFrameEvictor(this)), 436 frame_evictor_(new DelegatedFrameEvictor(this)),
441 observing_root_window_(false), 437 observing_root_window_(false),
442 prev_top_shown_pix_(0.f),
443 prev_bottom_shown_pix_(0.f),
444 weak_ptr_factory_(this) { 438 weak_ptr_factory_(this) {
445 // Set the layer which will hold the content layer for this view. The content 439 // Set the layer which will hold the content layer for this view. The content
446 // layer is managed by the DelegatedFrameHost. 440 // layer is managed by the DelegatedFrameHost.
447 view_.SetLayer(cc::Layer::Create()); 441 view_.SetLayer(cc::Layer::Create());
448 if (using_browser_compositor_) { 442 if (using_browser_compositor_) {
449 // This FrameSinkId must be unique with ContextProviderFactory's FrameSinkId 443 // This FrameSinkId must be unique with ContextProviderFactory's FrameSinkId
450 // allocation. 444 // allocation.
451 // TODO(crbug.com/685777): Centralize allocation in one place for easier 445 // TODO(crbug.com/685777): Centralize allocation in one place for easier
452 // maintenance. 446 // maintenance.
453 cc::FrameSinkId frame_sink_id = cc::FrameSinkId( 447 cc::FrameSinkId frame_sink_id = cc::FrameSinkId(
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 783
790 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { 784 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
791 if (cached_background_color_ == color) 785 if (cached_background_color_ == color)
792 return; 786 return;
793 787
794 cached_background_color_ = color; 788 cached_background_color_ = color;
795 789
796 if (delegated_frame_host_) 790 if (delegated_frame_host_)
797 delegated_frame_host_->UpdateBackgroundColor(color); 791 delegated_frame_host_->UpdateBackgroundColor(color);
798 792
799 view_.OnBackgroundColorChanged(color); 793 if (content_view_core_)
794 content_view_core_->OnBackgroundColorChanged(color);
800 } 795 }
801 796
802 void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) { 797 void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) {
803 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SetNeedsBeginFrames", 798 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SetNeedsBeginFrames",
804 "needs_begin_frames", needs_begin_frames); 799 "needs_begin_frames", needs_begin_frames);
805 if (needs_begin_frames) 800 if (needs_begin_frames)
806 AddBeginFrameRequest(PERSISTENT_BEGIN_FRAME); 801 AddBeginFrameRequest(PERSISTENT_BEGIN_FRAME);
807 else 802 else
808 ClearBeginFrameRequest(PERSISTENT_BEGIN_FRAME); 803 ClearBeginFrameRequest(PERSISTENT_BEGIN_FRAME);
809 } 804 }
810 805
811 void RenderWidgetHostViewAndroid::OnStartContentIntent( 806 void RenderWidgetHostViewAndroid::OnStartContentIntent(
812 const GURL& content_url, bool is_main_frame) { 807 const GURL& content_url, bool is_main_frame) {
813 view_.StartContentIntent(content_url, is_main_frame); 808 if (content_view_core_)
809 content_view_core_->StartContentIntent(content_url, is_main_frame);
814 } 810 }
815 811
816 bool RenderWidgetHostViewAndroid::OnTouchEvent( 812 bool RenderWidgetHostViewAndroid::OnTouchEvent(
817 const ui::MotionEvent& event) { 813 const ui::MotionEvent& event) {
818 if (!host_) 814 if (!host_)
819 return false; 815 return false;
820 816
821 ComputeEventLatencyOSTouchHistograms(event); 817 ComputeEventLatencyOSTouchHistograms(event);
822 818
823 // If a browser-based widget consumes the touch event, it's critical that 819 // If a browser-based widget consumes the touch event, it's critical that
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 selection_controller_->OnViewportChanged(viewport_rect); 1267 selection_controller_->OnViewportChanged(viewport_rect);
1272 } 1268 }
1273 1269
1274 UpdateBackgroundColor(is_transparent ? SK_ColorTRANSPARENT 1270 UpdateBackgroundColor(is_transparent ? SK_ColorTRANSPARENT
1275 : frame_metadata.root_background_color); 1271 : frame_metadata.root_background_color);
1276 1272
1277 view_.set_content_offset(gfx::Vector2dF(0.0f, 1273 view_.set_content_offset(gfx::Vector2dF(0.0f,
1278 frame_metadata.top_controls_height * 1274 frame_metadata.top_controls_height *
1279 frame_metadata.top_controls_shown_ratio)); 1275 frame_metadata.top_controls_shown_ratio));
1280 1276
1281 float dip_scale = ui::GetScaleFactorForNativeView(GetNativeView());
1282 float top_controls_pix = frame_metadata.top_controls_height * dip_scale;
1283 float top_shown_pix = top_controls_pix
1284 * frame_metadata.top_controls_shown_ratio;
1285 bool top_changed = !FloatEquals(top_shown_pix, prev_top_shown_pix_);
1286
1287 float bottom_controls_pix = frame_metadata.bottom_controls_height * dip_scale;
1288 float bottom_shown_pix = bottom_controls_pix
1289 * frame_metadata.bottom_controls_shown_ratio;
1290 bool bottom_changed = !FloatEquals(bottom_shown_pix, prev_bottom_shown_pix_);
1291
1292 if (top_changed) {
1293 float translate = top_shown_pix - top_controls_pix;
1294 view_.OnTopControlsChanged(translate, top_shown_pix);
1295 prev_top_shown_pix_ = top_shown_pix;
1296 }
1297 if (bottom_changed) {
1298 float translate = bottom_controls_pix - bottom_shown_pix;
1299 view_.OnBottomControlsChanged(translate, bottom_shown_pix);
1300 prev_bottom_shown_pix_ = bottom_shown_pix;
1301 }
1302
1303 // All offsets and sizes are in CSS pixels. 1277 // All offsets and sizes are in CSS pixels.
1304 content_view_core_->UpdateFrameInfo( 1278 content_view_core_->UpdateFrameInfo(
1305 frame_metadata.root_scroll_offset, 1279 frame_metadata.root_scroll_offset,
1306 frame_metadata.page_scale_factor, 1280 frame_metadata.page_scale_factor,
1307 gfx::Vector2dF(frame_metadata.min_page_scale_factor, 1281 gfx::Vector2dF(frame_metadata.min_page_scale_factor,
1308 frame_metadata.max_page_scale_factor), 1282 frame_metadata.max_page_scale_factor),
1309 frame_metadata.root_layer_size, 1283 frame_metadata.root_layer_size,
1310 frame_metadata.scrollable_viewport_size, 1284 frame_metadata.scrollable_viewport_size,
1311 frame_metadata.top_controls_height, 1285 frame_metadata.top_controls_height,
1312 frame_metadata.top_controls_shown_ratio, 1286 frame_metadata.top_controls_shown_ratio,
1287 frame_metadata.bottom_controls_height,
1288 frame_metadata.bottom_controls_shown_ratio,
1313 is_mobile_optimized, 1289 is_mobile_optimized,
1314 frame_metadata.selection.start); 1290 frame_metadata.selection.start);
1315 } 1291 }
1316 1292
1317 void RenderWidgetHostViewAndroid::ShowInternal() { 1293 void RenderWidgetHostViewAndroid::ShowInternal() {
1318 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_; 1294 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_;
1319 if (!show) 1295 if (!show)
1320 return; 1296 return;
1321 1297
1322 if (!host_ || !host_->is_hidden()) 1298 if (!host_ || !host_->is_hidden())
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 1974 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
1999 if (!compositor) 1975 if (!compositor)
2000 return; 1976 return;
2001 1977
2002 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 1978 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2003 overscroll_refresh_handler, compositor, 1979 overscroll_refresh_handler, compositor,
2004 ui::GetScaleFactorForNativeView(GetNativeView())); 1980 ui::GetScaleFactorForNativeView(GetNativeView()));
2005 } 1981 }
2006 1982
2007 } // namespace content 1983 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698