| 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 "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "content/common/content_constants_internal.h" | 14 #include "content/common/content_constants_internal.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 18 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 19 #include "ui/gl/gl_context.h" | 19 #include "ui/gl/gl_context.h" |
| 20 #include "ui/gl/gl_switches.h" | 20 #include "ui/gl/gl_switches.h" |
| 21 #include "ui/gl/gpu_switching_manager.h" | 21 #include "ui/gl/gpu_switching_manager.h" |
| 22 #include "ui/gfx/size_conversions.h" |
| 22 #include "ui/surface/io_surface_support_mac.h" | 23 #include "ui/surface/io_surface_support_mac.h" |
| 23 | 24 |
| 24 #ifdef NDEBUG | 25 #ifdef NDEBUG |
| 25 #define CHECK_GL_ERROR() | 26 #define CHECK_GL_ERROR() |
| 26 #else | 27 #else |
| 27 #define CHECK_GL_ERROR() do { \ | 28 #define CHECK_GL_ERROR() do { \ |
| 28 GLenum gl_error = glGetError(); \ | 29 GLenum gl_error = glGetError(); \ |
| 29 LOG_IF(ERROR, gl_error != GL_NO_ERROR) << "GL Error :" << gl_error; \ | 30 LOG_IF(ERROR, gl_error != GL_NO_ERROR) << "GL Error :" << gl_error; \ |
| 30 } while (0) | 31 } while (0) |
| 31 #endif | 32 #endif |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view, float scale_factor) { | 321 void CompositingIOSurfaceMac::DrawIOSurface(NSView* view, float scale_factor) { |
| 321 CGLSetCurrentContext(cglContext_); | 322 CGLSetCurrentContext(cglContext_); |
| 322 | 323 |
| 323 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); | 324 bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_); |
| 324 | 325 |
| 325 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", | 326 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", |
| 326 "has_io_surface", has_io_surface); | 327 "has_io_surface", has_io_surface); |
| 327 | 328 |
| 328 [glContext_ setView:view]; | 329 [glContext_ setView:view]; |
| 329 gfx::Size window_size(NSSizeToCGSize([view frame].size)); | 330 gfx::Size window_size(NSSizeToCGSize([view frame].size)); |
| 330 gfx::Size pixel_window_size = window_size.Scale(scale_factor); | 331 gfx::Size pixel_window_size = gfx::ToFlooredSize( |
| 332 window_size.Scale(scale_factor)); |
| 331 glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height()); | 333 glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height()); |
| 332 | 334 |
| 333 // TODO: After a resolution change, the DPI-ness of the view and the | 335 // TODO: After a resolution change, the DPI-ness of the view and the |
| 334 // IOSurface might not be in sync. | 336 // IOSurface might not be in sync. |
| 335 io_surface_size_ = pixel_io_surface_size_.Scale(1.0 / scale_factor); | 337 io_surface_size_ = gfx::ToFlooredSize( |
| 338 pixel_io_surface_size_.Scale(1.0 / scale_factor)); |
| 336 quad_.set_size(io_surface_size_, pixel_io_surface_size_); | 339 quad_.set_size(io_surface_size_, pixel_io_surface_size_); |
| 337 | 340 |
| 338 glMatrixMode(GL_PROJECTION); | 341 glMatrixMode(GL_PROJECTION); |
| 339 glLoadIdentity(); | 342 glLoadIdentity(); |
| 340 | 343 |
| 341 // Note that the projection keeps things in view units, so the use of | 344 // Note that the projection keeps things in view units, so the use of |
| 342 // window_size / io_surface_size_ (as opposed to the pixel_ variants) below is | 345 // window_size / io_surface_size_ (as opposed to the pixel_ variants) below is |
| 343 // correct. | 346 // correct. |
| 344 glOrtho(0, window_size.width(), window_size.height(), 0, -1, 1); | 347 glOrtho(0, window_size.width(), window_size.height(), 0, -1, 1); |
| 345 glMatrixMode(GL_MODELVIEW); | 348 glMatrixMode(GL_MODELVIEW); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); | 838 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); |
| 836 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); | 839 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); |
| 837 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); | 840 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); |
| 838 if (copy_context_.use_fence) { | 841 if (copy_context_.use_fence) { |
| 839 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); | 842 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); |
| 840 } | 843 } |
| 841 copy_context_.Reset(); | 844 copy_context_.Reset(); |
| 842 } | 845 } |
| 843 | 846 |
| 844 } // namespace content | 847 } // namespace content |
| OLD | NEW |