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