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

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

Issue 2241003002: Mac: Loosen CoreAnimation blacklist on 10.10 and histograms to watch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix var name Created 4 years, 4 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
« no previous file with comments | « gpu/config/gpu_driver_bug_list_json.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/metrics/histogram_macros.h"
25 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
26 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
27 #include "gpu/ipc/common/gpu_messages.h" 28 #include "gpu/ipc/common/gpu_messages.h"
28 #include "gpu/ipc/service/gpu_channel_manager.h" 29 #include "gpu/ipc/service/gpu_channel_manager.h"
29 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 30 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
30 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" 31 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h"
31 #include "ui/accelerated_widget_mac/io_surface_context.h" 32 #include "ui/accelerated_widget_mac/io_surface_context.h"
32 #include "ui/base/cocoa/animation_utils.h" 33 #include "ui/base/cocoa/animation_utils.h"
33 #include "ui/base/cocoa/remote_layer_api.h" 34 #include "ui/base/cocoa/remote_layer_api.h"
34 #include "ui/gfx/geometry/rect_conversions.h" 35 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 ca_layer_in_use_queries_.clear(); 177 ca_layer_in_use_queries_.clear();
177 178
178 stub_->SendSwapBuffersCompleted(params); 179 stub_->SendSwapBuffersCompleted(params);
179 } 180 }
180 181
181 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal( 182 gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
182 const gfx::Rect& pixel_damage_rect) { 183 const gfx::Rect& pixel_damage_rect) {
183 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal"); 184 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
184 185
186 base::TimeTicks before_flush_time;
187 base::TimeTicks after_flush_before_commit_time;
188
185 // If supported, use GLFence to ensure that we haven't gotten more than one 189 // If supported, use GLFence to ensure that we haven't gotten more than one
186 // frame ahead of GL. 190 // frame ahead of GL.
187 if (gl::GLFence::IsSupported()) { 191 if (gl::GLFence::IsSupported()) {
188 gl::ScopedSetGLToRealGLApi scoped_set_gl_api; 192 gl::ScopedSetGLToRealGLApi scoped_set_gl_api;
189 CheckGLErrors("Before fence/flush"); 193 CheckGLErrors("Before fence/flush");
190 194
191 // If we have gotten more than one frame ahead of GL, wait for the previous 195 // If we have gotten more than one frame ahead of GL, wait for the previous
192 // frame to complete. 196 // frame to complete.
193 if (previous_frame_fence_) { 197 if (previous_frame_fence_) {
194 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::ClientWait"); 198 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::ClientWait");
(...skipping 13 matching lines...) Expand all
208 while (!previous_frame_fence_->HasCompleted() && timeout_msec > 0) { 212 while (!previous_frame_fence_->HasCompleted() && timeout_msec > 0) {
209 --timeout_msec; 213 --timeout_msec;
210 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 214 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
211 } 215 }
212 if (!previous_frame_fence_->HasCompleted()) { 216 if (!previous_frame_fence_->HasCompleted()) {
213 // We timed out waiting for the above fence, just issue a glFinish. 217 // We timed out waiting for the above fence, just issue a glFinish.
214 glFinish(); 218 glFinish();
215 } 219 }
216 } 220 }
217 221
222 before_flush_time = base::TimeTicks::Now();
223
218 // Create a fence for the current frame's work and save the context. 224 // Create a fence for the current frame's work and save the context.
219 previous_frame_fence_.reset(gl::GLFence::Create()); 225 previous_frame_fence_.reset(gl::GLFence::Create());
220 fence_context_obj_.reset(CGLGetCurrentContext(), 226 fence_context_obj_.reset(CGLGetCurrentContext(),
221 base::scoped_policy::RETAIN); 227 base::scoped_policy::RETAIN);
222 228
223 // A glFlush is necessary to ensure correct content appears. 229 // A glFlush is necessary to ensure correct content appears.
224 glFlush(); 230 glFlush();
231 CheckGLErrors("After fence/flush");
225 232
226 CheckGLErrors("After fence/flush"); 233 after_flush_before_commit_time = base::TimeTicks::Now();
234 UMA_HISTOGRAM_TIMES("GPU.IOSurface.GLFlushTime",
235 after_flush_before_commit_time - before_flush_time);
227 } else { 236 } else {
228 // GLFence isn't supported - issue a glFinish on each frame to ensure 237 // GLFence isn't supported - issue a glFinish on each frame to ensure
229 // there is backpressure from GL. 238 // there is backpressure from GL.
230 gl::ScopedSetGLToRealGLApi scoped_set_gl_api; 239 gl::ScopedSetGLToRealGLApi scoped_set_gl_api;
231 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::glFinish"); 240 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::glFinish");
232 CheckGLErrors("Before finish"); 241 CheckGLErrors("Before finish");
233 glFinish(); 242 glFinish();
234 CheckGLErrors("After finish"); 243 CheckGLErrors("After finish");
244 after_flush_before_commit_time = base::TimeTicks::Now();
235 } 245 }
236 246
237 base::TimeTicks finish_time = base::TimeTicks::Now();
238
239 bool fullscreen_low_power_layer_valid = false; 247 bool fullscreen_low_power_layer_valid = false;
240 ca_layer_tree_coordinator_->CommitPendingTreesToCA( 248 ca_layer_tree_coordinator_->CommitPendingTreesToCA(
241 pixel_damage_rect, &fullscreen_low_power_layer_valid); 249 pixel_damage_rect, &fullscreen_low_power_layer_valid);
242 // TODO(ccameron): Plumb the fullscreen low power layer through to the 250
243 // appropriate window. 251 base::TimeTicks after_transaction_time = base::TimeTicks::Now();
252 UMA_HISTOGRAM_TIMES("GPU.IOSurface.CATransactionTime",
253 after_transaction_time - after_flush_before_commit_time);
244 254
245 // Update the latency info to reflect the swap time. 255 // Update the latency info to reflect the swap time.
246 for (auto& latency_info : latency_info_) { 256 for (auto& latency_info : latency_info_) {
247 latency_info.AddLatencyNumberWithTimestamp( 257 latency_info.AddLatencyNumberWithTimestamp(
248 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, finish_time, 1); 258 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0,
259 after_flush_before_commit_time, 1);
249 latency_info.AddLatencyNumberWithTimestamp( 260 latency_info.AddLatencyNumberWithTimestamp(
250 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, 261 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0,
251 finish_time, 1); 262 after_flush_before_commit_time, 1);
252 } 263 }
253 264
254 // Send acknowledgement to the browser. 265 // Send acknowledgement to the browser.
255 CAContextID ca_context_id = 0; 266 CAContextID ca_context_id = 0;
256 CAContextID fullscreen_low_power_ca_context_id = 0; 267 CAContextID fullscreen_low_power_ca_context_id = 0;
257 gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port; 268 gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port;
258 if (use_remote_layer_api_) { 269 if (use_remote_layer_api_) {
259 ca_context_id = [ca_context_ contextId]; 270 ca_context_id = [ca_context_ contextId];
260 fullscreen_low_power_ca_context_id = 271 fullscreen_low_power_ca_context_id =
261 [fullscreen_low_power_ca_context_ contextId]; 272 [fullscreen_low_power_ca_context_ contextId];
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 390 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
380 391
381 // Post a task holding a reference to the new GL context. The reason for 392 // Post a task holding a reference to the new GL context. The reason for
382 // this is to avoid creating-then-destroying the context for every image 393 // this is to avoid creating-then-destroying the context for every image
383 // transport surface that is observing the GPU switch. 394 // transport surface that is observing the GPU switch.
384 base::ThreadTaskRunnerHandle::Get()->PostTask( 395 base::ThreadTaskRunnerHandle::Get()->PostTask(
385 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 396 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
386 } 397 }
387 398
388 } // namespace gpu 399 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/config/gpu_driver_bug_list_json.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698