Commit 7ecbfa31 authored by ccameron's avatar ccameron Committed by Commit bot

Mac: Add more trace events for CAOpenGLLayers

There exists lots of tracing for the old CAOpenGLLayer path in
ui::IOSurfaceLayerHelper. The new path doesn't have this tracing.

This adds tracing for the swap state (this is the pseudo-thread
counter corresponding to PendingSwapAck in ui::IOSurfaceLayerHelper,
along with trace events for the important functions related to swaps
on Mac.

BUG=487882

Review URL: https://codereview.chromium.org/1137093003

Cr-Commit-Position: refs/heads/master@{#329878}
parent dc5cefc1
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/mac/sdk_forward_declarations.h" #include "base/mac/sdk_forward_declarations.h"
#include "base/trace_event/trace_event.h"
#include "ui/accelerated_widget_mac/surface_handle_types.h" #include "ui/accelerated_widget_mac/surface_handle_types.h"
#include "ui/base/cocoa/animation_utils.h" #include "ui/base/cocoa/animation_utils.h"
#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/geometry/size_conversions.h"
...@@ -297,8 +298,13 @@ void CALayerStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size, ...@@ -297,8 +298,13 @@ void CALayerStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size,
} }
void CALayerStorageProvider::SwapBuffers() { void CALayerStorageProvider::SwapBuffers() {
TRACE_EVENT0("gpu", "CALayerStorageProvider::SwapBuffers");
DCHECK(!has_pending_draw_); DCHECK(!has_pending_draw_);
// A trace value of 2 indicates that there is a pending swap ack. See
// LayerCanDraw for other value meanings.
TRACE_COUNTER_ID1("gpu", "CALayerPendingSwap", this, 2);
// Recreate the CALayer on the new GPU if a GPU switch has occurred. Note // Recreate the CALayer on the new GPU if a GPU switch has occurred. Note
// that the CAContext will retain a reference to the old CALayer until the // that the CAContext will retain a reference to the old CALayer until the
// call to -[CAContext setLayer:] replaces the old CALayer with the new one. // call to -[CAContext setLayer:] replaces the old CALayer with the new one.
...@@ -416,6 +422,7 @@ void CALayerStorageProvider::DiscardBackbuffer() { ...@@ -416,6 +422,7 @@ void CALayerStorageProvider::DiscardBackbuffer() {
void CALayerStorageProvider::SwapBuffersAckedByBrowser( void CALayerStorageProvider::SwapBuffersAckedByBrowser(
bool disable_throttling) { bool disable_throttling) {
TRACE_EVENT0("gpu", "CALayerStorageProvider::SwapBuffersAckedByBrowser");
throttling_disabled_ = disable_throttling; throttling_disabled_ = disable_throttling;
if (!previously_discarded_contexts_.empty()) if (!previously_discarded_contexts_.empty())
previously_discarded_contexts_.pop_front(); previously_discarded_contexts_.pop_front();
...@@ -430,6 +437,24 @@ base::Closure CALayerStorageProvider::LayerShareGroupContextDirtiedCallback() { ...@@ -430,6 +437,24 @@ base::Closure CALayerStorageProvider::LayerShareGroupContextDirtiedCallback() {
} }
bool CALayerStorageProvider::LayerCanDraw() { bool CALayerStorageProvider::LayerCanDraw() {
TRACE_EVENT0("gpu", "CALayerStorageProvider::LayerCanDraw");
// This tracing would be more natural to do with a pseudo-thread for each
// layer, rather than a counter.
// http://crbug.com/366300
if (has_pending_draw_) {
// If there is a draw pending then increase the signal from 2 to 3, to
// indicate that there is a swap pending, and CoreAnimation has asked to
// draw it.
TRACE_COUNTER_ID1("gpu", "CALayerPendingSwap", this, 3);
} else {
// If there is not a draw pending, then give an instantaneous blip up from
// 0 to 1, indicating that CoreAnimation was ready to draw a frame but we
// were not (or didn't have new content to draw).
TRACE_COUNTER_ID1("gpu", "CALayerPendingSwap", this, 1);
TRACE_COUNTER_ID1("gpu", "CALayerPendingSwap", this, 0);
}
if (has_pending_draw_) { if (has_pending_draw_) {
can_draw_returned_false_count_ = 0; can_draw_returned_false_count_ = 0;
return true; return true;
...@@ -450,6 +475,7 @@ bool CALayerStorageProvider::LayerCanDraw() { ...@@ -450,6 +475,7 @@ bool CALayerStorageProvider::LayerCanDraw() {
} }
void CALayerStorageProvider::LayerDoDraw() { void CALayerStorageProvider::LayerDoDraw() {
TRACE_EVENT0("gpu", "CALayerStorageProvider::LayerDoDraw");
if (gfx::GetGLImplementation() == if (gfx::GetGLImplementation() ==
gfx::kGLImplementationDesktopGLCoreProfile) { gfx::kGLImplementationDesktopGLCoreProfile) {
glClearColor(1, 0, 1, 1); glClearColor(1, 0, 1, 1);
...@@ -550,6 +576,9 @@ void CALayerStorageProvider::UnblockBrowserIfNeeded() { ...@@ -550,6 +576,9 @@ void CALayerStorageProvider::UnblockBrowserIfNeeded() {
ui::SurfaceHandleFromCAContextID([context_ contextId]), ui::SurfaceHandleFromCAContextID([context_ contextId]),
fbo_pixel_size_, fbo_pixel_size_,
fbo_scale_factor_); fbo_scale_factor_);
// A trace value of 0 indicates that there is no longer a pending swap ack.
TRACE_COUNTER_ID1("gpu", "CALayerPendingSwap", this, 0);
} }
} // namespace content } // namespace content
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "content/common/gpu/image_transport_surface_fbo_mac.h" #include "content/common/gpu/image_transport_surface_fbo_mac.h"
#include "base/trace_event/trace_event.h"
#include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/image_transport_surface_calayer_mac.h" #include "content/common/gpu/image_transport_surface_calayer_mac.h"
#include "content/common/gpu/image_transport_surface_iosurface_mac.h" #include "content/common/gpu/image_transport_surface_iosurface_mac.h"
...@@ -169,6 +170,7 @@ void ImageTransportSurfaceFBO::AdjustBufferAllocation() { ...@@ -169,6 +170,7 @@ void ImageTransportSurfaceFBO::AdjustBufferAllocation() {
} }
bool ImageTransportSurfaceFBO::SwapBuffers() { bool ImageTransportSurfaceFBO::SwapBuffers() {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers");
return SwapBuffersInternal(); return SwapBuffersInternal();
} }
...@@ -191,6 +193,7 @@ bool ImageTransportSurfaceFBO::SwapBuffersInternal() { ...@@ -191,6 +193,7 @@ bool ImageTransportSurfaceFBO::SwapBuffersInternal() {
void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle, void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle,
const gfx::Size pixel_size, const gfx::Size pixel_size,
float scale_factor) { float scale_factor) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SendSwapBuffers");
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = surface_handle; params.surface_handle = surface_handle;
params.size = pixel_size; params.size = pixel_size;
...@@ -207,6 +210,7 @@ void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { ...@@ -207,6 +210,7 @@ void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) {
bool ImageTransportSurfaceFBO::PostSubBuffer( bool ImageTransportSurfaceFBO::PostSubBuffer(
int x, int y, int width, int height) { int x, int y, int width, int height) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer");
return SwapBuffersInternal(); return SwapBuffersInternal();
} }
...@@ -228,6 +232,7 @@ void* ImageTransportSurfaceFBO::GetDisplay() { ...@@ -228,6 +232,7 @@ void* ImageTransportSurfaceFBO::GetDisplay() {
void ImageTransportSurfaceFBO::OnBufferPresented( void ImageTransportSurfaceFBO::OnBufferPresented(
const AcceleratedSurfaceMsg_BufferPresented_Params& params) { const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::OnBufferPresented");
SetRendererID(params.renderer_id); SetRendererID(params.renderer_id);
storage_provider_->SwapBuffersAckedByBrowser(params.disable_throttling); storage_provider_->SwapBuffersAckedByBrowser(params.disable_throttling);
} }
......
...@@ -80,16 +80,18 @@ bool IOSurfaceLayerHelper::CanDraw() { ...@@ -80,16 +80,18 @@ bool IOSurfaceLayerHelper::CanDraw() {
[layer_ setAsynchronous:NO]; [layer_ setAsynchronous:NO];
} }
// Add an instantaneous blip to the PendingSwapAck state to indicate if (needs_display_) {
// that CoreAnimation asked if a frame is ready. A blip up to to 3 (usually // If there is a draw pending then increase the signal from 2 to 3, to
// from 2, indicating that a swap ack is pending) indicates that we // indicate that we are in the state where there is a swap pending and
// requested a draw. A blip up to 1 (usually from 0, indicating there is no // CoreAnimation has been committed to draw it.
// pending swap ack) indicates that we did not request a draw. This would TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 3);
// be more natural to do with a tracing pseudo-thread } else {
// http://crbug.com/366300 // If there is not a draw pending, then give an instantaneous blip up from
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, needs_display_ ? 3 : 1); // 0 to 1, indicating that CoreAnimation was ready to draw a frame but we
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, // were not (or didn't have new content to draw).
has_pending_frame_ ? 2 : 0); TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 1);
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 0);
}
return needs_display_; return needs_display_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment