OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/software_browser_compositor_output_surface.
h" | 5 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
6 | 6 |
| 7 #include "base/location.h" |
7 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop/message_loop.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
10 #include "cc/output/compositor_frame.h" | 12 #include "cc/output/compositor_frame.h" |
11 #include "cc/output/output_surface_client.h" | 13 #include "cc/output/output_surface_client.h" |
12 #include "cc/output/software_output_device.h" | 14 #include "cc/output/software_output_device.h" |
13 #include "content/browser/renderer_host/render_widget_host_impl.h" | 15 #include "content/browser/renderer_host/render_widget_host_impl.h" |
14 #include "ui/events/latency_info.h" | 16 #include "ui/events/latency_info.h" |
15 #include "ui/gfx/vsync_provider.h" | 17 #include "ui/gfx/vsync_provider.h" |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 | 20 |
(...skipping 12 matching lines...) Expand all Loading... |
31 void SoftwareBrowserCompositorOutputSurface::SwapBuffers( | 33 void SoftwareBrowserCompositorOutputSurface::SwapBuffers( |
32 cc::CompositorFrame* frame) { | 34 cc::CompositorFrame* frame) { |
33 base::TimeTicks swap_time = base::TimeTicks::Now(); | 35 base::TimeTicks swap_time = base::TimeTicks::Now(); |
34 for (auto& latency : frame->metadata.latency_info) { | 36 for (auto& latency : frame->metadata.latency_info) { |
35 latency.AddLatencyNumberWithTimestamp( | 37 latency.AddLatencyNumberWithTimestamp( |
36 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); | 38 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); |
37 latency.AddLatencyNumberWithTimestamp( | 39 latency.AddLatencyNumberWithTimestamp( |
38 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | 40 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, |
39 swap_time, 1); | 41 swap_time, 1); |
40 } | 42 } |
41 base::MessageLoop::current()->PostTask( | 43 base::ThreadTaskRunnerHandle::Get()->PostTask( |
42 FROM_HERE, | 44 FROM_HERE, base::Bind(&RenderWidgetHostImpl::CompositorFrameDrawn, |
43 base::Bind( | 45 frame->metadata.latency_info)); |
44 &RenderWidgetHostImpl::CompositorFrameDrawn, | |
45 frame->metadata.latency_info)); | |
46 | 46 |
47 gfx::VSyncProvider* vsync_provider = software_device()->GetVSyncProvider(); | 47 gfx::VSyncProvider* vsync_provider = software_device()->GetVSyncProvider(); |
48 if (vsync_provider) { | 48 if (vsync_provider) { |
49 vsync_provider->GetVSyncParameters(base::Bind( | 49 vsync_provider->GetVSyncParameters(base::Bind( |
50 &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu, | 50 &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu, |
51 weak_factory_.GetWeakPtr())); | 51 weak_factory_.GetWeakPtr())); |
52 } | 52 } |
53 PostSwapBuffersComplete(); | 53 PostSwapBuffersComplete(); |
54 client_->DidSwapBuffers(); | 54 client_->DidSwapBuffers(); |
55 } | 55 } |
56 | 56 |
57 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
58 void SoftwareBrowserCompositorOutputSurface::OnSurfaceDisplayed() { | 58 void SoftwareBrowserCompositorOutputSurface::OnSurfaceDisplayed() { |
59 // See GpuBrowserCompositorOutputSurface for when and how this is used. | 59 // See GpuBrowserCompositorOutputSurface for when and how this is used. |
60 NOTREACHED() << "Not expected for software surfaces."; | 60 NOTREACHED() << "Not expected for software surfaces."; |
61 } | 61 } |
62 | 62 |
63 void SoftwareBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 63 void SoftwareBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
64 bool suspended) { | 64 bool suspended) { |
65 } | 65 } |
66 | 66 |
67 bool SoftwareBrowserCompositorOutputSurface:: | 67 bool SoftwareBrowserCompositorOutputSurface:: |
68 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { | 68 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { |
69 return false; | 69 return false; |
70 } | 70 } |
71 #endif | 71 #endif |
72 | 72 |
73 } // namespace content | 73 } // namespace content |
OLD | NEW |