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/OpenGL.h> | 7 #include <OpenGL/OpenGL.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 UnrefIOSurface(); | 93 UnrefIOSurface(); |
94 } | 94 } |
95 | 95 |
96 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle) { | 96 void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle) { |
97 CGLSetCurrentContext(cglContext_); | 97 CGLSetCurrentContext(cglContext_); |
98 MapIOSurfaceToTexture(io_surface_handle); | 98 MapIOSurfaceToTexture(io_surface_handle); |
99 CGLSetCurrentContext(0); | 99 CGLSetCurrentContext(0); |
100 } | 100 } |
101 | 101 |
102 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view) { | 102 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view) { |
103 TRACE_EVENT0("browser", "CompositingIOSurfaceMac::DrawIOSurface"); | |
104 CGLSetCurrentContext(cglContext_); | 103 CGLSetCurrentContext(cglContext_); |
105 | 104 |
106 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); | 105 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); |
107 | 106 |
| 107 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", |
| 108 "has_io_surface", has_io_surface); |
| 109 |
108 [glContext_ setView:view]; | 110 [glContext_ setView:view]; |
109 NSSize window_size = [view frame].size; | 111 NSSize window_size = [view frame].size; |
110 glViewport(0, 0, window_size.width, window_size.height); | 112 glViewport(0, 0, window_size.width, window_size.height); |
111 | 113 |
112 glMatrixMode(GL_PROJECTION); | 114 glMatrixMode(GL_PROJECTION); |
113 glLoadIdentity(); | 115 glLoadIdentity(); |
114 glOrtho(0, window_size.width, window_size.height, 0, -1, 1); | 116 glOrtho(0, window_size.width, window_size.height, 0, -1, 1); |
115 glMatrixMode(GL_MODELVIEW); | 117 glMatrixMode(GL_MODELVIEW); |
116 glLoadIdentity(); | 118 glLoadIdentity(); |
117 | 119 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 286 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
285 } | 287 } |
286 | 288 |
287 void CompositingIOSurfaceMac::UnrefIOSurfaceWithContextCurrent() { | 289 void CompositingIOSurfaceMac::UnrefIOSurfaceWithContextCurrent() { |
288 if (texture_) { | 290 if (texture_) { |
289 glDeleteTextures(1, &texture_); | 291 glDeleteTextures(1, &texture_); |
290 texture_ = 0; | 292 texture_ = 0; |
291 } | 293 } |
292 | 294 |
293 io_surface_.reset(); | 295 io_surface_.reset(); |
| 296 |
| 297 // Forget the ID, because even if it is still around when we want to use it |
| 298 // again, OSX may have reused the same ID for a new tab and we don't want to |
| 299 // blit random tab contents. |
| 300 io_surface_handle_ = 0; |
294 } | 301 } |
295 | 302 |
296 void CompositingIOSurfaceMac::GlobalFrameDidChange() { | 303 void CompositingIOSurfaceMac::GlobalFrameDidChange() { |
297 [glContext_ update]; | 304 [glContext_ update]; |
298 } | 305 } |
299 | 306 |
300 void CompositingIOSurfaceMac::ClearDrawable() { | 307 void CompositingIOSurfaceMac::ClearDrawable() { |
301 [glContext_ clearDrawable]; | 308 [glContext_ clearDrawable]; |
302 UnrefIOSurface(); | 309 UnrefIOSurface(); |
303 } | 310 } |
OLD | NEW |