| 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" | 25 #include "base/mac/scoped_cftyperef.h" |
| 26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
| 27 #include "gpu/ipc/service/ca_layer_partial_damage_tree_mac.h" | |
| 28 #include "gpu/ipc/service/ca_layer_tree_mac.h" | |
| 29 #include "gpu/ipc/service/gpu_channel_manager.h" | 27 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 30 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 28 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 29 #include "ui/accelerated_widget_mac/ca_layer_partial_damage_tree_mac.h" |
| 30 #include "ui/accelerated_widget_mac/ca_layer_tree_mac.h" |
| 31 #include "ui/accelerated_widget_mac/io_surface_context.h" | 31 #include "ui/accelerated_widget_mac/io_surface_context.h" |
| 32 #include "ui/base/cocoa/animation_utils.h" | 32 #include "ui/base/cocoa/animation_utils.h" |
| 33 #include "ui/base/cocoa/remote_layer_api.h" | 33 #include "ui/base/cocoa/remote_layer_api.h" |
| 34 #include "ui/gfx/geometry/rect_conversions.h" | 34 #include "ui/gfx/geometry/rect_conversions.h" |
| 35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 36 #include "ui/gl/gl_context.h" | 36 #include "ui/gl/gl_context.h" |
| 37 #include "ui/gl/gl_fence.h" | 37 #include "ui/gl/gl_fence.h" |
| 38 #include "ui/gl/gl_image_io_surface.h" | 38 #include "ui/gl/gl_image_io_surface.h" |
| 39 #include "ui/gl/gpu_switching_manager.h" | 39 #include "ui/gl/gpu_switching_manager.h" |
| 40 #include "ui/gl/scoped_api.h" | 40 #include "ui/gl/scoped_api.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 return false; | 274 return false; |
| 275 } | 275 } |
| 276 if (z_order) { | 276 if (z_order) { |
| 277 DLOG(ERROR) << "Invalid non-zero Z order."; | 277 DLOG(ERROR) << "Invalid non-zero Z order."; |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 if (pending_partial_damage_tree_) { | 280 if (pending_partial_damage_tree_) { |
| 281 DLOG(ERROR) << "Only one overlay per swap is allowed."; | 281 DLOG(ERROR) << "Only one overlay per swap is allowed."; |
| 282 return false; | 282 return false; |
| 283 } | 283 } |
| 284 pending_partial_damage_tree_.reset(new CALayerPartialDamageTree( | 284 pending_partial_damage_tree_.reset(new ui::CALayerPartialDamageTree( |
| 285 use_remote_layer_api_, | 285 use_remote_layer_api_, |
| 286 static_cast<gl::GLImageIOSurface*>(image)->io_surface(), | 286 static_cast<gl::GLImageIOSurface*>(image)->io_surface(), |
| 287 pixel_frame_rect)); | 287 pixel_frame_rect)); |
| 288 return true; | 288 return true; |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( | 291 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( |
| 292 gl::GLImage* contents_image, | 292 gl::GLImage* contents_image, |
| 293 const gfx::RectF& contents_rect, | 293 const gfx::RectF& contents_rect, |
| 294 float opacity, | 294 float opacity, |
| 295 unsigned background_color, | 295 unsigned background_color, |
| 296 unsigned edge_aa_mask, | 296 unsigned edge_aa_mask, |
| 297 const gfx::RectF& rect, | 297 const gfx::RectF& rect, |
| 298 bool is_clipped, | 298 bool is_clipped, |
| 299 const gfx::RectF& clip_rect, | 299 const gfx::RectF& clip_rect, |
| 300 const gfx::Transform& transform, | 300 const gfx::Transform& transform, |
| 301 int sorting_context_id, | 301 int sorting_context_id, |
| 302 unsigned filter) { | 302 unsigned filter) { |
| 303 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | 303 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; |
| 304 if (contents_image) { | 304 if (contents_image) { |
| 305 io_surface = | 305 io_surface = |
| 306 static_cast<gl::GLImageIOSurface*>(contents_image)->io_surface(); | 306 static_cast<gl::GLImageIOSurface*>(contents_image)->io_surface(); |
| 307 } | 307 } |
| 308 if (!pending_ca_layer_tree_) | 308 if (!pending_ca_layer_tree_) |
| 309 pending_ca_layer_tree_.reset(new CALayerTree); | 309 pending_ca_layer_tree_.reset(new ui::CALayerTree); |
| 310 return pending_ca_layer_tree_->ScheduleCALayer( | 310 return pending_ca_layer_tree_->ScheduleCALayer( |
| 311 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, | 311 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, |
| 312 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), | 312 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), |
| 313 background_color, edge_aa_mask, opacity); | 313 background_color, edge_aa_mask, opacity); |
| 314 } | 314 } |
| 315 | 315 |
| 316 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { | 316 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { |
| 317 return true; | 317 return true; |
| 318 } | 318 } |
| 319 | 319 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 342 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 342 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
| 343 | 343 |
| 344 // Post a task holding a reference to the new GL context. The reason for | 344 // Post a task holding a reference to the new GL context. The reason for |
| 345 // this is to avoid creating-then-destroying the context for every image | 345 // this is to avoid creating-then-destroying the context for every image |
| 346 // transport surface that is observing the GPU switch. | 346 // transport surface that is observing the GPU switch. |
| 347 base::MessageLoop::current()->PostTask( | 347 base::MessageLoop::current()->PostTask( |
| 348 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 348 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
| 349 } | 349 } |
| 350 | 350 |
| 351 } // namespace gpu | 351 } // namespace gpu |
| OLD | NEW |