OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 // to be updated if this event is changed or moved. | 263 // to be updated if this event is changed or moved. |
260 TRACE_EVENT2("gpu", "ImageTransportSurfaceFBO::CreateFramebuffer", | 264 TRACE_EVENT2("gpu", "ImageTransportSurfaceFBO::CreateFramebuffer", |
261 "width", new_rounded_size.width(), | 265 "width", new_rounded_size.width(), |
262 "height", new_rounded_size.height()); | 266 "height", new_rounded_size.height()); |
263 | 267 |
264 rounded_size_ = new_rounded_size; | 268 rounded_size_ = new_rounded_size; |
265 | 269 |
266 // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on | 270 // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on |
267 // Mac OS X and is required for IOSurface interoperability. | 271 // Mac OS X and is required for IOSurface interoperability. |
268 GLint previous_texture_id = 0; | 272 GLint previous_texture_id = 0; |
269 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &previous_texture_id); | 273 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &previous_texture_id); |
piman
2014/06/19 21:51:02
Note: you can use gfx::ScopedTextureBinder
ccameron
2014/06/19 23:56:41
That indicates that it expects GLES 2.0 textures,
| |
270 | 274 |
271 // Free the old IO Surface first to reduce memory fragmentation. | 275 // Free the old IO Surface first to reduce memory fragmentation. |
272 DestroyFramebuffer(); | 276 DestroyFramebuffer(); |
273 | 277 |
274 glGenFramebuffersEXT(1, &fbo_id_); | 278 glGenFramebuffersEXT(1, &fbo_id_); |
275 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_); | 279 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_); |
276 | 280 |
277 glGenTextures(1, &texture_id_); | 281 glGenTextures(1, &texture_id_); |
278 | 282 |
279 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_id_); | 283 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_id_); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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()), |
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 |