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 @@
#include "base/command_line.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/base/cocoa/animation_utils.h"
#include "ui/gfx/geometry/size_conversions.h"
......@@ -297,8 +298,13 @@ void CALayerStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size,
}
void CALayerStorageProvider::SwapBuffers() {
TRACE_EVENT0("gpu", "CALayerStorageProvider::SwapBuffers");
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
// 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.
......@@ -416,6 +422,7 @@ void CALayerStorageProvider::DiscardBackbuffer() {
void CALayerStorageProvider::SwapBuffersAckedByBrowser(
bool disable_throttling) {
TRACE_EVENT0("gpu", "CALayerStorageProvider::SwapBuffersAckedByBrowser");
throttling_disabled_ = disable_throttling;
if (!previously_discarded_contexts_.empty())
previously_discarded_contexts_.pop_front();
......@@ -430,6 +437,24 @@ base::Closure CALayerStorageProvider::LayerShareGroupContextDirtiedCallback() {
}
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_) {
can_draw_returned_false_count_ = 0;
return true;
......@@ -450,6 +475,7 @@ bool CALayerStorageProvider::LayerCanDraw() {
}
void CALayerStorageProvider::LayerDoDraw() {
TRACE_EVENT0("gpu", "CALayerStorageProvider::LayerDoDraw");
if (gfx::GetGLImplementation() ==
gfx::kGLImplementationDesktopGLCoreProfile) {
glClearColor(1, 0, 1, 1);
......@@ -550,6 +576,9 @@ void CALayerStorageProvider::UnblockBrowserIfNeeded() {
ui::SurfaceHandleFromCAContextID([context_ contextId]),
fbo_pixel_size_,
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
......@@ -4,6 +4,7 @@
#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/image_transport_surface_calayer_mac.h"
#include "content/common/gpu/image_transport_surface_iosurface_mac.h"
......@@ -169,6 +170,7 @@ void ImageTransportSurfaceFBO::AdjustBufferAllocation() {
}
bool ImageTransportSurfaceFBO::SwapBuffers() {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SwapBuffers");
return SwapBuffersInternal();
}
......@@ -191,6 +193,7 @@ bool ImageTransportSurfaceFBO::SwapBuffersInternal() {
void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle,
const gfx::Size pixel_size,
float scale_factor) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::SendSwapBuffers");
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = surface_handle;
params.size = pixel_size;
......@@ -207,6 +210,7 @@ void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) {
bool ImageTransportSurfaceFBO::PostSubBuffer(
int x, int y, int width, int height) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::PostSubBuffer");
return SwapBuffersInternal();
}
......@@ -228,6 +232,7 @@ void* ImageTransportSurfaceFBO::GetDisplay() {
void ImageTransportSurfaceFBO::OnBufferPresented(
const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceFBO::OnBufferPresented");
SetRendererID(params.renderer_id);
storage_provider_->SwapBuffersAckedByBrowser(params.disable_throttling);
}
......
......@@ -80,16 +80,18 @@ bool IOSurfaceLayerHelper::CanDraw() {
[layer_ setAsynchronous:NO];
}
// Add an instantaneous blip to the PendingSwapAck state to indicate
// that CoreAnimation asked if a frame is ready. A blip up to to 3 (usually
// from 2, indicating that a swap ack is pending) indicates that we
// requested a draw. A blip up to 1 (usually from 0, indicating there is no
// pending swap ack) indicates that we did not request a draw. This would
// be more natural to do with a tracing pseudo-thread
// http://crbug.com/366300
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, needs_display_ ? 3 : 1);
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this,
has_pending_frame_ ? 2 : 0);
if (needs_display_) {
// If there is a draw pending then increase the signal from 2 to 3, to
// indicate that we are in the state where there is a swap pending and
// CoreAnimation has been committed to draw it.
TRACE_COUNTER_ID1("browser", "PendingSwapAck", 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("browser", "PendingSwapAck", this, 1);
TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 0);
}
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