2017-10-27 23:10:06 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2010-09-03 20:10:45 +00:00
|
|
|
#include "Layers.h"
|
2020-11-23 16:09:05 +00:00
|
|
|
|
|
|
|
#include <inttypes.h> // for PRIu64
|
|
|
|
#include <stdio.h> // for stderr
|
|
|
|
#include <algorithm> // for max, min
|
|
|
|
#include <list> // for list
|
|
|
|
#include <set> // for set
|
|
|
|
#include <string> // for char_traits, string, basic_string
|
|
|
|
#include <type_traits> // for remove_reference<>::type
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "CompositableHost.h" // for CompositableHost
|
2021-10-18 23:11:30 +00:00
|
|
|
#include "LayerUserData.h" // for LayerUserData
|
2020-11-23 16:09:05 +00:00
|
|
|
#include "TreeTraversal.h" // for ForwardIterator, ForEachNode, DepthFirstSearch, TraversalFlag, TraversalFl...
|
|
|
|
#include "UnitTransforms.h" // for ViewAs, PixelCastJustification, PixelCastJustification::RenderTargetIsPare...
|
|
|
|
#include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController
|
|
|
|
#include "gfx2DGlue.h" // for ThebesMatrix, ToPoint, ThebesRect
|
|
|
|
#include "gfxEnv.h" // for gfxEnv
|
|
|
|
#include "gfxMatrix.h" // for gfxMatrix
|
|
|
|
#include "gfxUtils.h" // for gfxUtils, gfxUtils::sDumpPaintFile
|
|
|
|
#include "mozilla/ArrayIterator.h" // for ArrayIterator
|
2021-10-18 23:11:30 +00:00
|
|
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
2020-11-23 16:09:05 +00:00
|
|
|
#include "mozilla/Logging.h" // for LogLevel, LogLevel::Debug, MOZ_LOG_TEST
|
2021-11-08 23:59:35 +00:00
|
|
|
#include "mozilla/ProfilerMarkers.h" // for profiler_thread_is_being_profiled_for_markers, PROFILER_MARKER_TEXT
|
2020-11-23 16:09:05 +00:00
|
|
|
#include "mozilla/ScrollPositionUpdate.h" // for ScrollPositionUpdate
|
|
|
|
#include "mozilla/Telemetry.h" // for AccumulateTimeDelta
|
|
|
|
#include "mozilla/TelemetryHistogramEnums.h" // for KEYPRESS_PRESENT_LATENCY, SCROLL_PRESENT_LATENCY
|
|
|
|
#include "mozilla/ToString.h" // for ToString
|
|
|
|
#include "mozilla/gfx/2D.h" // for SourceSurface, DrawTarget, DataSourceSurface
|
|
|
|
#include "mozilla/gfx/BasePoint3D.h" // for BasePoint3D<>::(anonymous union)::(anonymous), BasePoint3D<>::(anonymous)
|
|
|
|
#include "mozilla/gfx/BaseRect.h" // for operator<<, BaseRect (ptr only)
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for operator<<, BaseSize<>::(anonymous union)::(anonymous), BaseSize<>::(anony...
|
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix, Matrix4x4Typed<>::(anonymous union)::(anonymous), Matri...
|
2021-08-26 04:59:57 +00:00
|
|
|
#include "mozilla/gfx/MatrixFwd.h" // for Float
|
|
|
|
#include "mozilla/gfx/Polygon.h" // for Polygon, PolygonTyped
|
|
|
|
#include "mozilla/layers/BSPTree.h" // for LayerPolygon, BSPTree
|
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
2020-11-23 16:09:05 +00:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for SpecificLayerAttributes, CompositorAnimations (ptr only), ContainerLayerAt...
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for EventRegions, operator<<, CompositionPayload, CSSTransformMatrix, MOZ_LAYE...
|
|
|
|
#include "nsBaseHashtable.h" // for nsBaseHashtable<>::Iterator, nsBaseHashtable<>::LookupResult
|
2021-09-04 09:38:27 +00:00
|
|
|
#include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
|
|
|
|
#include "nsPrintfCString.h" // for nsPrintfCString
|
|
|
|
#include "nsRegionFwd.h" // for IntRegion
|
|
|
|
#include "nsString.h" // for nsTSubstring
|
2012-08-21 04:06:46 +00:00
|
|
|
|
2020-11-23 16:21:38 +00:00
|
|
|
// Undo the damage done by mozzconf.h
|
|
|
|
#undef compress
|
|
|
|
#include "mozilla/Compression.h"
|
|
|
|
|
2014-05-22 10:11:45 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2018-11-01 20:15:46 +00:00
|
|
|
typedef ScrollableLayerGuid::ViewID ViewID;
|
2014-05-22 10:11:45 +00:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2015-08-03 06:11:00 +00:00
|
|
|
using namespace mozilla::Compression;
|
2010-07-21 18:06:33 +00:00
|
|
|
|
2012-03-01 08:26:09 +00:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
template <typename T>
|
2014-01-08 08:43:46 +00:00
|
|
|
void WriteSnapshotToDumpFile_internal(T* aObj, DataSourceSurface* aSurf) {
|
2012-03-01 08:26:09 +00:00
|
|
|
nsCString string(aObj->Name());
|
2014-05-22 03:48:52 +00:00
|
|
|
string.Append('-');
|
2012-08-22 15:56:38 +00:00
|
|
|
string.AppendInt((uint64_t)aObj);
|
2015-05-12 13:16:54 +00:00
|
|
|
if (gfxUtils::sDumpPaintFile != stderr) {
|
2016-11-15 09:08:18 +00:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(array["%s"]=")",
|
|
|
|
string.BeginReading());
|
2013-11-23 22:44:18 +00:00
|
|
|
}
|
2014-06-27 11:19:40 +00:00
|
|
|
gfxUtils::DumpAsDataURI(aSurf, gfxUtils::sDumpPaintFile);
|
2015-05-12 13:16:54 +00:00
|
|
|
if (gfxUtils::sDumpPaintFile != stderr) {
|
2016-11-15 09:08:18 +00:00
|
|
|
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(";)");
|
2013-11-23 22:44:18 +00:00
|
|
|
}
|
2012-03-01 08:26:09 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 00:37:19 +00:00
|
|
|
void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> surf = aTarget->Snapshot();
|
|
|
|
RefPtr<DataSourceSurface> dSurf = surf->GetDataSurface();
|
2014-01-08 08:43:46 +00:00
|
|
|
WriteSnapshotToDumpFile_internal(aCompositor, dSurf);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
}
|
2012-03-01 08:26:09 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-18 20:13:12 +00:00
|
|
|
IntRect ToOutsideIntRect(const gfxRect& aRect) {
|
2017-12-19 20:48:39 +00:00
|
|
|
return IntRect::RoundOut(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2014-08-18 20:13:12 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 15:32:29 +00:00
|
|
|
void RecordCompositionPayloadsPresented(
|
2020-12-08 22:40:33 +00:00
|
|
|
const TimeStamp& aCompositionEndTime,
|
2019-05-28 15:32:29 +00:00
|
|
|
const nsTArray<CompositionPayload>& aPayloads) {
|
|
|
|
if (aPayloads.Length()) {
|
2020-12-08 22:40:33 +00:00
|
|
|
TimeStamp presented = aCompositionEndTime;
|
2019-05-28 15:32:29 +00:00
|
|
|
for (const CompositionPayload& payload : aPayloads) {
|
2021-11-08 23:59:35 +00:00
|
|
|
if (profiler_thread_is_being_profiled_for_markers()) {
|
2020-06-29 22:41:20 +00:00
|
|
|
MOZ_RELEASE_ASSERT(payload.mType <= kHighestCompositionPayloadType);
|
|
|
|
nsAutoCString name(
|
|
|
|
kCompositionPayloadTypeNames[uint8_t(payload.mType)]);
|
|
|
|
name.AppendLiteral(" Payload Presented");
|
|
|
|
// This doesn't really need to be a text marker. Once we have a version
|
|
|
|
// of profiler_add_marker that accepts both a start time and an end
|
|
|
|
// time, we could use that here.
|
|
|
|
nsPrintfCString text(
|
|
|
|
"Latency: %dms",
|
2019-05-28 15:32:29 +00:00
|
|
|
int32_t((presented - payload.mTimeStamp).ToMilliseconds()));
|
2020-10-01 11:02:23 +00:00
|
|
|
PROFILER_MARKER_TEXT(
|
|
|
|
name, GRAPHICS,
|
|
|
|
MarkerTiming::Interval(payload.mTimeStamp, presented), text);
|
2019-05-28 15:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (payload.mType == CompositionPayloadType::eKeyPress) {
|
|
|
|
Telemetry::AccumulateTimeDelta(
|
|
|
|
mozilla::Telemetry::KEYPRESS_PRESENT_LATENCY, payload.mTimeStamp,
|
|
|
|
presented);
|
2019-12-07 03:57:56 +00:00
|
|
|
} else if (payload.mType == CompositionPayloadType::eAPZScroll) {
|
|
|
|
Telemetry::AccumulateTimeDelta(
|
|
|
|
mozilla::Telemetry::SCROLL_PRESENT_LATENCY, payload.mTimeStamp,
|
|
|
|
presented);
|
2021-03-18 14:20:20 +00:00
|
|
|
} else if (payload.mType ==
|
|
|
|
CompositionPayloadType::eMouseUpFollowedByClick) {
|
|
|
|
Telemetry::AccumulateTimeDelta(
|
|
|
|
mozilla::Telemetry::MOUSEUP_FOLLOWED_BY_CLICK_PRESENT_LATENCY,
|
|
|
|
payload.mTimeStamp, presented);
|
2019-05-28 15:32:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-31 17:28:20 +00:00
|
|
|
} // namespace layers
|
2010-07-21 18:06:33 +00:00
|
|
|
} // namespace mozilla
|