| 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 "content/common/gpu/gpu_messages.h" | 7 #include "content/common/gpu/gpu_messages.h" |
| 8 #include "content/common/gpu/image_transport_surface_calayer_mac.h" | 8 #include "content/common/gpu/image_transport_surface_calayer_mac.h" |
| 9 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" | 9 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" |
| 10 #include "ui/base/cocoa/remote_layer_api.h" | 10 #include "ui/base/cocoa/remote_layer_api.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (!backbuffer_suggested_allocation_ && | 162 if (!backbuffer_suggested_allocation_ && |
| 163 !frontbuffer_suggested_allocation_ && | 163 !frontbuffer_suggested_allocation_ && |
| 164 has_complete_framebuffer_) { | 164 has_complete_framebuffer_) { |
| 165 DestroyFramebuffer(); | 165 DestroyFramebuffer(); |
| 166 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { | 166 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { |
| 167 AllocateOrResizeFramebuffer(pixel_size_, scale_factor_); | 167 AllocateOrResizeFramebuffer(pixel_size_, scale_factor_); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool ImageTransportSurfaceFBO::SwapBuffers() { | 171 bool ImageTransportSurfaceFBO::SwapBuffers() { |
| 172 return SwapBuffersInternal(); |
| 173 } |
| 174 |
| 175 bool ImageTransportSurfaceFBO::SwapBuffersInternal() { |
| 172 DCHECK(backbuffer_suggested_allocation_); | 176 DCHECK(backbuffer_suggested_allocation_); |
| 173 if (!frontbuffer_suggested_allocation_) | 177 if (!frontbuffer_suggested_allocation_) |
| 174 return true; | 178 return true; |
| 175 glFlush(); | 179 glFlush(); |
| 176 | 180 |
| 177 // It is the responsibility of the storage provider to send the swap IPC. | 181 // It is the responsibility of the storage provider to send the swap IPC. |
| 178 is_swap_buffers_send_pending_ = true; | 182 is_swap_buffers_send_pending_ = true; |
| 179 storage_provider_->SwapBuffers(pixel_size_, scale_factor_); | 183 storage_provider_->SwapBuffers(); |
| 180 | 184 |
| 181 // The call to swapBuffers could potentially result in an immediate draw. | 185 // The call to swapBuffers could potentially result in an immediate draw. |
| 182 // Ensure that any changes made to the context's state are restored. | 186 // Ensure that any changes made to the context's state are restored. |
| 183 context_->RestoreStateIfDirtiedExternally(); | 187 context_->RestoreStateIfDirtiedExternally(); |
| 184 return true; | 188 return true; |
| 185 } | 189 } |
| 186 | 190 |
| 187 void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle, | 191 void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle, |
| 188 const gfx::Size pixel_size, | 192 const gfx::Size pixel_size, |
| 189 float scale_factor) { | 193 float scale_factor) { |
| 190 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 194 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 191 params.surface_handle = surface_handle; | 195 params.surface_handle = surface_handle; |
| 192 params.size = pixel_size; | 196 params.size = pixel_size; |
| 193 params.scale_factor = scale_factor; | 197 params.scale_factor = scale_factor; |
| 194 params.latency_info.swap(latency_info_); | 198 params.latency_info.swap(latency_info_); |
| 195 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 199 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 196 is_swap_buffers_send_pending_ = false; | 200 is_swap_buffers_send_pending_ = false; |
| 197 } | 201 } |
| 198 | 202 |
| 199 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { | 203 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { |
| 200 if (renderer_id) | 204 if (renderer_id) |
| 201 context_->share_group()->SetRendererID(renderer_id); | 205 context_->share_group()->SetRendererID(renderer_id); |
| 202 } | 206 } |
| 203 | 207 |
| 204 bool ImageTransportSurfaceFBO::PostSubBuffer( | 208 bool ImageTransportSurfaceFBO::PostSubBuffer( |
| 205 int x, int y, int width, int height) { | 209 int x, int y, int width, int height) { |
| 206 // Mac does not support sub-buffer swaps. | 210 return SwapBuffersInternal(); |
| 207 NOTREACHED(); | |
| 208 return false; | |
| 209 } | 211 } |
| 210 | 212 |
| 211 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { | 213 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { |
| 212 return false; | 214 return true; |
| 213 } | 215 } |
| 214 | 216 |
| 215 gfx::Size ImageTransportSurfaceFBO::GetSize() { | 217 gfx::Size ImageTransportSurfaceFBO::GetSize() { |
| 216 return pixel_size_; | 218 return pixel_size_; |
| 217 } | 219 } |
| 218 | 220 |
| 219 void* ImageTransportSurfaceFBO::GetHandle() { | 221 void* ImageTransportSurfaceFBO::GetHandle() { |
| 220 return NULL; | 222 return NULL; |
| 221 } | 223 } |
| 222 | 224 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 bool needs_new_storage = | 297 bool needs_new_storage = |
| 296 !has_complete_framebuffer_ || | 298 !has_complete_framebuffer_ || |
| 297 new_rounded_pixel_size != rounded_pixel_size_ || | 299 new_rounded_pixel_size != rounded_pixel_size_ || |
| 298 new_scale_factor != scale_factor_; | 300 new_scale_factor != scale_factor_; |
| 299 | 301 |
| 300 // Save the new storage parameters. | 302 // Save the new storage parameters. |
| 301 pixel_size_ = new_pixel_size; | 303 pixel_size_ = new_pixel_size; |
| 302 rounded_pixel_size_ = new_rounded_pixel_size; | 304 rounded_pixel_size_ = new_rounded_pixel_size; |
| 303 scale_factor_ = new_scale_factor; | 305 scale_factor_ = new_scale_factor; |
| 304 | 306 |
| 305 if (!needs_new_storage) | 307 if (!needs_new_storage) { |
| 308 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); |
| 306 return; | 309 return; |
| 310 } |
| 307 | 311 |
| 308 TRACE_EVENT2("gpu", "ImageTransportSurfaceFBO::AllocateOrResizeFramebuffer", | 312 TRACE_EVENT2("gpu", "ImageTransportSurfaceFBO::AllocateOrResizeFramebuffer", |
| 309 "width", new_rounded_pixel_size.width(), | 313 "width", new_rounded_pixel_size.width(), |
| 310 "height", new_rounded_pixel_size.height()); | 314 "height", new_rounded_pixel_size.height()); |
| 311 | 315 |
| 312 // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on | 316 // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on |
| 313 // Mac OS X and is required for IOSurface interoperability. | 317 // Mac OS X and is required for IOSurface interoperability. |
| 314 GLint previous_texture_id = 0; | 318 GLint previous_texture_id = 0; |
| 315 | 319 |
| 316 GLenum texture_target = GL_TEXTURE_RECTANGLE_ARB; | 320 GLenum texture_target = GL_TEXTURE_RECTANGLE_ARB; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 395 } |
| 392 | 396 |
| 393 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); | 397 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); |
| 394 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { | 398 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { |
| 395 DLOG(ERROR) << "Framebuffer was incomplete: " << status; | 399 DLOG(ERROR) << "Framebuffer was incomplete: " << status; |
| 396 DestroyFramebuffer(); | 400 DestroyFramebuffer(); |
| 397 return; | 401 return; |
| 398 } | 402 } |
| 399 | 403 |
| 400 has_complete_framebuffer_ = true; | 404 has_complete_framebuffer_ = true; |
| 405 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); |
| 401 | 406 |
| 402 glBindTexture(texture_target, previous_texture_id); | 407 glBindTexture(texture_target, previous_texture_id); |
| 403 // The FBO remains bound for this GL context. | 408 // The FBO remains bound for this GL context. |
| 404 } | 409 } |
| 405 | 410 |
| 406 } // namespace content | 411 } // namespace content |
| OLD | NEW |