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/browser/renderer_host/compositing_iosurface_mac.h" | 5 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
6 | 6 |
| 7 #include <OpenGL/CGLRenderers.h> |
7 #include <OpenGL/OpenGL.h> | 8 #include <OpenGL/OpenGL.h> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
12 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
15 #include "content/common/content_constants_internal.h" | 16 #include "content/common/content_constants_internal.h" |
16 #include "gpu/command_buffer/service/gpu_switches.h" | 17 #include "gpu/command_buffer/service/gpu_switches.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 312 } |
312 | 313 |
313 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle, | 314 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle, |
314 const gfx::Size& size) { | 315 const gfx::Size& size) { |
315 pixel_io_surface_size_ = size; | 316 pixel_io_surface_size_ = size; |
316 CGLSetCurrentContext(cglContext_); | 317 CGLSetCurrentContext(cglContext_); |
317 MapIOSurfaceToTexture(io_surface_handle); | 318 MapIOSurfaceToTexture(io_surface_handle); |
318 CGLSetCurrentContext(0); | 319 CGLSetCurrentContext(0); |
319 } | 320 } |
320 | 321 |
| 322 int CompositingIOSurfaceMac::GetRenderer() { |
| 323 GLint current_renderer_id = -1; |
| 324 if (CGLGetParameter(cglContext_, |
| 325 kCGLCPCurrentRendererID, |
| 326 ¤t_renderer_id) == kCGLNoError) |
| 327 return current_renderer_id & kCGLRendererIDMatchingMask; |
| 328 return -1; |
| 329 } |
| 330 |
321 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view, float scale_factor) { | 331 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view, float scale_factor) { |
322 CGLSetCurrentContext(cglContext_); | 332 CGLSetCurrentContext(cglContext_); |
323 | 333 |
324 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); | 334 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); |
325 | 335 |
326 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", | 336 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", |
327 "has_io_surface", has_io_surface); | 337 "has_io_surface", has_io_surface); |
328 | 338 |
329 [glContext_ setView:view]; | 339 [glContext_ setView:view]; |
330 gfx::Size window_size(NSSizeToCGSize([view frame].size)); | 340 gfx::Size window_size(NSSizeToCGSize([view frame].size)); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 } | 902 } |
893 copy_context_.Reset(); | 903 copy_context_.Reset(); |
894 } | 904 } |
895 | 905 |
896 gfx::Rect CompositingIOSurfaceMac::IntersectWithIOSurface( | 906 gfx::Rect CompositingIOSurfaceMac::IntersectWithIOSurface( |
897 const gfx::Rect& rect) const { | 907 const gfx::Rect& rect) const { |
898 return gfx::IntersectRects(rect, gfx::Rect(io_surface_size_)); | 908 return gfx::IntersectRects(rect, gfx::Rect(io_surface_size_)); |
899 } | 909 } |
900 | 910 |
901 } // namespace content | 911 } // namespace content |
OLD | NEW |