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/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { | 89 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { |
90 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 90 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
91 } | 91 } |
92 | 92 |
93 void GpuBrowserCompositorOutputSurface::Reshape( | 93 void GpuBrowserCompositorOutputSurface::Reshape( |
94 const gfx::Size& size, | 94 const gfx::Size& size, |
95 float device_scale_factor, | 95 float device_scale_factor, |
96 const gfx::ColorSpace& color_space, | 96 const gfx::ColorSpace& color_space, |
97 bool has_alpha, | 97 bool has_alpha, |
98 bool use_stencil) { | 98 bool use_stencil) { |
| 99 size_ = size; |
| 100 has_set_draw_rectangle_since_last_resize_ = false; |
99 context_provider()->ContextGL()->ResizeCHROMIUM( | 101 context_provider()->ContextGL()->ResizeCHROMIUM( |
100 size.width(), size.height(), device_scale_factor, has_alpha); | 102 size.width(), size.height(), device_scale_factor, has_alpha); |
101 } | 103 } |
102 | 104 |
103 void GpuBrowserCompositorOutputSurface::SwapBuffers( | 105 void GpuBrowserCompositorOutputSurface::SwapBuffers( |
104 cc::OutputSurfaceFrame frame) { | 106 cc::OutputSurfaceFrame frame) { |
105 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); | 107 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); |
106 | 108 |
107 gfx::Size surface_size = frame.size; | 109 gfx::Size surface_size = frame.size; |
108 if (reflector_) { | 110 if (reflector_) { |
109 if (frame.sub_buffer_rect) { | 111 if (frame.sub_buffer_rect) { |
110 reflector_texture_->CopyTextureSubImage(*frame.sub_buffer_rect); | 112 reflector_texture_->CopyTextureSubImage(*frame.sub_buffer_rect); |
111 reflector_->OnSourcePostSubBuffer(*frame.sub_buffer_rect, surface_size); | 113 reflector_->OnSourcePostSubBuffer(*frame.sub_buffer_rect, surface_size); |
112 } else { | 114 } else { |
113 reflector_texture_->CopyTextureFullImage(surface_size); | 115 reflector_texture_->CopyTextureFullImage(surface_size); |
114 reflector_->OnSourceSwapBuffers(surface_size); | 116 reflector_->OnSourceSwapBuffers(surface_size); |
115 } | 117 } |
116 } | 118 } |
117 | 119 |
| 120 set_draw_rectangle_for_frame_ = false; |
| 121 |
118 if (frame.sub_buffer_rect) { | 122 if (frame.sub_buffer_rect) { |
119 DCHECK(frame.content_bounds.empty()); | 123 DCHECK(frame.content_bounds.empty()); |
120 context_provider_->ContextSupport()->PartialSwapBuffers( | 124 context_provider_->ContextSupport()->PartialSwapBuffers( |
121 *frame.sub_buffer_rect); | 125 *frame.sub_buffer_rect); |
122 } else if (!frame.content_bounds.empty()) { | 126 } else if (!frame.content_bounds.empty()) { |
123 context_provider_->ContextSupport()->SwapWithBounds(frame.content_bounds); | 127 context_provider_->ContextSupport()->SwapWithBounds(frame.content_bounds); |
124 } else { | 128 } else { |
125 context_provider_->ContextSupport()->Swap(); | 129 context_provider_->ContextSupport()->Swap(); |
126 } | 130 } |
127 } | 131 } |
(...skipping 13 matching lines...) Expand all Loading... |
141 | 145 |
142 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { | 146 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { |
143 return false; | 147 return false; |
144 } | 148 } |
145 | 149 |
146 #if defined(OS_MACOSX) | 150 #if defined(OS_MACOSX) |
147 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 151 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
148 bool suspended) {} | 152 bool suspended) {} |
149 #endif | 153 #endif |
150 | 154 |
| 155 void GpuBrowserCompositorOutputSurface::SetDrawRectangle( |
| 156 const gfx::Rect& rect) { |
| 157 if (set_draw_rectangle_for_frame_) |
| 158 return; |
| 159 DCHECK(gfx::Rect(size_).Contains(rect)); |
| 160 DCHECK(has_set_draw_rectangle_since_last_resize_ || |
| 161 (gfx::Rect(size_) == rect)); |
| 162 set_draw_rectangle_for_frame_ = true; |
| 163 has_set_draw_rectangle_since_last_resize_ = true; |
| 164 context_provider()->ContextGL()->SetDrawRectangleCHROMIUM( |
| 165 rect.x(), rect.y(), rect.width(), rect.height()); |
| 166 } |
| 167 |
151 gpu::CommandBufferProxyImpl* | 168 gpu::CommandBufferProxyImpl* |
152 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { | 169 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { |
153 ui::ContextProviderCommandBuffer* provider_command_buffer = | 170 ui::ContextProviderCommandBuffer* provider_command_buffer = |
154 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); | 171 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); |
155 gpu::CommandBufferProxyImpl* command_buffer_proxy = | 172 gpu::CommandBufferProxyImpl* command_buffer_proxy = |
156 provider_command_buffer->GetCommandBufferProxy(); | 173 provider_command_buffer->GetCommandBufferProxy(); |
157 DCHECK(command_buffer_proxy); | 174 DCHECK(command_buffer_proxy); |
158 return command_buffer_proxy; | 175 return command_buffer_proxy; |
159 } | 176 } |
160 | 177 |
161 } // namespace content | 178 } // namespace content |
OLD | NEW |