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_calayer_mac.h" | 5 #include "content/common/gpu/image_transport_surface_calayer_mac.h" |
6 | 6 |
| 7 #include <OpenGL/CGLRenderers.h> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
9 #include "content/common/gpu/surface_handle_types_mac.h" | 11 #include "content/common/gpu/surface_handle_types_mac.h" |
10 #include "ui/base/cocoa/animation_utils.h" | 12 #include "ui/base/cocoa/animation_utils.h" |
11 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
12 #include "ui/gl/gl_gl_api_implementation.h" | 14 #include "ui/gl/gl_gl_api_implementation.h" |
13 #include "ui/gl/gl_switches.h" | 15 #include "ui/gl/gl_switches.h" |
14 | 16 |
15 @interface ImageTransportLayer : CAOpenGLLayer { | 17 @interface ImageTransportLayer : CAOpenGLLayer { |
16 content::CALayerStorageProvider* storageProvider_; | 18 content::CALayerStorageProvider* storageProvider_; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 glTexCoord2f(fbo_pixel_size_.width(), fbo_pixel_size_.height()); | 286 glTexCoord2f(fbo_pixel_size_.width(), fbo_pixel_size_.height()); |
285 glVertex2f(fbo_pixel_size_.width(), fbo_pixel_size_.height()); | 287 glVertex2f(fbo_pixel_size_.width(), fbo_pixel_size_.height()); |
286 | 288 |
287 glTexCoord2f(fbo_pixel_size_.width(), 0); | 289 glTexCoord2f(fbo_pixel_size_.width(), 0); |
288 glVertex2f(fbo_pixel_size_.width(), 0); | 290 glVertex2f(fbo_pixel_size_.width(), 0); |
289 } | 291 } |
290 glEnd(); | 292 glEnd(); |
291 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); | 293 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); |
292 glDisable(GL_TEXTURE_RECTANGLE_ARB); | 294 glDisable(GL_TEXTURE_RECTANGLE_ARB); |
293 | 295 |
| 296 GLint current_renderer_id = 0; |
| 297 if (CGLGetParameter(CGLGetCurrentContext(), |
| 298 kCGLCPCurrentRendererID, |
| 299 ¤t_renderer_id) == kCGLNoError) { |
| 300 current_renderer_id &= kCGLRendererIDMatchingMask; |
| 301 transport_surface_->SetRendererID(current_renderer_id); |
| 302 } |
| 303 |
294 // Allow forward progress in the context now that the swap is complete. | 304 // Allow forward progress in the context now that the swap is complete. |
295 UnblockBrowserIfNeeded(); | 305 UnblockBrowserIfNeeded(); |
296 } | 306 } |
297 | 307 |
298 void CALayerStorageProvider::LayerResetStorageProvider() { | 308 void CALayerStorageProvider::LayerResetStorageProvider() { |
299 // If we are providing back-pressure by waiting for a draw, that draw will | 309 // If we are providing back-pressure by waiting for a draw, that draw will |
300 // now never come, so release the pressure now. | 310 // now never come, so release the pressure now. |
301 UnblockBrowserIfNeeded(); | 311 UnblockBrowserIfNeeded(); |
302 } | 312 } |
303 | 313 |
304 void CALayerStorageProvider::UnblockBrowserIfNeeded() { | 314 void CALayerStorageProvider::UnblockBrowserIfNeeded() { |
305 if (!has_pending_draw_) | 315 if (!has_pending_draw_) |
306 return; | 316 return; |
307 pending_draw_weak_factory_.InvalidateWeakPtrs(); | 317 pending_draw_weak_factory_.InvalidateWeakPtrs(); |
308 has_pending_draw_ = false; | 318 has_pending_draw_ = false; |
309 transport_surface_->SendSwapBuffers( | 319 transport_surface_->SendSwapBuffers( |
310 SurfaceHandleFromCAContextID([context_ contextId]), | 320 SurfaceHandleFromCAContextID([context_ contextId]), |
311 fbo_pixel_size_, | 321 fbo_pixel_size_, |
312 fbo_scale_factor_); | 322 fbo_scale_factor_); |
313 } | 323 } |
314 | 324 |
315 } // namespace content | 325 } // namespace content |
OLD | NEW |