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 "content/port/browser/render_widget_host_view_frame_subscriber.h" | 17 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 343 } |
343 | 344 |
344 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle, | 345 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle, |
345 const gfx::Size& size) { | 346 const gfx::Size& size) { |
346 pixel_io_surface_size_ = size; | 347 pixel_io_surface_size_ = size; |
347 CGLSetCurrentContext(cglContext_); | 348 CGLSetCurrentContext(cglContext_); |
348 MapIOSurfaceToTexture(io_surface_handle); | 349 MapIOSurfaceToTexture(io_surface_handle); |
349 CGLSetCurrentContext(0); | 350 CGLSetCurrentContext(0); |
350 } | 351 } |
351 | 352 |
| 353 int CompositingIOSurfaceMac::GetRendererID() { |
| 354 GLint current_renderer_id = -1; |
| 355 if (CGLGetParameter(cglContext_, |
| 356 kCGLCPCurrentRendererID, |
| 357 ¤t_renderer_id) == kCGLNoError) |
| 358 return current_renderer_id & kCGLRendererIDMatchingMask; |
| 359 return -1; |
| 360 } |
| 361 |
352 void CompositingIOSurfaceMac::DrawIOSurface( | 362 void CompositingIOSurfaceMac::DrawIOSurface( |
353 NSView* view, float scale_factor, | 363 NSView* view, float scale_factor, |
354 RenderWidgetHostViewFrameSubscriber* frame_subscriber) { | 364 RenderWidgetHostViewFrameSubscriber* frame_subscriber) { |
355 CGLSetCurrentContext(cglContext_); | 365 CGLSetCurrentContext(cglContext_); |
356 | 366 |
357 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); | 367 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); |
358 | 368 |
359 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", | 369 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", |
360 "has_io_surface", has_io_surface); | 370 "has_io_surface", has_io_surface); |
361 | 371 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 } | 1033 } |
1024 | 1034 |
1025 gfx::Rect CompositingIOSurfaceMac::IntersectWithIOSurface( | 1035 gfx::Rect CompositingIOSurfaceMac::IntersectWithIOSurface( |
1026 const gfx::Rect& rect, float scale_factor) const { | 1036 const gfx::Rect& rect, float scale_factor) const { |
1027 return gfx::IntersectRects(rect, | 1037 return gfx::IntersectRects(rect, |
1028 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(io_surface_size_), | 1038 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(io_surface_size_), |
1029 scale_factor))); | 1039 scale_factor))); |
1030 } | 1040 } |
1031 | 1041 |
1032 } // namespace content | 1042 } // namespace content |
OLD | NEW |