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_iosurface_mac.h" | 8 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 129 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
130 params.surface_handle = storage_provider_->GetSurfaceHandle(); | 130 params.surface_handle = storage_provider_->GetSurfaceHandle(); |
131 params.size = GetSize(); | 131 params.size = GetSize(); |
132 params.scale_factor = scale_factor_; | 132 params.scale_factor = scale_factor_; |
133 params.latency_info.swap(latency_info_); | 133 params.latency_info.swap(latency_info_); |
134 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 134 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
135 | 135 |
136 DCHECK(!is_swap_buffers_pending_); | 136 DCHECK(!is_swap_buffers_pending_); |
137 is_swap_buffers_pending_ = true; | 137 is_swap_buffers_pending_ = true; |
| 138 |
| 139 storage_provider_->WillSwapBuffers(); |
138 return true; | 140 return true; |
139 } | 141 } |
140 | 142 |
141 bool ImageTransportSurfaceFBO::PostSubBuffer( | 143 bool ImageTransportSurfaceFBO::PostSubBuffer( |
142 int x, int y, int width, int height) { | 144 int x, int y, int width, int height) { |
143 DCHECK(backbuffer_suggested_allocation_); | 145 DCHECK(backbuffer_suggested_allocation_); |
144 if (!frontbuffer_suggested_allocation_) | 146 if (!frontbuffer_suggested_allocation_) |
145 return true; | 147 return true; |
146 glFlush(); | 148 glFlush(); |
147 | 149 |
148 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 150 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
149 params.surface_handle = storage_provider_->GetSurfaceHandle(); | 151 params.surface_handle = storage_provider_->GetSurfaceHandle(); |
150 params.x = x; | 152 params.x = x; |
151 params.y = y; | 153 params.y = y; |
152 params.width = width; | 154 params.width = width; |
153 params.height = height; | 155 params.height = height; |
154 params.surface_size = GetSize(); | 156 params.surface_size = GetSize(); |
155 params.surface_scale_factor = scale_factor_; | 157 params.surface_scale_factor = scale_factor_; |
156 params.latency_info.swap(latency_info_); | 158 params.latency_info.swap(latency_info_); |
157 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 159 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
158 | 160 |
159 DCHECK(!is_swap_buffers_pending_); | 161 DCHECK(!is_swap_buffers_pending_); |
160 is_swap_buffers_pending_ = true; | 162 is_swap_buffers_pending_ = true; |
| 163 |
| 164 storage_provider_->WillSwapBuffers(); |
161 return true; | 165 return true; |
162 } | 166 } |
163 | 167 |
164 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { | 168 bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { |
165 return true; | 169 return true; |
166 } | 170 } |
167 | 171 |
168 gfx::Size ImageTransportSurfaceFBO::GetSize() { | 172 gfx::Size ImageTransportSurfaceFBO::GetSize() { |
169 return size_; | 173 return size_; |
170 } | 174 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 depth_stencil_renderbuffer_id_); | 318 depth_stencil_renderbuffer_id_); |
315 } | 319 } |
316 | 320 |
317 // If we asked for stencil but the extension isn't present, | 321 // If we asked for stencil but the extension isn't present, |
318 // it's OK to silently fail; subsequent code will/must check | 322 // it's OK to silently fail; subsequent code will/must check |
319 // for the presence of a stencil buffer before attempting to | 323 // for the presence of a stencil buffer before attempting to |
320 // do stencil-based operations. | 324 // do stencil-based operations. |
321 } | 325 } |
322 | 326 |
323 bool allocated_color_buffer = storage_provider_->AllocateColorBufferStorage( | 327 bool allocated_color_buffer = storage_provider_->AllocateColorBufferStorage( |
324 static_cast<CGLContextObj>(context_->GetHandle()), | 328 static_cast<CGLContextObj>(context_->GetHandle()), texture_id_, |
325 rounded_size_); | 329 rounded_size_, scale_factor_); |
326 if (!allocated_color_buffer) { | 330 if (!allocated_color_buffer) { |
327 DLOG(ERROR) << "Failed to allocate color buffer storage."; | 331 DLOG(ERROR) << "Failed to allocate color buffer storage."; |
328 DestroyFramebuffer(); | 332 DestroyFramebuffer(); |
329 return; | 333 return; |
330 } | 334 } |
331 | 335 |
332 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); | 336 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); |
333 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { | 337 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { |
334 DLOG(ERROR) << "Framebuffer was incomplete: " << status; | 338 DLOG(ERROR) << "Framebuffer was incomplete: " << status; |
335 DestroyFramebuffer(); | 339 DestroyFramebuffer(); |
336 return; | 340 return; |
337 } | 341 } |
338 | 342 |
339 has_complete_framebuffer_ = true; | 343 has_complete_framebuffer_ = true; |
340 | 344 |
341 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); | 345 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); |
342 // The FBO remains bound for this GL context. | 346 // The FBO remains bound for this GL context. |
343 } | 347 } |
344 | 348 |
345 } // namespace content | 349 } // namespace content |
OLD | NEW |