michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "RenderTrace.h" michael@0: michael@0: // If rendertrace is off let's no compile this code michael@0: #ifdef MOZ_RENDERTRACE michael@0: #include "Layers.h" michael@0: michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: static int colorId = 0; michael@0: michael@0: static gfx3DMatrix GetRootTransform(Layer *aLayer) { michael@0: gfx3DMatrix layerTrans = aLayer->GetTransform(); michael@0: layerTrans.ProjectTo2D(); michael@0: if (aLayer->GetParent() != nullptr) { michael@0: return GetRootTransform(aLayer->GetParent()) * layerTrans; michael@0: } michael@0: return layerTrans; michael@0: } michael@0: michael@0: void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset) { michael@0: if (!aLayer) michael@0: return; michael@0: michael@0: gfx3DMatrix trans = aRootTransform * aLayer->GetTransform(); michael@0: trans.ProjectTo2D(); michael@0: nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds(); michael@0: gfxRect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height); michael@0: trans.TransformBounds(rect); michael@0: michael@0: if (strcmp(aLayer->Name(), "ContainerLayer") != 0 && michael@0: strcmp(aLayer->Name(), "ContainerLayerComposite") != 0) { michael@0: printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n", michael@0: aLayer->Name(), (int)PR_IntervalNow(), michael@0: colorId, aColor, michael@0: (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); michael@0: } michael@0: michael@0: colorId++; michael@0: michael@0: for (Layer* child = aLayer->GetFirstChild(); michael@0: child; child = child->GetNextSibling()) { michael@0: RenderTraceLayers(child, aColor, aRootTransform, false); michael@0: } michael@0: michael@0: if (aReset) colorId = 0; michael@0: } michael@0: michael@0: void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect) { michael@0: gfx3DMatrix trans = GetRootTransform(aLayer); michael@0: gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height); michael@0: trans.TransformBounds(rect); michael@0: michael@0: printf_stderr("%s RENDERTRACE %u fillrect #%s %i %i %i %i\n", michael@0: aLayer->Name(), (int)PR_IntervalNow(), michael@0: aColor, michael@0: (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); michael@0: } michael@0: void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) { michael@0: // Clear with an empty rect michael@0: RenderTraceInvalidateStart(aLayer, aColor, nsIntRect()); michael@0: } michael@0: michael@0: void renderTraceEventStart(const char *aComment, const char *aColor) { michael@0: printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 10 10\n", michael@0: aComment, (int)PR_IntervalNow(), aColor); michael@0: } michael@0: michael@0: void renderTraceEventEnd(const char *aComment, const char *aColor) { michael@0: printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 0 0\n", michael@0: aComment, (int)PR_IntervalNow(), aColor); michael@0: } michael@0: michael@0: void renderTraceEventEnd(const char *aColor) { michael@0: renderTraceEventEnd("", aColor); michael@0: } michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif michael@0: