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/CGLIOSurface.h> | 7 #include <OpenGL/CGLIOSurface.h> |
8 #include <OpenGL/CGLRenderers.h> | 8 #include <OpenGL/CGLRenderers.h> |
9 #include <OpenGL/OpenGL.h> | 9 #include <OpenGL/OpenGL.h> |
10 | 10 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 offscreen_context_->cgl_context()); | 255 offscreen_context_->cgl_context()); |
256 DestroyAllCopyContextsWithinContext(); | 256 DestroyAllCopyContextsWithinContext(); |
257 UnrefIOSurfaceWithContextCurrent(); | 257 UnrefIOSurfaceWithContextCurrent(); |
258 } | 258 } |
259 offscreen_context_ = NULL; | 259 offscreen_context_ = NULL; |
260 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end()); | 260 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end()); |
261 } | 261 } |
262 | 262 |
263 bool CompositingIOSurfaceMac::SetIOSurfaceWithContextCurrent( | 263 bool CompositingIOSurfaceMac::SetIOSurfaceWithContextCurrent( |
264 scoped_refptr<CompositingIOSurfaceContext> current_context, | 264 scoped_refptr<CompositingIOSurfaceContext> current_context, |
265 uint64 io_surface_handle, | 265 IOSurfaceID io_surface_handle, |
266 const gfx::Size& size, | 266 const gfx::Size& size, |
267 float scale_factor) { | 267 float scale_factor) { |
268 bool result = MapIOSurfaceToTextureWithContextCurrent( | 268 bool result = MapIOSurfaceToTextureWithContextCurrent( |
269 current_context, size, scale_factor, io_surface_handle); | 269 current_context, size, scale_factor, io_surface_handle); |
270 EvictionMarkUpdated(); | 270 EvictionMarkUpdated(); |
271 return result; | 271 return result; |
272 } | 272 } |
273 | 273 |
274 int CompositingIOSurfaceMac::GetRendererID() { | 274 int CompositingIOSurfaceMac::GetRendererID() { |
275 GLint current_renderer_id = -1; | 275 GLint current_renderer_id = -1; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 446 |
447 return CopyToSelectedOutputWithinContext( | 447 return CopyToSelectedOutputWithinContext( |
448 src_pixel_subrect, region_in_frame, called_within_draw, | 448 src_pixel_subrect, region_in_frame, called_within_draw, |
449 NULL, target, callback); | 449 NULL, target, callback); |
450 } | 450 } |
451 | 451 |
452 bool CompositingIOSurfaceMac::MapIOSurfaceToTextureWithContextCurrent( | 452 bool CompositingIOSurfaceMac::MapIOSurfaceToTextureWithContextCurrent( |
453 const scoped_refptr<CompositingIOSurfaceContext>& current_context, | 453 const scoped_refptr<CompositingIOSurfaceContext>& current_context, |
454 const gfx::Size pixel_size, | 454 const gfx::Size pixel_size, |
455 float scale_factor, | 455 float scale_factor, |
456 uint64 io_surface_handle) { | 456 IOSurfaceID io_surface_handle) { |
457 TRACE_EVENT0("browser", "CompositingIOSurfaceMac::MapIOSurfaceToTexture"); | 457 TRACE_EVENT0("browser", "CompositingIOSurfaceMac::MapIOSurfaceToTexture"); |
458 | 458 |
459 if (!io_surface_ || io_surface_handle != io_surface_handle_) | 459 if (!io_surface_ || io_surface_handle != io_surface_handle_) |
460 UnrefIOSurfaceWithContextCurrent(); | 460 UnrefIOSurfaceWithContextCurrent(); |
461 | 461 |
462 pixel_io_surface_size_ = pixel_size; | 462 pixel_io_surface_size_ = pixel_size; |
463 scale_factor_ = scale_factor; | 463 scale_factor_ = scale_factor; |
464 dip_io_surface_size_ = gfx::ToFlooredSize( | 464 dip_io_surface_size_ = gfx::ToFlooredSize( |
465 gfx::ScaleSize(pixel_io_surface_size_, 1.0 / scale_factor_)); | 465 gfx::ScaleSize(pixel_io_surface_size_, 1.0 / scale_factor_)); |
466 | 466 |
467 // Early-out if the IOSurface has not changed. Note that because IOSurface | 467 // Early-out if the IOSurface has not changed. Note that because IOSurface |
468 // sizes are rounded, the same IOSurface may have two different sizes | 468 // sizes are rounded, the same IOSurface may have two different sizes |
469 // associated with it. | 469 // associated with it. |
470 if (io_surface_ && io_surface_handle == io_surface_handle_) | 470 if (io_surface_ && io_surface_handle == io_surface_handle_) |
471 return true; | 471 return true; |
472 | 472 |
473 io_surface_.reset(IOSurfaceLookup(static_cast<uint32>(io_surface_handle))); | 473 io_surface_.reset(IOSurfaceLookup(io_surface_handle)); |
474 // Can fail if IOSurface with that ID was already released by the gpu | 474 // Can fail if IOSurface with that ID was already released by the gpu |
475 // process. | 475 // process. |
476 if (!io_surface_) { | 476 if (!io_surface_) { |
477 UnrefIOSurfaceWithContextCurrent(); | 477 UnrefIOSurfaceWithContextCurrent(); |
478 return false; | 478 return false; |
479 } | 479 } |
480 | 480 |
481 io_surface_handle_ = io_surface_handle; | 481 io_surface_handle_ = io_surface_handle; |
482 | 482 |
483 // Actual IOSurface size is rounded up to reduce reallocations during window | 483 // Actual IOSurface size is rounded up to reduce reallocations during window |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 } | 961 } |
962 | 962 |
963 // static | 963 // static |
964 base::LazyInstance<CompositingIOSurfaceMac::EvictionQueue> | 964 base::LazyInstance<CompositingIOSurfaceMac::EvictionQueue> |
965 CompositingIOSurfaceMac::eviction_queue_; | 965 CompositingIOSurfaceMac::eviction_queue_; |
966 | 966 |
967 // static | 967 // static |
968 bool CompositingIOSurfaceMac::eviction_scheduled_ = false; | 968 bool CompositingIOSurfaceMac::eviction_scheduled_ = false; |
969 | 969 |
970 } // namespace content | 970 } // namespace content |
OLD | NEW |