| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 if (!helper_->Initialize()) | 50 if (!helper_->Initialize()) |
| 51 return false; | 51 return false; |
| 52 | 52 |
| 53 helper_->stub()->AddDestructionObserver(this); | 53 helper_->stub()->AddDestructionObserver(this); |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ImageTransportSurfaceFBO::Destroy() { | 57 void ImageTransportSurfaceFBO::Destroy() { |
| 58 DestroyFramebuffer(); | 58 DestroyFramebuffer(); |
| 59 | |
| 60 helper_->Destroy(); | |
| 61 } | 59 } |
| 62 | 60 |
| 63 bool ImageTransportSurfaceFBO::DeferDraws() { | 61 bool ImageTransportSurfaceFBO::DeferDraws() { |
| 64 storage_provider_->WillWriteToBackbuffer(); | 62 storage_provider_->WillWriteToBackbuffer(); |
| 65 // We should not have a pending send when we are drawing the next frame. | 63 // We should not have a pending send when we are drawing the next frame. |
| 66 DCHECK(!is_swap_buffers_send_pending_); | 64 DCHECK(!is_swap_buffers_send_pending_); |
| 67 return false; | 65 return false; |
| 68 } | 66 } |
| 69 | 67 |
| 70 bool ImageTransportSurfaceFBO::IsOffscreen() { | 68 bool ImageTransportSurfaceFBO::IsOffscreen() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 AdjustBufferAllocation(); | 102 AdjustBufferAllocation(); |
| 105 } | 103 } |
| 106 | 104 |
| 107 void ImageTransportSurfaceFBO::AdjustBufferAllocation() { | 105 void ImageTransportSurfaceFBO::AdjustBufferAllocation() { |
| 108 // On mac, the frontbuffer and backbuffer are the same buffer. The buffer is | 106 // On mac, the frontbuffer and backbuffer are the same buffer. The buffer is |
| 109 // free'd when both the browser and gpu processes have Unref'd the IOSurface. | 107 // free'd when both the browser and gpu processes have Unref'd the IOSurface. |
| 110 if (!backbuffer_suggested_allocation_ && | 108 if (!backbuffer_suggested_allocation_ && |
| 111 !frontbuffer_suggested_allocation_ && | 109 !frontbuffer_suggested_allocation_ && |
| 112 has_complete_framebuffer_) { | 110 has_complete_framebuffer_) { |
| 113 DestroyFramebuffer(); | 111 DestroyFramebuffer(); |
| 114 helper_->Suspend(); | |
| 115 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { | 112 } else if (backbuffer_suggested_allocation_ && !has_complete_framebuffer_) { |
| 116 CreateFramebuffer(); | 113 CreateFramebuffer(); |
| 117 } | 114 } |
| 118 } | 115 } |
| 119 | 116 |
| 120 bool ImageTransportSurfaceFBO::SwapBuffers() { | 117 bool ImageTransportSurfaceFBO::SwapBuffers() { |
| 121 DCHECK(backbuffer_suggested_allocation_); | 118 DCHECK(backbuffer_suggested_allocation_); |
| 122 if (!frontbuffer_suggested_allocation_) | 119 if (!frontbuffer_suggested_allocation_) |
| 123 return true; | 120 return true; |
| 124 glFlush(); | 121 glFlush(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return; | 310 return; |
| 314 } | 311 } |
| 315 | 312 |
| 316 has_complete_framebuffer_ = true; | 313 has_complete_framebuffer_ = true; |
| 317 | 314 |
| 318 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); | 315 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); |
| 319 // The FBO remains bound for this GL context. | 316 // The FBO remains bound for this GL context. |
| 320 } | 317 } |
| 321 | 318 |
| 322 } // namespace content | 319 } // namespace content |
| OLD | NEW |