2012-02-17 22:05:03 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
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/. */
|
2012-02-17 22:05:03 +00:00
|
|
|
|
|
|
|
#include "RenderTrace.h"
|
|
|
|
|
|
|
|
// If rendertrace is off let's no compile this code
|
|
|
|
#ifdef MOZ_RENDERTRACE
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "Layers.h"
|
2012-02-17 22:05:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
static int colorId = 0;
|
|
|
|
|
2014-07-22 01:37:57 +00:00
|
|
|
static gfx::Matrix4x4 GetRootTransform(Layer *aLayer) {
|
|
|
|
gfx::Matrix4x4 layerTrans = aLayer->GetTransform();
|
2012-05-29 17:56:44 +00:00
|
|
|
layerTrans.ProjectTo2D();
|
2013-07-20 08:48:55 +00:00
|
|
|
if (aLayer->GetParent() != nullptr) {
|
2012-03-05 20:17:13 +00:00
|
|
|
return GetRootTransform(aLayer->GetParent()) * layerTrans;
|
2012-02-24 16:35:04 +00:00
|
|
|
}
|
2012-03-05 20:17:13 +00:00
|
|
|
return layerTrans;
|
2012-02-17 22:05:03 +00:00
|
|
|
}
|
|
|
|
|
2014-08-01 12:31:49 +00:00
|
|
|
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx::Matrix4x4 aRootTransform, bool aReset) {
|
2012-02-17 22:05:03 +00:00
|
|
|
if (!aLayer)
|
|
|
|
return;
|
|
|
|
|
2014-08-01 12:31:49 +00:00
|
|
|
gfx::Matrix4x4 trans = aRootTransform * aLayer->GetTransform();
|
2012-05-29 17:56:44 +00:00
|
|
|
trans.ProjectTo2D();
|
2012-02-17 22:05:03 +00:00
|
|
|
nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds();
|
2014-08-01 12:31:49 +00:00
|
|
|
Rect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
|
2012-02-24 16:35:04 +00:00
|
|
|
trans.TransformBounds(rect);
|
|
|
|
|
|
|
|
if (strcmp(aLayer->Name(), "ContainerLayer") != 0 &&
|
2013-04-25 22:25:33 +00:00
|
|
|
strcmp(aLayer->Name(), "ContainerLayerComposite") != 0) {
|
2012-02-24 16:35:04 +00:00
|
|
|
printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n",
|
|
|
|
aLayer->Name(), (int)PR_IntervalNow(),
|
|
|
|
colorId, aColor,
|
|
|
|
(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
|
|
|
}
|
2012-02-17 22:05:03 +00:00
|
|
|
|
|
|
|
colorId++;
|
|
|
|
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
|
|
|
RenderTraceLayers(child, aColor, aRootTransform, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aReset) colorId = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect) {
|
2014-07-22 01:37:57 +00:00
|
|
|
gfx::Matrix4x4 trans = GetRootTransform(aLayer);
|
|
|
|
gfx::Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
2012-02-24 16:35:04 +00:00
|
|
|
trans.TransformBounds(rect);
|
2012-02-17 22:05:03 +00:00
|
|
|
|
2012-02-24 16:35:04 +00: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-17 22:05:03 +00:00
|
|
|
}
|
|
|
|
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) {
|
|
|
|
// Clear with an empty rect
|
|
|
|
RenderTraceInvalidateStart(aLayer, aColor, nsIntRect());
|
|
|
|
}
|
|
|
|
|
2012-02-24 22:41:16 +00: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-17 22:05:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|