| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // free'd when both the browser and gpu processes have Unref'd the IOSurface. | 162 // free'd when both the browser and gpu processes have Unref'd the IOSurface. |
| 163 if (!backbuffer_suggested_allocation_ && | 163 if (!backbuffer_suggested_allocation_ && |
| 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 bool ImageTransportSurfaceFBO::SwapBuffers() { | 172 gfx::SwapResult ImageTransportSurfaceFBO::SwapBuffers() { |
| 173 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers"); | 173 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers"); |
| 174 return SwapBuffersInternal(); | 174 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK |
| 175 : gfx::SwapResult::SWAP_FAILED; |
| 175 } | 176 } |
| 176 | 177 |
| 177 bool ImageTransportSurfaceFBO::SwapBuffersInternal() { | 178 bool ImageTransportSurfaceFBO::SwapBuffersInternal() { |
| 178 DCHECK(backbuffer_suggested_allocation_); | 179 DCHECK(backbuffer_suggested_allocation_); |
| 179 if (!frontbuffer_suggested_allocation_) | 180 if (!frontbuffer_suggested_allocation_) |
| 180 return true; | 181 return true; |
| 181 glFlush(); | 182 glFlush(); |
| 182 | 183 |
| 183 // It is the responsibility of the storage provider to send the swap IPC. | 184 // It is the responsibility of the storage provider to send the swap IPC. |
| 184 is_swap_buffers_send_pending_ = true; | 185 is_swap_buffers_send_pending_ = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 201 params.latency_info.swap(latency_info_); | 202 params.latency_info.swap(latency_info_); |
| 202 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 203 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 203 is_swap_buffers_send_pending_ = false; | 204 is_swap_buffers_send_pending_ = false; |
| 204 } | 205 } |
| 205 | 206 |
| 206 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { | 207 void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { |
| 207 if (renderer_id) | 208 if (renderer_id) |
| 208 context_->share_group()->SetRendererID(renderer_id); | 209 context_->share_group()->SetRendererID(renderer_id); |
| 209 } | 210 } |
| 210 | 211 |
| 211 bool ImageTransportSurfaceFBO::PostSubBuffer( | 212 gfx::SwapResult ImageTransportSurfaceFBO::PostSubBuffer(int x, |
| 212 int x, int y, int width, int height) { | 213 int y, |
| 214 int width, |
| 215 int height) { |
| 213 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer"); | 216 TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer"); |
| 214 return SwapBuffersInternal(); | 217 return SwapBuffersInternal() ? gfx::SwapResult::SWAP_ACK |
| 218 : gfx::SwapResult::SWAP_FAILED; |
| 215 } | 219 } |
| 216 | 220 |
| 217 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { | 221 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { |
| 218 return true; | 222 return true; |
| 219 } | 223 } |
| 220 | 224 |
| 221 gfx::Size ImageTransportSurfaceFBO::GetSize() { | 225 gfx::Size ImageTransportSurfaceFBO::GetSize() { |
| 222 return pixel_size_; | 226 return pixel_size_; |
| 223 } | 227 } |
| 224 | 228 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } | 411 } |
| 408 | 412 |
| 409 has_complete_framebuffer_ = true; | 413 has_complete_framebuffer_ = true; |
| 410 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); | 414 storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); |
| 411 | 415 |
| 412 glBindTexture(texture_target, previous_texture_id); | 416 glBindTexture(texture_target, previous_texture_id); |
| 413 // The FBO remains bound for this GL context. | 417 // The FBO remains bound for this GL context. |
| 414 } | 418 } |
| 415 | 419 |
| 416 } // namespace content | 420 } // namespace content |
| OLD | NEW |