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" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 12 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "gpu/command_buffer/service/gpu_switches.h" | 14 #include "gpu/command_buffer/service/gpu_switches.h" |
15 #include "ui/gfx/rect.h" | |
15 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 16 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
16 #include "ui/gl/gl_context.h" | 17 #include "ui/gl/gl_context.h" |
17 #include "ui/gl/gl_switches.h" | 18 #include "ui/gl/gl_switches.h" |
18 #include "ui/surface/io_surface_support_mac.h" | 19 #include "ui/surface/io_surface_support_mac.h" |
19 | 20 |
20 #ifdef NDEBUG | 21 #ifdef NDEBUG |
21 #define CHECK_GL_ERROR() | 22 #define CHECK_GL_ERROR() |
22 #else | 23 #else |
23 #define CHECK_GL_ERROR() do { \ | 24 #define CHECK_GL_ERROR() do { \ |
24 GLenum gl_error = glGetError(); \ | 25 GLenum gl_error = glGetError(); \ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 // by forcing the graphics pipeline to be completely drained at this | 297 // by forcing the graphics pipeline to be completely drained at this |
297 // point. | 298 // point. |
298 glFinish(); | 299 glFinish(); |
299 } | 300 } |
300 | 301 |
301 CGLFlushDrawable(cglContext_); | 302 CGLFlushDrawable(cglContext_); |
302 | 303 |
303 CGLSetCurrentContext(0); | 304 CGLSetCurrentContext(0); |
304 } | 305 } |
305 | 306 |
306 bool CompositingIOSurfaceMac::CopyTo(const gfx::Size& dst_size, void* out) { | 307 bool CompositingIOSurfaceMac::CopyTo( |
308 const gfx::Rect& src_subrect, | |
309 const gfx::Size& dst_size, | |
Nico
2012/07/26 23:45:48
Can you call the parameters src_pixel_subrect and
mazda
2012/07/27 00:00:35
Done.
| |
310 void* out) { | |
307 if (!MapIOSurfaceToTexture(io_surface_handle_)) | 311 if (!MapIOSurfaceToTexture(io_surface_handle_)) |
308 return false; | 312 return false; |
309 | 313 |
310 CGLSetCurrentContext(cglContext_); | 314 CGLSetCurrentContext(cglContext_); |
311 GLuint target = GL_TEXTURE_RECTANGLE_ARB; | 315 GLuint target = GL_TEXTURE_RECTANGLE_ARB; |
312 | 316 |
313 GLuint dst_texture = 0; | 317 GLuint dst_texture = 0; |
314 glGenTextures(1, &dst_texture); CHECK_GL_ERROR(); | 318 glGenTextures(1, &dst_texture); CHECK_GL_ERROR(); |
315 glBindTexture(target, dst_texture); CHECK_GL_ERROR(); | 319 glBindTexture(target, dst_texture); CHECK_GL_ERROR(); |
316 | 320 |
(...skipping 29 matching lines...) Expand all Loading... | |
346 glDisable(GL_BLEND); | 350 glDisable(GL_BLEND); |
347 | 351 |
348 glUseProgram(shader_program_blit_rgb_); | 352 glUseProgram(shader_program_blit_rgb_); |
349 | 353 |
350 int texture_unit = 0; | 354 int texture_unit = 0; |
351 glUniform1i(blit_rgb_sampler_location_, texture_unit); | 355 glUniform1i(blit_rgb_sampler_location_, texture_unit); |
352 glActiveTexture(GL_TEXTURE0 + texture_unit); | 356 glActiveTexture(GL_TEXTURE0 + texture_unit); |
353 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); | 357 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); |
354 | 358 |
355 SurfaceQuad quad; | 359 SurfaceQuad quad; |
356 quad.set_size(dst_size, pixel_io_surface_size_); | 360 quad.set_rect(0.0f, 0.0f, dst_size.width(), dst_size.height()); |
361 quad.set_texcoord_rect(src_subrect.x(), src_subrect.y(), | |
362 src_subrect.right(), src_subrect.bottom()); | |
357 DrawQuad(quad); | 363 DrawQuad(quad); |
358 | 364 |
359 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR(); | 365 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); CHECK_GL_ERROR(); |
360 glUseProgram(0); | 366 glUseProgram(0); |
361 | 367 |
362 CGLFlushDrawable(cglContext_); | 368 CGLFlushDrawable(cglContext_); |
363 | 369 |
364 glReadPixels(0, 0, dst_size.width(), dst_size.height(), | 370 glReadPixels(0, 0, dst_size.width(), dst_size.height(), |
365 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, out); | 371 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, out); |
366 | 372 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 void CompositingIOSurfaceMac::GlobalFrameDidChange() { | 467 void CompositingIOSurfaceMac::GlobalFrameDidChange() { |
462 [glContext_ update]; | 468 [glContext_ update]; |
463 } | 469 } |
464 | 470 |
465 void CompositingIOSurfaceMac::ClearDrawable() { | 471 void CompositingIOSurfaceMac::ClearDrawable() { |
466 [glContext_ clearDrawable]; | 472 [glContext_ clearDrawable]; |
467 UnrefIOSurface(); | 473 UnrefIOSurface(); |
468 } | 474 } |
469 | 475 |
470 } // namespace content | 476 } // namespace content |
OLD | NEW |