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

Side by Side Diff: content/renderer/render_widget.cc

Issue 23694031: Fix race conditions in window snapshot code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added screenshot sync test to telemetry unittests, updated cc unittest Created 7 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 | Annotate | Revision Log
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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 364
365 bool RenderWidget::UsingSynchronousRendererCompositor() const { 365 bool RenderWidget::UsingSynchronousRendererCompositor() const {
366 #if defined(OS_ANDROID) 366 #if defined(OS_ANDROID)
367 return SynchronousCompositorFactory::GetInstance() != NULL; 367 return SynchronousCompositorFactory::GetInstance() != NULL;
368 #else 368 #else
369 return false; 369 return false;
370 #endif 370 #endif
371 } 371 }
372 372
373 void RenderWidget::ScheduleCompositeWithForcedRedraw() {
374 ScheduleCompositeImpl(true);
375 }
376
377 void RenderWidget::ScheduleCompositeImpl(bool force_redraw) {
378 if (compositor_ && force_redraw) {
jamesr 2013/10/02 00:06:41 why don't you move this code into ScheduleComposit
379 // Regardless of whether threaded compositing is enabled, always
380 // use this mechanism to force the compositor to redraw. However,
381 // the invalidation code path below is still needed for the
382 // non-threaded case.
383 compositor_->SetNeedsForcedRedraw();
384 }
385
386 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() &&
387 compositor_) {
388 if (!force_redraw) {
389 compositor_->setNeedsRedraw();
390 }
391 } else {
392 // TODO(nduca): replace with something a little less hacky. The reason this
393 // hack is still used is because the Invalidate-DoDeferredUpdate loop
394 // contains a lot of host-renderer synchronization logic that is still
395 // important for the accelerated compositing case. The option of simply
396 // duplicating all that code is less desirable than "faking out" the
397 // invalidation path using a magical damage rect.
398 didInvalidateRect(WebRect(0, 0, 1, 1));
399 }
400 }
401
373 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 402 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
374 bool handled = true; 403 bool handled = true;
375 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 404 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
376 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 405 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
377 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 406 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
378 OnCursorVisibilityChange) 407 OnCursorVisibilityChange)
379 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 408 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
380 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 409 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
381 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 410 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
382 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) 411 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 params.scroll_offset = GetScrollOffset(); 1694 params.scroll_offset = GetScrollOffset();
1666 params.needs_ack = false; 1695 params.needs_ack = false;
1667 params.scale_factor = device_scale_factor_; 1696 params.scale_factor = device_scale_factor_;
1668 1697
1669 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); 1698 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1670 next_paint_flags_ = 0; 1699 next_paint_flags_ = 0;
1671 need_update_rect_for_auto_resize_ = false; 1700 need_update_rect_for_auto_resize_ = false;
1672 } 1701 }
1673 1702
1674 void RenderWidget::scheduleComposite() { 1703 void RenderWidget::scheduleComposite() {
1675 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && 1704 ScheduleCompositeImpl(false);
1676 compositor_) {
1677 compositor_->setNeedsRedraw();
1678 } else {
1679 // TODO(nduca): replace with something a little less hacky. The reason this
1680 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1681 // contains a lot of host-renderer synchronization logic that is still
1682 // important for the accelerated compositing case. The option of simply
1683 // duplicating all that code is less desirable than "faking out" the
1684 // invalidation path using a magical damage rect.
1685 didInvalidateRect(WebRect(0, 0, 1, 1));
1686 }
1687 } 1705 }
1688 1706
1689 void RenderWidget::scheduleAnimation() { 1707 void RenderWidget::scheduleAnimation() {
1690 if (animation_update_pending_) 1708 if (animation_update_pending_)
1691 return; 1709 return;
1692 1710
1693 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); 1711 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
1694 animation_update_pending_ = true; 1712 animation_update_pending_ = true;
1695 if (!animation_timer_.IsRunning()) { 1713 if (!animation_timer_.IsRunning()) {
1696 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, 1714 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 kDefaultCommandBufferSize, 2615 kDefaultCommandBufferSize,
2598 kDefaultStartTransferBufferSize, 2616 kDefaultStartTransferBufferSize,
2599 kDefaultMinTransferBufferSize, 2617 kDefaultMinTransferBufferSize,
2600 kDefaultMaxTransferBufferSize, 2618 kDefaultMaxTransferBufferSize,
2601 mapped_memory_reclaim_limit)) 2619 mapped_memory_reclaim_limit))
2602 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2620 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2603 return context.Pass(); 2621 return context.Pass();
2604 } 2622 }
2605 2623
2606 } // namespace content 2624 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698