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

Side by Side Diff: content/common/gpu/image_transport_surface_overlay_mac.mm

Issue 1830513003: Move AcceleratedSurfaceBuffersSwappedParams to content/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed piman's comment Created 4 years, 9 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 "content/common/gpu/image_transport_surface_overlay_mac.h" 5 #include "content/common/gpu/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 "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
28 #include "content/common/gpu/buffer_presented_params_mac.h" 27 #include "content/common/gpu/buffer_presented_params_mac.h"
29 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h" 28 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h"
30 #include "content/common/gpu/ca_layer_tree_mac.h" 29 #include "content/common/gpu/ca_layer_tree_mac.h"
31 #include "content/common/gpu/gpu_channel_manager.h" 30 #include "content/common/gpu/gpu_channel_manager.h"
32 #include "content/common/gpu/gpu_channel_manager_delegate.h" 31 #include "content/common/gpu/gpu_channel_manager_delegate.h"
33 #include "ui/accelerated_widget_mac/io_surface_context.h" 32 #include "ui/accelerated_widget_mac/io_surface_context.h"
34 #include "ui/base/cocoa/animation_utils.h" 33 #include "ui/base/cocoa/animation_utils.h"
35 #include "ui/base/cocoa/remote_layer_api.h" 34 #include "ui/base/cocoa/remote_layer_api.h"
36 #include "ui/gfx/geometry/rect_conversions.h" 35 #include "ui/gfx/geometry/rect_conversions.h"
37 #include "ui/gfx/transform.h" 36 #include "ui/gfx/transform.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 191
193 // Compute |vsync_timebase_| to be the first vsync after time zero. 192 // Compute |vsync_timebase_| to be the first vsync after time zero.
194 if (vsync_parameters_valid_) { 193 if (vsync_parameters_valid_) {
195 vsync_timebase_ -= 194 vsync_timebase_ -=
196 vsync_interval_ * 195 vsync_interval_ *
197 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); 196 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_);
198 } 197 }
199 } 198 }
200 199
201 void ImageTransportSurfaceOverlayMac::SendAcceleratedSurfaceBuffersSwapped( 200 void ImageTransportSurfaceOverlayMac::SendAcceleratedSurfaceBuffersSwapped(
202 AcceleratedSurfaceBuffersSwappedParams params) { 201 int32_t surface_id,
202 CAContextID ca_context_id,
203 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface,
204 const gfx::Size& size,
205 float scale_factor,
206 std::vector<ui::LatencyInfo> latency_info) {
203 // TRACE_EVENT for gpu tests: 207 // TRACE_EVENT for gpu tests:
204 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD, 208 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
205 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 209 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
206 "width", params.size.width()); 210 "width", size.width());
207 // On mac, handle_ is a surface id. See 211 // On mac, handle_ is a surface id. See
208 // GpuProcessTransportFactory::CreatePerCompositorData 212 // GpuProcessTransportFactory::CreatePerCompositorData
209 params.surface_id = handle_; 213 manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(
210 manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(params); 214 surface_id, ca_context_id, io_surface, size, scale_factor,
215 std::move(latency_info));
211 } 216 }
212 217
213 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( 218 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
214 const gfx::Rect& pixel_damage_rect) { 219 const gfx::Rect& pixel_damage_rect) {
215 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); 220 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
216 221
217 // Use the same concept of 'now' for the entire function. The duration of 222 // Use the same concept of 'now' for the entire function. The duration of
218 // this function only affect the result if this function lasts across a vsync 223 // this function only affect the result if this function lasts across a vsync
219 // boundary, in which case smooth animation is out the window anyway. 224 // boundary, in which case smooth animation is out the window anyway.
220 const base::TimeTicks now = base::TimeTicks::Now(); 225 const base::TimeTicks now = base::TimeTicks::Now();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 base::TimeTicks swap_time = base::TimeTicks::Now(); 358 base::TimeTicks swap_time = base::TimeTicks::Now();
354 for (auto latency_info : swap->latency_info) { 359 for (auto latency_info : swap->latency_info) {
355 latency_info.AddLatencyNumberWithTimestamp( 360 latency_info.AddLatencyNumberWithTimestamp(
356 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); 361 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1);
357 latency_info.AddLatencyNumberWithTimestamp( 362 latency_info.AddLatencyNumberWithTimestamp(
358 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, 363 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0,
359 swap_time, 1); 364 swap_time, 1);
360 } 365 }
361 366
362 // Send acknowledgement to the browser. 367 // Send acknowledgement to the browser.
363 AcceleratedSurfaceBuffersSwappedParams params; 368 CAContextID ca_context_id = 0;
369 gfx::ScopedRefCountedIOSurfaceMachPort io_surface;
364 if (use_remote_layer_api_) { 370 if (use_remote_layer_api_) {
365 params.ca_context_id = [ca_context_ contextId]; 371 ca_context_id = [ca_context_ contextId];
366 } else if (current_partial_damage_tree_) { 372 } else if (current_partial_damage_tree_) {
367 params.io_surface.reset(IOSurfaceCreateMachPort( 373 io_surface.reset(IOSurfaceCreateMachPort(
368 current_partial_damage_tree_->RootLayerIOSurface())); 374 current_partial_damage_tree_->RootLayerIOSurface()));
369 } 375 }
370 params.size = swap->pixel_size; 376 gfx::Size size = swap->pixel_size;
371 params.scale_factor = swap->scale_factor; 377 float scale_factor = swap->scale_factor;
372 params.latency_info.swap(swap->latency_info); 378 std::vector<ui::LatencyInfo> latency_info;
373 SendAcceleratedSurfaceBuffersSwapped(params); 379 latency_info.swap(swap->latency_info);
380 SendAcceleratedSurfaceBuffersSwapped(handle_, ca_context_id, io_surface, size,
381 scale_factor, std::move(latency_info));
374 382
375 // Remove this from the queue, and reset any callback timers. 383 // Remove this from the queue, and reset any callback timers.
376 pending_swaps_.pop_front(); 384 pending_swaps_.pop_front();
377 } 385 }
378 386
379 void ImageTransportSurfaceOverlayMac::DisplayAndClearAllPendingSwaps() { 387 void ImageTransportSurfaceOverlayMac::DisplayAndClearAllPendingSwaps() {
380 TRACE_EVENT0("gpu", 388 TRACE_EVENT0("gpu",
381 "ImageTransportSurfaceOverlayMac::DisplayAndClearAllPendingSwaps"); 389 "ImageTransportSurfaceOverlayMac::DisplayAndClearAllPendingSwaps");
382 while (!pending_swaps_.empty()) 390 while (!pending_swaps_.empty())
383 DisplayFirstPendingSwapImmediately(); 391 DisplayFirstPendingSwapImmediately();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 // Compute the previous vsync time. 553 // Compute the previous vsync time.
546 base::TimeTicks previous_vsync = 554 base::TimeTicks previous_vsync =
547 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + 555 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) +
548 vsync_timebase_; 556 vsync_timebase_;
549 557
550 // Return |interval_fraction| through the next vsync. 558 // Return |interval_fraction| through the next vsync.
551 return previous_vsync + (1 + interval_fraction) * vsync_interval_; 559 return previous_vsync + (1 + interval_fraction) * vsync_interval_;
552 } 560 }
553 561
554 } // namespace content 562 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_overlay_mac.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698