| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli
neAgent> timelineAgent, InspectorClient *client) | 151 TimelineTraceEventProcessor::TimelineTraceEventProcessor(WeakPtr<InspectorTimeli
neAgent> timelineAgent, InspectorClient *client) |
| 152 : m_timelineAgent(timelineAgent) | 152 : m_timelineAgent(timelineAgent) |
| 153 , m_timeConverter(timelineAgent.get()->timeConverter()) | 153 , m_timeConverter(timelineAgent.get()->timeConverter()) |
| 154 , m_inspectorClient(client) | 154 , m_inspectorClient(client) |
| 155 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page(
))) | 155 , m_pageId(reinterpret_cast<unsigned long long>(m_timelineAgent.get()->page(
))) |
| 156 , m_layerTreeId(m_timelineAgent.get()->layerTreeId()) | 156 , m_layerTreeId(m_timelineAgent.get()->layerTreeId()) |
| 157 , m_lastEventProcessingTime(0) | 157 , m_lastEventProcessingTime(0) |
| 158 , m_processEventsTaskInFlight(false) | 158 , m_processEventsTaskInFlight(false) |
| 159 , m_layerId(0) | |
| 160 , m_paintSetupStart(0) | 159 , m_paintSetupStart(0) |
| 161 , m_paintSetupEnd(0) | 160 , m_paintSetupEnd(0) |
| 162 { | 161 { |
| 163 registerHandler(InstrumentationEvents::BeginFrame, TRACE_EVENT_PHASE_INSTANT
, &TimelineTraceEventProcessor::onBeginFrame); | 162 registerHandler(InstrumentationEvents::BeginFrame, TRACE_EVENT_PHASE_INSTANT
, &TimelineTraceEventProcessor::onBeginFrame); |
| 164 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onUpdateLayerBegin); | |
| 165 registerHandler(InstrumentationEvents::UpdateLayer, TRACE_EVENT_PHASE_END, &
TimelineTraceEventProcessor::onUpdateLayerEnd); | |
| 166 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onPaintLayerBegin); | |
| 167 registerHandler(InstrumentationEvents::PaintLayer, TRACE_EVENT_PHASE_END, &T
imelineTraceEventProcessor::onPaintLayerEnd); | |
| 168 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onPaintSetupBegin); | 163 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onPaintSetupBegin); |
| 169 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_END, &T
imelineTraceEventProcessor::onPaintSetupEnd); | 164 registerHandler(InstrumentationEvents::PaintSetup, TRACE_EVENT_PHASE_END, &T
imelineTraceEventProcessor::onPaintSetupEnd); |
| 170 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onRasterTaskBegin); | 165 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_BEGIN,
&TimelineTraceEventProcessor::onRasterTaskBegin); |
| 171 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_END, &T
imelineTraceEventProcessor::onRasterTaskEnd); | 166 registerHandler(InstrumentationEvents::RasterTask, TRACE_EVENT_PHASE_END, &T
imelineTraceEventProcessor::onRasterTaskEnd); |
| 172 registerHandler(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_DELETE_OBJEC
T, &TimelineTraceEventProcessor::onLayerDeleted); | 167 registerHandler(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_DELETE_OBJEC
T, &TimelineTraceEventProcessor::onLayerDeleted); |
| 173 registerHandler(InstrumentationEvents::Paint, TRACE_EVENT_PHASE_INSTANT, &Ti
melineTraceEventProcessor::onPaint); | 168 registerHandler(InstrumentationEvents::Paint, TRACE_EVENT_PHASE_INSTANT, &Ti
melineTraceEventProcessor::onPaint); |
| 174 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE
_BEGIN, &TimelineTraceEventProcessor::onImageDecodeBegin); | 169 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE
_BEGIN, &TimelineTraceEventProcessor::onImageDecodeBegin); |
| 175 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE
_END, &TimelineTraceEventProcessor::onImageDecodeEnd); | 170 registerHandler(PlatformInstrumentation::ImageDecodeEvent, TRACE_EVENT_PHASE
_END, &TimelineTraceEventProcessor::onImageDecodeEnd); |
| 176 registerHandler(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_
PHASE_INSTANT, &TimelineTraceEventProcessor::onDrawLazyPixelRef); | 171 registerHandler(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_
PHASE_INSTANT, &TimelineTraceEventProcessor::onDrawLazyPixelRef); |
| 177 registerHandler(PlatformInstrumentation::DecodeLazyPixelRefEvent, TRACE_EVEN
T_PHASE_BEGIN, &TimelineTraceEventProcessor::onDecodeLazyPixelRefBegin); | 172 registerHandler(PlatformInstrumentation::DecodeLazyPixelRefEvent, TRACE_EVEN
T_PHASE_BEGIN, &TimelineTraceEventProcessor::onDecodeLazyPixelRefBegin); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 (this->*(it->value))(event); | 234 (this->*(it->value))(event); |
| 240 } | 235 } |
| 241 | 236 |
| 242 void TimelineTraceEventProcessor::onBeginFrame(const TraceEvent&) | 237 void TimelineTraceEventProcessor::onBeginFrame(const TraceEvent&) |
| 243 { | 238 { |
| 244 // We don't handle BeginFrame explicitly now, but it still implicitly helps | 239 // We don't handle BeginFrame explicitly now, but it still implicitly helps |
| 245 // to pump the background events regularly (as opposed to posting a task), | 240 // to pump the background events regularly (as opposed to posting a task), |
| 246 // as this is only done upon events we recognize. | 241 // as this is only done upon events we recognize. |
| 247 } | 242 } |
| 248 | 243 |
| 249 void TimelineTraceEventProcessor::onUpdateLayerBegin(const TraceEvent& event) | |
| 250 { | |
| 251 unsigned long long layerTreeId = event.asUInt(InstrumentationEventArguments:
:LayerTreeId); | |
| 252 if (layerTreeId != static_cast<unsigned long long>(m_layerTreeId)) | |
| 253 return; | |
| 254 m_layerId = event.asUInt(InstrumentationEventArguments::LayerId); | |
| 255 // We don't know the node yet. For content layers, the node will be updated | |
| 256 // by paint. For others, let it remain 0 -- we just need the fact that | |
| 257 // the layer belongs to the page (see cookie check). | |
| 258 m_layerToNodeMap.add(m_layerId, 0); | |
| 259 } | |
| 260 | |
| 261 void TimelineTraceEventProcessor::onUpdateLayerEnd(const TraceEvent& event) | |
| 262 { | |
| 263 m_layerId = 0; | |
| 264 } | |
| 265 | |
| 266 void TimelineTraceEventProcessor::onPaintLayerBegin(const TraceEvent& event) | |
| 267 { | |
| 268 m_layerId = event.asUInt(InstrumentationEventArguments::LayerId); | |
| 269 ASSERT(m_layerId); | |
| 270 ASSERT(!m_paintSetupStart); | |
| 271 } | |
| 272 | |
| 273 void TimelineTraceEventProcessor::onPaintLayerEnd(const TraceEvent& event) | |
| 274 { | |
| 275 m_layerId = 0; | |
| 276 } | |
| 277 | |
| 278 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) | 244 void TimelineTraceEventProcessor::onPaintSetupBegin(const TraceEvent& event) |
| 279 { | 245 { |
| 280 ASSERT(!m_paintSetupStart); | 246 ASSERT(!m_paintSetupStart); |
| 281 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); | 247 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti
mestamp()); |
| 282 } | 248 } |
| 283 | 249 |
| 284 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) | 250 void TimelineTraceEventProcessor::onPaintSetupEnd(const TraceEvent& event) |
| 285 { | 251 { |
| 286 ASSERT(m_paintSetupStart); | 252 ASSERT(m_paintSetupStart); |
| 287 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); | 253 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time
stamp()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 unsigned long long id = event.id(); | 321 unsigned long long id = event.id(); |
| 356 ASSERT(id); | 322 ASSERT(id); |
| 357 processBackgroundEvents(); | 323 processBackgroundEvents(); |
| 358 m_layerToNodeMap.remove(id); | 324 m_layerToNodeMap.remove(id); |
| 359 } | 325 } |
| 360 | 326 |
| 361 void TimelineTraceEventProcessor::onPaint(const TraceEvent& event) | 327 void TimelineTraceEventProcessor::onPaint(const TraceEvent& event) |
| 362 { | 328 { |
| 363 double paintSetupStart = m_paintSetupStart; | 329 double paintSetupStart = m_paintSetupStart; |
| 364 m_paintSetupStart = 0; | 330 m_paintSetupStart = 0; |
| 365 if (!m_layerId) | |
| 366 return; | |
| 367 unsigned long long pageId = event.asUInt(InstrumentationEventArguments::Page
Id); | 331 unsigned long long pageId = event.asUInt(InstrumentationEventArguments::Page
Id); |
| 368 if (pageId != m_pageId) | 332 if (pageId != m_pageId) |
| 369 return; | 333 return; |
| 370 long long nodeId = event.asInt(InstrumentationEventArguments::NodeId); | |
| 371 ASSERT(nodeId); | |
| 372 m_layerToNodeMap.set(m_layerId, nodeId); | |
| 373 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); | 334 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); |
| 374 if (timelineAgent && paintSetupStart) { | 335 if (!timelineAgent) |
| 375 RefPtr<JSONObject> paintSetupRecord = TimelineRecordFactory::createGener
icRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup); | 336 return; |
| 376 paintSetupRecord->setNumber("endTime", m_paintSetupEnd); | 337 if (int layerId = timelineAgent->layerBeingPainted()) { |
| 377 paintSetupRecord->setObject("data", TimelineRecordFactory::createLayerDa
ta(nodeId)); | 338 int nodeId = timelineAgent->nodeBeingPainted(); |
| 378 timelineAgent->addRecordToTimeline(paintSetupRecord); | 339 ASSERT(nodeId); |
| 340 m_layerToNodeMap.set(layerId, nodeId); |
| 341 if (paintSetupStart) { |
| 342 RefPtr<JSONObject> paintSetupRecord = TimelineRecordFactory::createG
enericRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup); |
| 343 paintSetupRecord->setNumber("endTime", m_paintSetupEnd); |
| 344 paintSetupRecord->setObject("data", TimelineRecordFactory::createLay
erData(nodeId)); |
| 345 timelineAgent->addRecordToTimeline(paintSetupRecord); |
| 346 } |
| 379 } | 347 } |
| 380 } | 348 } |
| 381 | 349 |
| 382 void TimelineTraceEventProcessor::onDecodeLazyPixelRefBegin(const TraceEvent& ev
ent) | 350 void TimelineTraceEventProcessor::onDecodeLazyPixelRefBegin(const TraceEvent& ev
ent) |
| 383 { | 351 { |
| 384 TimelineThreadState& state = threadState(event.threadIdentifier()); | 352 TimelineThreadState& state = threadState(event.threadIdentifier()); |
| 385 ASSERT(!state.decodedPixelRefId); | 353 ASSERT(!state.decodedPixelRefId); |
| 386 unsigned long long pixelRefId = event.asUInt(PlatformInstrumentation::LazyPi
xelRef); | 354 unsigned long long pixelRefId = event.asUInt(PlatformInstrumentation::LazyPi
xelRef); |
| 387 ASSERT(pixelRefId); | 355 ASSERT(pixelRefId); |
| 388 if (m_pixelRefToImageInfo.contains(pixelRefId)) | 356 if (m_pixelRefToImageInfo.contains(pixelRefId)) |
| 389 state.decodedPixelRefId = pixelRefId; | 357 state.decodedPixelRefId = pixelRefId; |
| 390 } | 358 } |
| 391 | 359 |
| 392 void TimelineTraceEventProcessor::onDecodeLazyPixelRefEnd(const TraceEvent& even
t) | 360 void TimelineTraceEventProcessor::onDecodeLazyPixelRefEnd(const TraceEvent& even
t) |
| 393 { | 361 { |
| 394 threadState(event.threadIdentifier()).decodedPixelRefId = 0; | 362 threadState(event.threadIdentifier()).decodedPixelRefId = 0; |
| 395 } | 363 } |
| 396 | 364 |
| 397 void TimelineTraceEventProcessor::onDrawLazyPixelRef(const TraceEvent& event) | 365 void TimelineTraceEventProcessor::onDrawLazyPixelRef(const TraceEvent& event) |
| 398 { | 366 { |
| 399 // Only track LazyPixelRefs created while we paint known layers | |
| 400 if (!m_layerId || !m_layerToNodeMap.contains(m_layerId)) | |
| 401 return; | |
| 402 unsigned long long pixelRefId = event.asUInt(PlatformInstrumentation::LazyPi
xelRef); | 367 unsigned long long pixelRefId = event.asUInt(PlatformInstrumentation::LazyPi
xelRef); |
| 403 ASSERT(pixelRefId); | 368 ASSERT(pixelRefId); |
| 404 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); | 369 InspectorTimelineAgent* timelineAgent = m_timelineAgent.get(); |
| 405 if (!timelineAgent) | 370 if (!timelineAgent) |
| 406 return; | 371 return; |
| 407 const RenderImage* renderImage = timelineAgent->imageBeingPainted(); | 372 const RenderImage* renderImage = timelineAgent->imageBeingPainted(); |
| 408 if (!renderImage) | 373 if (!renderImage) |
| 409 return; | 374 return; |
| 410 int nodeId = timelineAgent->nodeId(renderImage->generatingNode()); | 375 int nodeId = timelineAgent->nodeId(renderImage->generatingNode()); |
| 411 String url; | 376 String url; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 413 } |
| 449 | 414 |
| 450 void TimelineTraceEventProcessor::processBackgroundEventsTask() | 415 void TimelineTraceEventProcessor::processBackgroundEventsTask() |
| 451 { | 416 { |
| 452 m_processEventsTaskInFlight = false; | 417 m_processEventsTaskInFlight = false; |
| 453 processBackgroundEvents(); | 418 processBackgroundEvents(); |
| 454 } | 419 } |
| 455 | 420 |
| 456 } // namespace WebCore | 421 } // namespace WebCore |
| 457 | 422 |
| OLD | NEW |