Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: gpu/ipc/service/image_transport_surface_overlay_mac.mm

Issue 2006923006: Move all CARendererLayerTree parameters to separate struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
36 #include "ui/gfx/transform.h" 35 #include "ui/gfx/transform.h"
36 #include "ui/gl/ca_renderer_layer_params.h"
37 #include "ui/gl/gl_context.h" 37 #include "ui/gl/gl_context.h"
38 #include "ui/gl/gl_fence.h" 38 #include "ui/gl/gl_fence.h"
39 #include "ui/gl/gl_image_io_surface.h" 39 #include "ui/gl/gl_image_io_surface.h"
40 #include "ui/gl/gpu_switching_manager.h" 40 #include "ui/gl/gpu_switching_manager.h"
41 #include "ui/gl/scoped_api.h" 41 #include "ui/gl/scoped_api.h"
42 #include "ui/gl/scoped_cgl.h" 42 #include "ui/gl/scoped_cgl.h"
43 43
44 namespace { 44 namespace {
45 45
46 void CheckGLErrors(const char* msg) { 46 void CheckGLErrors(const char* msg) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 gl::GLImageIOSurface::FromGLImage(image); 324 gl::GLImageIOSurface::FromGLImage(image);
325 if (!io_surface_image) { 325 if (!io_surface_image) {
326 DLOG(ERROR) << "Not an IOSurface image."; 326 DLOG(ERROR) << "Not an IOSurface image.";
327 return false; 327 return false;
328 } 328 }
329 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer( 329 return ca_layer_tree_coordinator_->SetPendingGLRendererBackbuffer(
330 io_surface_image->io_surface()); 330 io_surface_image->io_surface());
331 } 331 }
332 332
333 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer( 333 bool ImageTransportSurfaceOverlayMac::ScheduleCALayer(
334 gl::GLImage* contents_image, 334 const ui::CARendererLayerParams& params) {
335 const gfx::RectF& contents_rect, 335 gl::GLImageIOSurface* io_surface_image =
336 float opacity, 336 gl::GLImageIOSurface::FromGLImage(params.image);
337 unsigned background_color, 337 if (!io_surface_image) {
338 unsigned edge_aa_mask, 338 DLOG(ERROR) << "Cannot schedule CALayer with non-IOSurface GLImage";
339 const gfx::RectF& rect, 339 return false;
340 bool is_clipped,
341 const gfx::RectF& clip_rect,
342 const gfx::Transform& transform,
343 int sorting_context_id,
344 unsigned filter) {
345 base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
346 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer;
347 if (contents_image) {
348 gl::GLImageIOSurface* io_surface_image =
349 gl::GLImageIOSurface::FromGLImage(contents_image);
350 if (!io_surface_image) {
351 DLOG(ERROR) << "Cannot schedule CALayer with non-IOSurface GLImage";
352 return false;
353 }
354 io_surface = io_surface_image->io_surface();
355 cv_pixel_buffer = io_surface_image->cv_pixel_buffer();
356 } 340 }
357 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree() 341 return ca_layer_tree_coordinator_->GetPendingCARendererLayerTree()
358 ->ScheduleCALayer(is_clipped, gfx::ToEnclosingRect(clip_rect), 342 ->ScheduleCALayer(params);
359 sorting_context_id, transform, io_surface,
360 cv_pixel_buffer, contents_rect,
361 gfx::ToEnclosingRect(rect), background_color,
362 edge_aa_mask, opacity, filter);
363 } 343 }
364 344
365 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery( 345 void ImageTransportSurfaceOverlayMac::ScheduleCALayerInUseQuery(
366 std::vector<CALayerInUseQuery> queries) { 346 std::vector<CALayerInUseQuery> queries) {
367 ca_layer_in_use_queries_.swap(queries); 347 ca_layer_in_use_queries_.swap(queries);
368 } 348 }
369 349
370 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { 350 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
371 return true; 351 return true;
372 } 352 }
(...skipping 23 matching lines...) Expand all
396 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 376 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
397 377
398 // Post a task holding a reference to the new GL context. The reason for 378 // Post a task holding a reference to the new GL context. The reason for
399 // this is to avoid creating-then-destroying the context for every image 379 // this is to avoid creating-then-destroying the context for every image
400 // transport surface that is observing the GPU switch. 380 // transport surface that is observing the GPU switch.
401 base::MessageLoop::current()->PostTask( 381 base::MessageLoop::current()->PostTask(
402 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 382 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
403 } 383 }
404 384
405 } // namespace gpu 385 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698