2017-10-28 02:10:06 +03: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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2012-02-18 02:05:03 +04:00
|
|
|
|
|
|
|
#include "RenderTrace.h"
|
|
|
|
|
|
|
|
// If rendertrace is off let's no compile this code
|
|
|
|
#ifdef MOZ_RENDERTRACE
|
2013-08-12 03:17:23 +04:00
|
|
|
# include "Layers.h"
|
2016-03-10 12:20:40 +03:00
|
|
|
# include "TreeTraversal.h" // for ForEachNode
|
2012-02-18 02:05:03 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-07-22 05:37:57 +04:00
|
|
|
static gfx::Matrix4x4 GetRootTransform(Layer *aLayer) {
|
|
|
|
gfx::Matrix4x4 layerTrans = aLayer->GetTransform();
|
2012-05-29 21:56:44 +04:00
|
|
|
layerTrans.ProjectTo2D();
|
2013-07-20 12:48:55 +04:00
|
|
|
if (aLayer->GetParent() != nullptr) {
|
2012-03-06 00:17:13 +04:00
|
|
|
return GetRootTransform(aLayer->GetParent()) * layerTrans;
|
2012-02-24 20:35:04 +04:00
|
|
|
}
|
2012-03-06 00:17:13 +04:00
|
|
|
return layerTrans;
|
2012-02-18 02:05:03 +04:00
|
|
|
}
|
|
|
|
|
2016-03-10 12:20:40 +03:00
|
|
|
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++;
|
|
|
|
});
|
2012-02-18 02:05:03 +04:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:53 +03:00
|
|
|
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor,
|
|
|
|
const gfx::IntRect aRect) {
|
2014-07-22 05:37:57 +04:00
|
|
|
gfx::Matrix4x4 trans = GetRootTransform(aLayer);
|
|
|
|
gfx::Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
2012-02-24 20:35:04 +04:00
|
|
|
trans.TransformBounds(rect);
|
2012-02-18 02:05:03 +04:00
|
|
|
|
2012-02-24 20:35:04 +04:00
|
|
|
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);
|
2012-02-18 02:05:03 +04:00
|
|
|
}
|
|
|
|
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) {
|
|
|
|
// Clear with an empty rect
|
2015-05-07 12:07:53 +03:00
|
|
|
RenderTraceInvalidateStart(aLayer, aColor, gfx::IntRect());
|
2012-02-18 02:05:03 +04:00
|
|
|
}
|
|
|
|
|
2012-02-25 02:41:16 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-02-18 02:05:03 +04:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|