Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 // request to the renderer to paint the view if required. | 798 // request to the renderer to paint the view if required. |
| 799 if (!repaint_ack_pending_ && !resize_ack_pending_) { | 799 if (!repaint_ack_pending_ && !resize_ack_pending_) { |
| 800 repaint_start_time_ = TimeTicks::Now(); | 800 repaint_start_time_ = TimeTicks::Now(); |
| 801 repaint_ack_pending_ = true; | 801 repaint_ack_pending_ = true; |
| 802 TRACE_EVENT_ASYNC_BEGIN0( | 802 TRACE_EVENT_ASYNC_BEGIN0( |
| 803 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 803 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
| 804 Send(new ViewMsg_Repaint(routing_id_, view_size)); | 804 Send(new ViewMsg_Repaint(routing_id_, view_size)); |
| 805 } | 805 } |
| 806 | 806 |
| 807 TimeDelta max_delay = TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); | 807 TimeDelta max_delay = TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); |
| 808 TimeTicks end_time = TimeTicks::Now() + max_delay; | 808 TimeTicks start_time = TimeTicks::Now(); |
| 809 TimeTicks end_time = start_time + max_delay; | |
| 809 do { | 810 do { |
| 810 TRACE_EVENT0("renderer_host", "WaitForSurface::WaitForUpdate"); | 811 TRACE_EVENT0("renderer_host", "WaitForSurface::WaitForUpdate"); |
| 811 | 812 |
| 812 // When we have asked the RenderWidget to resize, and we are still waiting | 813 // When we have asked the RenderWidget to resize, and we are still waiting |
| 813 // on a response, block for a little while to see if we can't get a response | 814 // on a response, block for a little while to see if we can't get a response |
| 814 // before returning the old (incorrectly sized) backing store. | 815 // before returning the old (incorrectly sized) backing store. |
| 815 IPC::Message msg; | 816 IPC::Message msg; |
| 816 if (RenderWidgetResizeHelper::Get()->WaitForSingleTaskToRun(max_delay)) { | 817 if (RenderWidgetResizeHelper::Get()->WaitForSingleTaskToRun(max_delay)) { |
| 817 | 818 |
| 818 // For auto-resized views, current_size_ determines the view_size and it | 819 // For auto-resized views, current_size_ determines the view_size and it |
| 819 // may have changed during the handling of an UpdateRect message. | 820 // may have changed during the handling of an UpdateRect message. |
| 820 if (auto_resize_enabled_) | 821 if (auto_resize_enabled_) |
| 821 view_size = current_size_; | 822 view_size = current_size_; |
| 822 | 823 |
| 823 // Break now if we got a backing store or accelerated surface of the | 824 // Break now if we got a backing store or accelerated surface of the |
| 824 // correct size. | 825 // correct size. |
| 825 if (view_->HasAcceleratedSurface(view_size)) | 826 if (view_->HasAcceleratedSurface(view_size)) |
| 826 return; | 827 return; |
| 827 } else { | 828 } else { |
| 828 TRACE_EVENT0("renderer_host", "WaitForSurface::Timeout"); | 829 TRACE_EVENT0("renderer_host", "WaitForSurface::Timeout"); |
| 829 break; | 830 break; |
| 830 } | 831 } |
| 831 | 832 |
| 832 // Loop if we still have time left and haven't gotten a properly sized | 833 // Loop if we still have time left and haven't gotten a properly sized |
| 833 // BackingStore yet. This is necessary to support the GPU path which | 834 // BackingStore yet. This is necessary to support the GPU path which |
| 834 // typically has multiple frames pipelined -- we may need to skip one or two | 835 // typically has multiple frames pipelined -- we may need to skip one or two |
| 835 // BackingStore messages to get to the latest. | 836 // BackingStore messages to get to the latest. |
| 836 max_delay = end_time - TimeTicks::Now(); | 837 max_delay = end_time - TimeTicks::Now(); |
| 837 } while (max_delay > TimeDelta::FromSeconds(0)); | 838 } while (max_delay > TimeDelta::FromSeconds(0)); |
| 839 | |
|
ccameron
2015/01/06 02:14:21
It should be possible to combine the base::TimeTic
erikchen
2015/01/06 03:23:16
It saves a call to TimeTicks::Now(), plus the orig
| |
| 840 TimeDelta wait_duration = TimeTicks::Now() - start_time; | |
| 841 UMA_HISTOGRAM_CUSTOM_TIMES("OSX.RendererHost.SurfaceWaitTime", wait_duration, | |
| 842 TimeDelta::FromMilliseconds(1), | |
| 843 TimeDelta::FromMilliseconds(200), 50); | |
| 838 } | 844 } |
| 839 #endif | 845 #endif |
| 840 | 846 |
| 841 bool RenderWidgetHostImpl::ScheduleComposite() { | 847 bool RenderWidgetHostImpl::ScheduleComposite() { |
| 842 if (is_hidden_ || current_size_.IsEmpty() || repaint_ack_pending_ || | 848 if (is_hidden_ || current_size_.IsEmpty() || repaint_ack_pending_ || |
| 843 resize_ack_pending_) { | 849 resize_ack_pending_) { |
| 844 return false; | 850 return false; |
| 845 } | 851 } |
| 846 | 852 |
| 847 // Send out a request to the renderer to paint the view if required. | 853 // Send out a request to the renderer to paint the view if required. |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2164 } | 2170 } |
| 2165 #endif | 2171 #endif |
| 2166 | 2172 |
| 2167 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2173 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2168 if (view_) | 2174 if (view_) |
| 2169 return view_->PreferredReadbackFormat(); | 2175 return view_->PreferredReadbackFormat(); |
| 2170 return kN32_SkColorType; | 2176 return kN32_SkColorType; |
| 2171 } | 2177 } |
| 2172 | 2178 |
| 2173 } // namespace content | 2179 } // namespace content |
| OLD | NEW |