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/common/gpu/image_transport_surface_fbo_mac.h" | 5 #include "content/common/gpu/image_transport_surface_fbo_mac.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "content/common/gpu/gpu_messages.h" | 8 #include "content/common/gpu/gpu_messages.h" |
9 #include "content/common/gpu/image_transport_surface_calayer_mac.h" | 9 #include "content/common/gpu/image_transport_surface_calayer_mac.h" |
10 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" | 10 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 !frontbuffer_suggested_allocation_ && | 164 !frontbuffer_suggested_allocation_ && |
165 has_complete_framebuffer_) { | 165 has_complete_framebuffer_) { |
166 DestroyFramebuffer(); | 166 DestroyFramebuffer(); |
167 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { | 167 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { |
168 AllocateOrResizeFramebuffer(pixel_size_, scale_factor_); | 168 AllocateOrResizeFramebuffer(pixel_size_, scale_factor_); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 gfx::SwapResult ImageTransportSurfaceFBO::SwapBuffers() { | 172 gfx::SwapResult ImageTransportSurfaceFBO::SwapBuffers() { |
173 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers"); | 173 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers"); |
| 174 pending_swap_pixel_damage_rect_ = gfx::Rect(pixel_size_); |
174 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK | 175 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK |
175 : gfx::SwapResult::SWAP_FAILED; | 176 : gfx::SwapResult::SWAP_FAILED; |
176 } | 177 } |
177 | 178 |
178 bool ImageTransportSurfaceFBO::SwapBuffersInternal() { | 179 bool ImageTransportSurfaceFBO::SwapBuffersInternal() { |
179 DCHECK(backbuffer_suggested_allocation_); | 180 DCHECK(backbuffer_suggested_allocation_); |
180 if (!frontbuffer_suggested_allocation_) | 181 if (!frontbuffer_suggested_allocation_) |
181 return true; | 182 return true; |
182 glFlush(); | 183 glFlush(); |
183 | 184 |
184 // It is the responsibility of the storage provider to send the swap IPC. | 185 // It is the responsibility of the storage provider to send the swap IPC. |
185 is_swap_buffers_send_pending_ = true; | 186 is_swap_buffers_send_pending_ = true; |
186 storage_provider_->SwapBuffers(); | 187 storage_provider_->SwapBuffers(); |
187 | 188 |
188 // The call to swapBuffers could potentially result in an immediate draw. | 189 // The call to swapBuffers could potentially result in an immediate draw. |
189 // Ensure that any changes made to the context's state are restored. | 190 // Ensure that any changes made to the context's state are restored. |
190 context_->RestoreStateIfDirtiedExternally(); | 191 context_->RestoreStateIfDirtiedExternally(); |
191 return true; | 192 return true; |
192 } | 193 } |
193 | 194 |
194 void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle, | 195 void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle, |
195 const gfx::Size pixel_size, | 196 const gfx::Size pixel_size, |
196 float scale_factor) { | 197 float scale_factor) { |
197 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SendSwapBuffers"); | 198 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SendSwapBuffers"); |
198 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 199 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
199 params.surface_handle = surface_handle; | 200 params.surface_handle = surface_handle; |
200 params.size = pixel_size; | 201 params.size = pixel_size; |
| 202 params.damage_rect = pending_swap_pixel_damage_rect_; |
201 params.scale_factor = scale_factor; | 203 params.scale_factor = scale_factor; |
202 params.latency_info.swap(latency_info_); | 204 params.latency_info.swap(latency_info_); |
203 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 205 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
204 is_swap_buffers_send_pending_ = false; | 206 is_swap_buffers_send_pending_ = false; |
| 207 pending_swap_pixel_damage_rect_ = gfx::Rect(); |
205 } | 208 } |
206 | 209 |
207 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { | 210 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { |
208 if (renderer_id) | 211 if (renderer_id) |
209 context_->share_group()->SetRendererID(renderer_id); | 212 context_->share_group()->SetRendererID(renderer_id); |
210 } | 213 } |
211 | 214 |
212 gfx::SwapResult ImageTransportSurfaceFBO::PostSubBuffer(int x, | 215 gfx::SwapResult ImageTransportSurfaceFBO::PostSubBuffer(int x, |
213 int y, | 216 int y, |
214 int width, | 217 int width, |
215 int height) { | 218 int height) { |
216 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer"); | 219 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer"); |
| 220 pending_swap_pixel_damage_rect_.Union(gfx::Rect(x, y, width, height)); |
217 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK | 221 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK |
218 : gfx::SwapResult::SWAP_FAILED; | 222 : gfx::SwapResult::SWAP_FAILED; |
219 } | 223 } |
220 | 224 |
221 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { | 225 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { |
222 return true; | 226 return true; |
223 } | 227 } |
224 | 228 |
225 gfx::Size ImageTransportSurfaceFBO::GetSize() { | 229 gfx::Size ImageTransportSurfaceFBO::GetSize() { |
226 return pixel_size_; | 230 return pixel_size_; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 415 } |
412 | 416 |
413 has_complete_framebuffer_ = true; | 417 has_complete_framebuffer_ = true; |
414 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); | 418 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); |
415 | 419 |
416 glBindTexture(texture_target, previous_texture_id); | 420 glBindTexture(texture_target, previous_texture_id); |
417 // The FBO remains bound for this GL context. | 421 // The FBO remains bound for this GL context. |
418 } | 422 } |
419 | 423 |
420 } // namespace content | 424 } // namespace content |
OLD | NEW |