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 16 matching lines...) Expand all Loading... | |
134 | 136 |
135 // Draw the color channels from the incoming texture. | 137 // Draw the color channels from the incoming texture. |
136 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); CHECK_GL_ERROR(); | 138 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); CHECK_GL_ERROR(); |
137 glEnable(GL_TEXTURE_RECTANGLE_ARB); CHECK_GL_ERROR(); | 139 glEnable(GL_TEXTURE_RECTANGLE_ARB); CHECK_GL_ERROR(); |
138 | 140 |
139 DrawQuad(quad_); | 141 DrawQuad(quad_); |
140 | 142 |
141 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR(); | 143 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR(); |
142 } | 144 } |
143 | 145 |
144 CGLFlushDrawable(cglContext_); | 146 CGLFlushDrawable(cglContext_); |
vangelis
2012/04/18 20:32:26
Can we send the acknowledgement back to the GPU pr
jbates
2012/04/18 23:01:58
The SwapBuffersAck is intentionally going back to
| |
145 | 147 |
146 CGLSetCurrentContext(0); | 148 CGLSetCurrentContext(0); |
147 } | 149 } |
148 | 150 |
149 bool CompositingIOSurfaceMac::CopyTo(const gfx::Size& dst_size, void* out) { | 151 bool CompositingIOSurfaceMac::CopyTo(const gfx::Size& dst_size, void* out) { |
150 if (!MapIOSurfaceToTexture(io_surface_handle_)) | 152 if (!MapIOSurfaceToTexture(io_surface_handle_)) |
151 return false; | 153 return false; |
152 | 154 |
153 CGLSetCurrentContext(cglContext_); | 155 CGLSetCurrentContext(cglContext_); |
154 GLuint target = GL_TEXTURE_RECTANGLE_ARB; | 156 GLuint target = GL_TEXTURE_RECTANGLE_ARB; |
(...skipping 129 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 |