summaryrefslogtreecommitdiffstats
path: root/gfx/layers/RenderTrace.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /gfx/layers/RenderTrace.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/layers/RenderTrace.cpp')
-rw-r--r--gfx/layers/RenderTrace.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/gfx/layers/RenderTrace.cpp b/gfx/layers/RenderTrace.cpp
new file mode 100644
index 000000000..977c772a7
--- /dev/null
+++ b/gfx/layers/RenderTrace.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * 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/. */
+
+#include "RenderTrace.h"
+
+// If rendertrace is off let's no compile this code
+#ifdef MOZ_RENDERTRACE
+#include "Layers.h"
+#include "TreeTraversal.h" // for ForEachNode
+
+
+namespace mozilla {
+namespace layers {
+
+static gfx::Matrix4x4 GetRootTransform(Layer *aLayer) {
+ gfx::Matrix4x4 layerTrans = aLayer->GetTransform();
+ layerTrans.ProjectTo2D();
+ if (aLayer->GetParent() != nullptr) {
+ return GetRootTransform(aLayer->GetParent()) * layerTrans;
+ }
+ return layerTrans;
+}
+
+void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx::Matrix4x4 aRootTransform) {
+ int colorId = 0;
+ ForEachNode<ForwardIterator>(
+ aLayer,
+ [&colorId] (Layer *layer)
+ {
+ gfx::Matrix4x4 trans = aRootTransform * layer->GetTransform();
+ trans.ProjectTo2D();
+ gfx::IntRect clipRect = layer->GetLocalVisibleRegion().GetBounds();
+ Rect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
+ trans.TransformBounds(rect);
+
+ if (strcmp(layer->Name(), "ContainerLayer") != 0 &&
+ strcmp(layer->Name(), "ContainerLayerComposite") != 0) {
+ printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n",
+ layer->Name(), (int)PR_IntervalNow(),
+ colorId, aColor,
+ (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+ }
+ colorId++;
+ });
+}
+
+void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const gfx::IntRect aRect) {
+ gfx::Matrix4x4 trans = GetRootTransform(aLayer);
+ gfx::Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
+ trans.TransformBounds(rect);
+
+ printf_stderr("%s RENDERTRACE %u fillrect #%s %i %i %i %i\n",
+ aLayer->Name(), (int)PR_IntervalNow(),
+ aColor,
+ (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) {
+ // Clear with an empty rect
+ RenderTraceInvalidateStart(aLayer, aColor, gfx::IntRect());
+}
+
+void renderTraceEventStart(const char *aComment, const char *aColor) {
+ printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 10 10\n",
+ aComment, (int)PR_IntervalNow(), aColor);
+}
+
+void renderTraceEventEnd(const char *aComment, const char *aColor) {
+ printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 0 0\n",
+ aComment, (int)PR_IntervalNow(), aColor);
+}
+
+void renderTraceEventEnd(const char *aColor) {
+ renderTraceEventEnd("", aColor);
+}
+
+}
+}
+
+#endif
+