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 "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/output/output_surface_client.h" | 8 #include "cc/output/output_surface_client.h" |
9 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 9 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
10 #include "content/browser/compositor/reflector_impl.h" | 10 #include "content/browser/compositor/reflector_impl.h" |
| 11 #include "content/browser/compositor/reflector_texture.h" |
11 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
12 #include "content/common/gpu/client/context_provider_command_buffer.h" | 13 #include "content/common/gpu/client/context_provider_command_buffer.h" |
13 #include "content/public/browser/browser_thread.h" | |
14 #include "gpu/command_buffer/client/context_support.h" | 14 #include "gpu/command_buffer/client/context_support.h" |
15 #include "gpu/command_buffer/client/gles2_interface.h" | |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 | 17 |
19 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( | 18 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( |
20 const scoped_refptr<ContextProviderCommandBuffer>& context, | 19 const scoped_refptr<ContextProviderCommandBuffer>& context, |
21 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 20 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
22 scoped_ptr<BrowserCompositorOverlayCandidateValidator> | 21 scoped_ptr<BrowserCompositorOverlayCandidateValidator> |
23 overlay_candidate_validator) | 22 overlay_candidate_validator) |
24 : BrowserCompositorOutputSurface(context, | 23 : BrowserCompositorOutputSurface(context, |
25 vsync_manager, | 24 vsync_manager, |
(...skipping 27 matching lines...) Expand all Loading... |
53 if (!BrowserCompositorOutputSurface::BindToClient(client)) | 52 if (!BrowserCompositorOutputSurface::BindToClient(client)) |
54 return false; | 53 return false; |
55 | 54 |
56 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( | 55 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( |
57 swap_buffers_completion_callback_.callback()); | 56 swap_buffers_completion_callback_.callback()); |
58 GetCommandBufferProxy()->SetUpdateVSyncParametersCallback( | 57 GetCommandBufferProxy()->SetUpdateVSyncParametersCallback( |
59 update_vsync_parameters_callback_.callback()); | 58 update_vsync_parameters_callback_.callback()); |
60 return true; | 59 return true; |
61 } | 60 } |
62 | 61 |
| 62 void GpuBrowserCompositorOutputSurface::OnReflectorChanged() { |
| 63 if (!reflector_) { |
| 64 reflector_texture_.reset(); |
| 65 } else { |
| 66 reflector_texture_.reset(new ReflectorTexture(context_provider())); |
| 67 reflector_->OnSourceTextureMailboxUpdated(reflector_texture_->mailbox()); |
| 68 } |
| 69 } |
| 70 |
63 void GpuBrowserCompositorOutputSurface::SwapBuffers( | 71 void GpuBrowserCompositorOutputSurface::SwapBuffers( |
64 cc::CompositorFrame* frame) { | 72 cc::CompositorFrame* frame) { |
65 DCHECK(frame->gl_frame_data); | 73 DCHECK(frame->gl_frame_data); |
66 | 74 |
67 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); | 75 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); |
68 | 76 |
69 if (reflector_) { | 77 if (reflector_) { |
70 if (frame->gl_frame_data->sub_buffer_rect == | 78 if (frame->gl_frame_data->sub_buffer_rect == |
71 gfx::Rect(frame->gl_frame_data->size)) | 79 gfx::Rect(frame->gl_frame_data->size)) { |
| 80 reflector_texture_->CopyTextureFullImage(SurfaceSize()); |
72 reflector_->OnSourceSwapBuffers(); | 81 reflector_->OnSourceSwapBuffers(); |
73 else | 82 } else { |
74 reflector_->OnSourcePostSubBuffer(frame->gl_frame_data->sub_buffer_rect); | 83 const gfx::Rect& rect = frame->gl_frame_data->sub_buffer_rect; |
| 84 reflector_texture_->CopyTextureSubImage(rect); |
| 85 reflector_->OnSourcePostSubBuffer(rect); |
| 86 } |
75 } | 87 } |
76 | 88 |
77 if (frame->gl_frame_data->sub_buffer_rect == | 89 if (frame->gl_frame_data->sub_buffer_rect == |
78 gfx::Rect(frame->gl_frame_data->size)) { | 90 gfx::Rect(frame->gl_frame_data->size)) { |
79 context_provider_->ContextSupport()->Swap(); | 91 context_provider_->ContextSupport()->Swap(); |
80 } else { | 92 } else { |
81 context_provider_->ContextSupport()->PartialSwapBuffers( | 93 context_provider_->ContextSupport()->PartialSwapBuffers( |
82 frame->gl_frame_data->sub_buffer_rect); | 94 frame->gl_frame_data->sub_buffer_rect); |
83 } | 95 } |
84 | 96 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 146 } |
135 } | 147 } |
136 | 148 |
137 bool GpuBrowserCompositorOutputSurface:: | 149 bool GpuBrowserCompositorOutputSurface:: |
138 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { | 150 SurfaceShouldNotShowFramesAfterSuspendForRecycle() const { |
139 return should_show_frames_state_ != SHOULD_SHOW_FRAMES; | 151 return should_show_frames_state_ != SHOULD_SHOW_FRAMES; |
140 } | 152 } |
141 #endif | 153 #endif |
142 | 154 |
143 } // namespace content | 155 } // namespace content |
OLD | NEW |