| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "gpu/ipc/service/image_transport_surface_overlay_mac.h" | 5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" |
| 6 | 6 |
| 7 #include <CoreGraphics/CoreGraphics.h> | 7 #include <CoreGraphics/CoreGraphics.h> |
| 8 #include <IOSurface/IOSurface.h> | 8 #include <IOSurface/IOSurface.h> |
| 9 #include <OpenGL/CGLRenderers.h> | 9 #include <OpenGL/CGLRenderers.h> |
| 10 #include <OpenGL/CGLTypes.h> | 10 #include <OpenGL/CGLTypes.h> |
| 11 #include <OpenGL/gl.h> | 11 #include <OpenGL/gl.h> |
| 12 #include <stddef.h> | 12 #include <stddef.h> |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 | 15 |
| 16 // This type consistently causes problem on Mac, and needs to be dealt with | 16 // This type consistently causes problem on Mac, and needs to be dealt with |
| 17 // in a systemic way. | 17 // in a systemic way. |
| 18 // http://crbug.com/517208 | 18 // http://crbug.com/517208 |
| 19 #ifndef GL_OES_EGL_image | 19 #ifndef GL_OES_EGL_image |
| 20 typedef void* GLeglImageOES; | 20 typedef void* GLeglImageOES; |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #include "base/bind.h" | 23 #include "base/bind.h" |
| 24 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
| 25 #include "base/mac/scoped_cftyperef.h" | |
| 26 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 27 #include "gpu/ipc/common/gpu_messages.h" | 26 #include "gpu/ipc/common/gpu_messages.h" |
| 28 #include "gpu/ipc/service/gpu_channel_manager.h" | 27 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 29 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 28 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 30 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" | 29 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" |
| 31 #include "ui/accelerated_widget_mac/io_surface_context.h" | 30 #include "ui/accelerated_widget_mac/io_surface_context.h" |
| 32 #include "ui/base/cocoa/animation_utils.h" | 31 #include "ui/base/cocoa/animation_utils.h" |
| 33 #include "ui/base/cocoa/remote_layer_api.h" | 32 #include "ui/base/cocoa/remote_layer_api.h" |
| 34 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
| 35 #include "ui/gfx/swap_result.h" | 34 #include "ui/gfx/swap_result.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 291 } |
| 293 if (z_order) { | 292 if (z_order) { |
| 294 DLOG(ERROR) << "Invalid non-zero Z order."; | 293 DLOG(ERROR) << "Invalid non-zero Z order."; |
| 295 return false; | 294 return false; |
| 296 } | 295 } |
| 297 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( | 296 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( |
| 298 static_cast<gl::GLImageIOSurface*>(image)->io_surface()); | 297 static_cast<gl::GLImageIOSurface*>(image)->io_surface()); |
| 299 } | 298 } |
| 300 | 299 |
| 301 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( | 300 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( |
| 302 gl::GLImage* contents_image, | 301 const ui::CARendererLayerParams& params) { |
| 303 const gfx::RectF& contents_rect, | |
| 304 float opacity, | |
| 305 unsigned background_color, | |
| 306 unsigned edge_aa_mask, | |
| 307 const gfx::RectF& rect, | |
| 308 bool is_clipped, | |
| 309 const gfx::RectF& clip_rect, | |
| 310 const gfx::Transform& transform, | |
| 311 int sorting_context_id, | |
| 312 unsigned filter) { | |
| 313 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | |
| 314 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; | |
| 315 if (contents_image) { | |
| 316 gl::GLImageIOSurface* io_surface_image = | |
| 317 static_cast<gl::GLImageIOSurface*>(contents_image); | |
| 318 io_surface = io_surface_image->io_surface(); | |
| 319 cv_pixel_buffer = io_surface_image->cv_pixel_buffer(); | |
| 320 } | |
| 321 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() | 302 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() |
| 322 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), | 303 ->ScheduleCALayer(params); |
| 323 sorting_context_id, transform, io_surface, | |
| 324 cv_pixel_buffer, contents_rect, | |
| 325 gfx::ToEnclosingRect(rect), background_color, | |
| 326 edge_aa_mask, opacity, filter); | |
| 327 } | 304 } |
| 328 | 305 |
| 329 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { | 306 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { |
| 330 return true; | 307 return true; |
| 331 } | 308 } |
| 332 | 309 |
| 333 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, | 310 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, |
| 334 float scale_factor, | 311 float scale_factor, |
| 335 bool has_alpha) { | 312 bool has_alpha) { |
| 336 pixel_size_ = pixel_size; | 313 pixel_size_ = pixel_size; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 355 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 332 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
| 356 | 333 |
| 357 // Post a task holding a reference to the new GL context. The reason for | 334 // Post a task holding a reference to the new GL context. The reason for |
| 358 // this is to avoid creating-then-destroying the context for every image | 335 // this is to avoid creating-then-destroying the context for every image |
| 359 // transport surface that is observing the GPU switch. | 336 // transport surface that is observing the GPU switch. |
| 360 base::MessageLoop::current()->PostTask( | 337 base::MessageLoop::current()->PostTask( |
| 361 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 338 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
| 362 } | 339 } |
| 363 | 340 |
| 364 } // namespace gpu | 341 } // namespace gpu |
| OLD | NEW |