Chromium Code Reviews| 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/gpu_browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
| 12 #include "components/display_compositor/compositor_overlay_candidate_validator.h " | 12 #include "components/display_compositor/compositor_overlay_candidate_validator.h " |
| 13 #include "content/browser/compositor/reflector_impl.h" | 13 #include "content/browser/compositor/reflector_impl.h" |
| 14 #include "content/browser/compositor/reflector_texture.h" | 14 #include "content/browser/compositor/reflector_texture.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_impl.h" | 15 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 16 #include "content/common/gpu/client/context_provider_command_buffer.h" | 16 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 17 #include "gpu/command_buffer/client/context_support.h" | 17 #include "gpu/command_buffer/client/context_support.h" |
| 18 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 18 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 19 | 19 |
| 20 #if defined(OS_MACOSX) | |
| 21 #include "content/browser/gpu/gpu_surface_tracker.h" | |
| 22 #include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h" | |
| 23 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | |
| 24 #endif | |
| 25 | |
| 20 namespace content { | 26 namespace content { |
| 21 | 27 |
| 22 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( | 28 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( |
| 23 const scoped_refptr<ContextProviderCommandBuffer>& context, | 29 const scoped_refptr<ContextProviderCommandBuffer>& context, |
| 24 const scoped_refptr<ContextProviderCommandBuffer>& worker_context, | 30 const scoped_refptr<ContextProviderCommandBuffer>& worker_context, |
| 25 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 31 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
| 26 base::SingleThreadTaskRunner* task_runner, | 32 base::SingleThreadTaskRunner* task_runner, |
| 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 33 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 28 overlay_candidate_validator) | 34 overlay_candidate_validator) |
| 29 : BrowserCompositorOutputSurface(context, | 35 : BrowserCompositorOutputSurface(context, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
| 112 if (should_show_frames_state_ == | 118 if (should_show_frames_state_ == |
| 113 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { | 119 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { |
| 114 should_show_frames_state_ = SHOULD_SHOW_FRAMES; | 120 should_show_frames_state_ = SHOULD_SHOW_FRAMES; |
| 115 } | 121 } |
| 116 #endif | 122 #endif |
| 117 } | 123 } |
| 118 | 124 |
| 119 void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 125 void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 120 const std::vector<ui::LatencyInfo>& latency_info, | 126 const std::vector<ui::LatencyInfo>& latency_info, |
| 121 gfx::SwapResult result) { | 127 gfx::SwapResult result, |
| 128 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | |
| 129 #if defined(OS_MACOSX) | |
|
ccameron
2016/05/08 19:22:17
I plumbed the gpu::GpuProcessHostedCALayerTreePara
piman
2016/05/09 16:23:58
This is the right place, I think. CommandBufferPro
| |
| 130 if (!SurfaceIsSuspendForRecycle()) { | |
| 131 gfx::AcceleratedWidget native_widget = | |
| 132 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( | |
| 133 params_mac->surface_handle); | |
| 134 ui::AcceleratedWidgetMacGotFrame( | |
| 135 native_widget, params_mac->ca_context_id, | |
| 136 params_mac->fullscreen_low_power_ca_context_valid, | |
| 137 params_mac->fullscreen_low_power_ca_context_id, params_mac->io_surface, | |
| 138 params_mac->pixel_size, params_mac->scale_factor, nullptr, nullptr); | |
| 139 } | |
| 140 #endif | |
| 122 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 141 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| 123 OnSwapBuffersComplete(); | 142 OnSwapBuffersComplete(); |
| 124 } | 143 } |
| 125 | 144 |
| 126 #if defined(OS_MACOSX) | 145 #if defined(OS_MACOSX) |
| 127 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 146 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
| 128 bool suspended) { | 147 bool suspended) { |
| 129 if (suspended) { | 148 if (suspended) { |
| 130 // It may be that there are frames in-flight from the GPU process back to | 149 // It may be that there are frames in-flight from the GPU process back to |
| 131 // the browser. Make sure that these frames are not displayed by ignoring | 150 // the browser. Make sure that these frames are not displayed by ignoring |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 143 // observe). | 162 // observe). |
| 144 if (should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED) { | 163 if (should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED) { |
| 145 DiscardBackbuffer(); | 164 DiscardBackbuffer(); |
| 146 should_show_frames_state_ = | 165 should_show_frames_state_ = |
| 147 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED; | 166 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED; |
| 148 } | 167 } |
| 149 } | 168 } |
| 150 } | 169 } |
| 151 | 170 |
| 152 bool GpuBrowserCompositorOutputSurface:: | 171 bool GpuBrowserCompositorOutputSurface:: |
| 153 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { | 172 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { |
|
piman
2016/05/09 16:23:58
Am I right to assume that this (and maybe SetSurfa
ccameron
2016/05/09 18:40:36
Once we're doing the CALayer tree construction in
| |
| 154 return should_show_frames_state_ != SHOULD_SHOW_FRAMES; | 173 return should_show_frames_state_ != SHOULD_SHOW_FRAMES; |
| 155 } | 174 } |
| 156 #endif | 175 #endif |
| 157 | 176 |
| 158 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { | 177 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { |
| 159 #if defined(OS_MACOSX) | 178 #if defined(OS_MACOSX) |
| 160 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; | 179 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; |
| 161 #else | 180 #else |
| 162 return false; | 181 return false; |
| 163 #endif | 182 #endif |
| 164 } | 183 } |
| 165 | 184 |
| 166 } // namespace content | 185 } // namespace content |
| OLD | NEW |