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

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

Issue 1385543003: Have RenderWidgetHostViewAndroid own sync compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add dcheck Created 5 years, 2 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 is_showing_(!widget_host->is_hidden()), 321 is_showing_(!widget_host->is_hidden()),
322 content_view_core_(nullptr), 322 content_view_core_(nullptr),
323 content_view_core_window_android_(nullptr), 323 content_view_core_window_android_(nullptr),
324 ime_adapter_android_(this), 324 ime_adapter_android_(this),
325 cached_background_color_(SK_ColorWHITE), 325 cached_background_color_(SK_ColorWHITE),
326 last_output_surface_id_(kUndefinedOutputSurfaceId), 326 last_output_surface_id_(kUndefinedOutputSurfaceId),
327 gesture_provider_(ui::GetGestureProviderConfig( 327 gesture_provider_(ui::GetGestureProviderConfig(
328 ui::GestureProviderConfigType::CURRENT_PLATFORM), 328 ui::GestureProviderConfigType::CURRENT_PLATFORM),
329 this), 329 this),
330 stylus_text_selector_(this), 330 stylus_text_selector_(this),
331 using_browser_compositor_(CompositorImpl::IsInitialized()), 331 using_browser_compositor_(CompositorImpl::IsInitialized()),
no sievers 2015/10/07 00:31:51 Can we replace occurences of |using_browser_compos
boliu 2015/10/07 15:01:32 Done.
332 frame_evictor_(new DelegatedFrameEvictor(this)), 332 frame_evictor_(new DelegatedFrameEvictor(this)),
333 locks_on_frame_count_(0), 333 locks_on_frame_count_(0),
334 observing_root_window_(false), 334 observing_root_window_(false),
335 weak_ptr_factory_(this) { 335 weak_ptr_factory_(this) {
336 if (CompositorImpl::GetSurfaceManager()) 336 if (CompositorImpl::GetSurfaceManager())
337 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator(); 337 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator();
338 host_->SetView(this); 338 host_->SetView(this);
339 SetContentViewCore(content_view_core); 339 SetContentViewCore(content_view_core);
340 } 340 }
341 341
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, 1169 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck,
1170 weak_ptr_factory_.GetWeakPtr(), 1170 weak_ptr_factory_.GetWeakPtr(),
1171 last_frame_info_->output_surface_id); 1171 last_frame_info_->output_surface_id);
1172 1172
1173 ack_callbacks_.push(ack_callback); 1173 ack_callbacks_.push(ack_callback);
1174 } 1174 }
1175 1175
1176 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); 1176 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass()));
1177 } 1177 }
1178 1178
1179 SynchronousCompositorImpl*
1180 RenderWidgetHostViewAndroid::GetSynchronousCompositorImpl() {
1181 return sync_compositor_.get();
1182 }
1183
1179 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( 1184 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
1180 const cc::CompositorFrameMetadata& frame_metadata) { 1185 const cc::CompositorFrameMetadata& frame_metadata) {
1181 if (!content_view_core_) 1186 if (!content_view_core_)
1182 return; 1187 return;
1183 1188
1184 // This is a subset of OnSwapCompositorFrame() used in the synchronous 1189 // This is a subset of OnSwapCompositorFrame() used in the synchronous
1185 // compositor flow. 1190 // compositor flow.
1186 OnFrameMetadataUpdated(frame_metadata); 1191 OnFrameMetadataUpdated(frame_metadata);
1187 1192
1188 // DevTools ScreenCast support for Android WebView. 1193 // DevTools ScreenCast support for Android WebView.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 input_size_in_pixel = src_subrect_in_pixel.size(); 1279 input_size_in_pixel = src_subrect_in_pixel.size();
1275 1280
1276 gfx::Size output_size_in_pixel; 1281 gfx::Size output_size_in_pixel;
1277 if (dst_size_in_pixel.IsEmpty()) 1282 if (dst_size_in_pixel.IsEmpty())
1278 output_size_in_pixel = input_size_in_pixel; 1283 output_size_in_pixel = input_size_in_pixel;
1279 else 1284 else
1280 output_size_in_pixel = dst_size_in_pixel; 1285 output_size_in_pixel = dst_size_in_pixel;
1281 int output_width = output_size_in_pixel.width(); 1286 int output_width = output_size_in_pixel.width();
1282 int output_height = output_size_in_pixel.height(); 1287 int output_height = output_size_in_pixel.height();
1283 1288
1284 SynchronousCompositor* compositor = 1289 if (!sync_compositor_) {
no sievers 2015/10/07 00:31:51 Just DCHECK() here, the call site should be checki
boliu 2015/10/07 15:01:33 Done.
1285 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(),
1286 host_->GetRoutingID());
1287 if (!compositor) {
1288 callback.Run(SkBitmap(), READBACK_FAILED); 1290 callback.Run(SkBitmap(), READBACK_FAILED);
1289 return; 1291 return;
1290 } 1292 }
1291 1293
1292 SkBitmap bitmap; 1294 SkBitmap bitmap;
1293 bitmap.allocPixels(SkImageInfo::Make(output_width, 1295 bitmap.allocPixels(SkImageInfo::Make(output_width,
1294 output_height, 1296 output_height,
1295 color_type, 1297 color_type,
1296 kPremul_SkAlphaType)); 1298 kPremul_SkAlphaType));
1297 SkCanvas canvas(bitmap); 1299 SkCanvas canvas(bitmap);
1298 canvas.scale( 1300 canvas.scale(
1299 (float)output_width / (float)input_size_in_pixel.width(), 1301 (float)output_width / (float)input_size_in_pixel.width(),
1300 (float)output_height / (float)input_size_in_pixel.height()); 1302 (float)output_height / (float)input_size_in_pixel.height());
1301 compositor->DemandDrawSw(&canvas); 1303 sync_compositor_->DemandDrawSw(&canvas);
1302 callback.Run(bitmap, READBACK_SUCCESS); 1304 callback.Run(bitmap, READBACK_SUCCESS);
1303 } 1305 }
1304 1306
1305 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( 1307 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
1306 const cc::CompositorFrameMetadata& frame_metadata) { 1308 const cc::CompositorFrameMetadata& frame_metadata) {
1307 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); 1309 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata);
1308 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); 1310 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
1309 1311
1310 if (!content_view_core_) 1312 if (!content_view_core_)
1311 return; 1313 return;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 1477
1476 if (using_browser_compositor_) { 1478 if (using_browser_compositor_) {
1477 // TODO(brianderson): Replace this hardcoded deadline after Android 1479 // TODO(brianderson): Replace this hardcoded deadline after Android
1478 // switches to Surfaces and the Browser's commit isn't in the critcal path. 1480 // switches to Surfaces and the Browser's commit isn't in the critcal path.
1479 base::TimeTicks deadline = frame_time + (vsync_period * 0.6); 1481 base::TimeTicks deadline = frame_time + (vsync_period * 0.6);
1480 1482
1481 host_->Send(new ViewMsg_BeginFrame( 1483 host_->Send(new ViewMsg_BeginFrame(
1482 host_->GetRoutingID(), 1484 host_->GetRoutingID(),
1483 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, 1485 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
1484 vsync_period, cc::BeginFrameArgs::NORMAL))); 1486 vsync_period, cc::BeginFrameArgs::NORMAL)));
1485 } else { 1487 } else if (sync_compositor_.get()) {
1486 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID( 1488 // The synchronous compositor synchronously does it's work in this call.
1487 host_->GetProcess()->GetID(), host_->GetRoutingID()); 1489 // It does not use a deadline.
1488 if (compositor) { 1490 sync_compositor_->BeginFrame(cc::BeginFrameArgs::Create(
1489 // The synchronous compositor synchronously does it's work in this call. 1491 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period,
1490 // It does not use a deadline. 1492 cc::BeginFrameArgs::NORMAL));
1491 compositor->BeginFrame(cc::BeginFrameArgs::Create(
1492 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period,
1493 cc::BeginFrameArgs::NORMAL));
1494 }
1495 } 1493 }
1496 } 1494 }
1497 1495
1498 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { 1496 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
1499 bool needs_animate = false; 1497 bool needs_animate = false;
1500 if (overscroll_controller_) { 1498 if (overscroll_controller_) {
1501 needs_animate |= overscroll_controller_->Animate( 1499 needs_animate |= overscroll_controller_->Animate(
1502 frame_time, content_view_core_->GetLayer().get()); 1500 frame_time, content_view_core_->GetLayer().get());
1503 } 1501 }
1504 if (selection_controller_) 1502 if (selection_controller_)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1600
1603 if (input_event.type == blink::WebInputEvent::GestureTapDown || 1601 if (input_event.type == blink::WebInputEvent::GestureTapDown ||
1604 input_event.type == blink::WebInputEvent::TouchStart) { 1602 input_event.type == blink::WebInputEvent::TouchStart) {
1605 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance(); 1603 GpuDataManagerImpl* gpu_data = GpuDataManagerImpl::GetInstance();
1606 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); 1604 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
1607 if (shim && gpu_data && 1605 if (shim && gpu_data &&
1608 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING)) 1606 gpu_data->IsDriverBugWorkaroundActive(gpu::WAKE_UP_GPU_BEFORE_DRAWING))
1609 shim->Send(new GpuMsg_WakeUpGpu); 1607 shim->Send(new GpuMsg_WakeUpGpu);
1610 } 1608 }
1611 1609
1612 SynchronousCompositorImpl* compositor = 1610 if (sync_compositor_.get())
1613 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), 1611 return sync_compositor_->HandleInputEvent(input_event);
1614 host_->GetRoutingID());
1615 if (compositor)
1616 return compositor->HandleInputEvent(input_event);
1617 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1612 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1618 } 1613 }
1619 1614
1620 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { 1615 void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() {
1621 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); 1616 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput");
1622 RequestVSyncUpdate(FLUSH_INPUT); 1617 RequestVSyncUpdate(FLUSH_INPUT);
1623 } 1618 }
1624 1619
1625 BrowserAccessibilityManager* 1620 BrowserAccessibilityManager*
1626 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager( 1621 RenderWidgetHostViewAndroid::CreateBrowserAccessibilityManager(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 } 1733 }
1739 1734
1740 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() { 1735 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() {
1741 if (id_allocator_) 1736 if (id_allocator_)
1742 return id_allocator_->id_namespace(); 1737 return id_allocator_->id_namespace();
1743 return 0; 1738 return 0;
1744 } 1739 }
1745 1740
1746 void RenderWidgetHostViewAndroid::SetContentViewCore( 1741 void RenderWidgetHostViewAndroid::SetContentViewCore(
1747 ContentViewCoreImpl* content_view_core) { 1742 ContentViewCoreImpl* content_view_core) {
1743 // Android webview does not currently support switching ContentViewCoreImpl.
no sievers 2015/10/07 00:31:51 Hmm, I don't think this should ever happen, but ma
boliu 2015/10/07 15:01:33 So you are in my camp :) I don't really understan
1744 DCHECK_IMPLIES(!using_browser_compositor_,
1745 !content_view_core || !content_view_core_);
1748 RemoveLayers(); 1746 RemoveLayers();
1749 StopObservingRootWindow(); 1747 StopObservingRootWindow();
1750 1748
1751 bool resize = false; 1749 bool resize = false;
1752 if (content_view_core != content_view_core_) { 1750 if (content_view_core != content_view_core_) {
1753 overscroll_controller_.reset(); 1751 overscroll_controller_.reset();
1754 selection_controller_.reset(); 1752 selection_controller_.reset();
1755 ReleaseLocksOnSurface(); 1753 ReleaseLocksOnSurface();
1756 resize = true; 1754 resize = true;
1757 } 1755 }
1758 1756
1759 content_view_core_ = content_view_core; 1757 content_view_core_ = content_view_core;
1760 content_view_core_window_android_ = 1758 content_view_core_window_android_ =
1761 content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; 1759 content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
1762 DCHECK_EQ(!!content_view_core_, !!content_view_core_window_android_); 1760 DCHECK_EQ(!!content_view_core_, !!content_view_core_window_android_);
1763 1761
1764 BrowserAccessibilityManager* manager = NULL; 1762 BrowserAccessibilityManager* manager = NULL;
1765 if (host_) 1763 if (host_)
1766 manager = host_->GetRootBrowserAccessibilityManager(); 1764 manager = host_->GetRootBrowserAccessibilityManager();
1767 if (manager) { 1765 if (manager) {
1768 base::android::ScopedJavaLocalRef<jobject> obj; 1766 base::android::ScopedJavaLocalRef<jobject> obj;
1769 if (content_view_core_) 1767 if (content_view_core_)
1770 obj = content_view_core_->GetJavaObject(); 1768 obj = content_view_core_->GetJavaObject();
1771 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); 1769 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj);
1772 } 1770 }
1773 1771
1774 AttachLayers(); 1772 AttachLayers();
1775 1773 if (!content_view_core_) {
1776 if (!content_view_core_) 1774 sync_compositor_.reset();
1777 return; 1775 return;
1776 }
1778 1777
1779 if (is_showing_) 1778 if (is_showing_)
1780 StartObservingRootWindow(); 1779 StartObservingRootWindow();
1781 1780
1782 if (resize) 1781 if (resize)
1783 WasResized(); 1782 WasResized();
1784 1783
1785 if (!selection_controller_) 1784 if (!selection_controller_)
1786 selection_controller_ = CreateSelectionController(this, content_view_core_); 1785 selection_controller_ = CreateSelectionController(this, content_view_core_);
1787 1786
1788 if (!overscroll_controller_ && 1787 if (!overscroll_controller_ &&
1789 content_view_core_window_android_->GetCompositor()) { 1788 content_view_core_window_android_->GetCompositor()) {
1790 overscroll_controller_ = CreateOverscrollController(content_view_core_); 1789 overscroll_controller_ = CreateOverscrollController(content_view_core_);
1791 } 1790 }
1791
1792 if (!using_browser_compositor_ && !sync_compositor_.get()) {
1793 sync_compositor_ = SynchronousCompositorImpl::Create(
1794 this, content_view_core_->GetWebContents());
1795 }
1792 } 1796 }
1793 1797
1794 void RenderWidgetHostViewAndroid::RunAckCallbacks( 1798 void RenderWidgetHostViewAndroid::RunAckCallbacks(
1795 cc::SurfaceDrawStatus status) { 1799 cc::SurfaceDrawStatus status) {
1796 while (!ack_callbacks_.empty()) { 1800 while (!ack_callbacks_.empty()) {
1797 ack_callbacks_.front().Run(); 1801 ack_callbacks_.front().Run();
1798 ack_callbacks_.pop(); 1802 ack_callbacks_.pop();
1799 } 1803 }
1800 } 1804 }
1801 1805
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 results->orientationAngle = display.RotationAsDegree(); 2016 results->orientationAngle = display.RotationAsDegree();
2013 results->orientationType = 2017 results->orientationType =
2014 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2018 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2015 gfx::DeviceDisplayInfo info; 2019 gfx::DeviceDisplayInfo info;
2016 results->depth = info.GetBitsPerPixel(); 2020 results->depth = info.GetBitsPerPixel();
2017 results->depthPerComponent = info.GetBitsPerComponent(); 2021 results->depthPerComponent = info.GetBitsPerComponent();
2018 results->isMonochrome = (results->depthPerComponent == 0); 2022 results->isMonochrome = (results->depthPerComponent == 0);
2019 } 2023 }
2020 2024
2021 } // namespace content 2025 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698