Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "RenderTrace.h" |
michael@0 | 7 | |
michael@0 | 8 | // If rendertrace is off let's no compile this code |
michael@0 | 9 | #ifdef MOZ_RENDERTRACE |
michael@0 | 10 | #include "Layers.h" |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace layers { |
michael@0 | 15 | |
michael@0 | 16 | static int colorId = 0; |
michael@0 | 17 | |
michael@0 | 18 | static gfx3DMatrix GetRootTransform(Layer *aLayer) { |
michael@0 | 19 | gfx3DMatrix layerTrans = aLayer->GetTransform(); |
michael@0 | 20 | layerTrans.ProjectTo2D(); |
michael@0 | 21 | if (aLayer->GetParent() != nullptr) { |
michael@0 | 22 | return GetRootTransform(aLayer->GetParent()) * layerTrans; |
michael@0 | 23 | } |
michael@0 | 24 | return layerTrans; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset) { |
michael@0 | 28 | if (!aLayer) |
michael@0 | 29 | return; |
michael@0 | 30 | |
michael@0 | 31 | gfx3DMatrix trans = aRootTransform * aLayer->GetTransform(); |
michael@0 | 32 | trans.ProjectTo2D(); |
michael@0 | 33 | nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds(); |
michael@0 | 34 | gfxRect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height); |
michael@0 | 35 | trans.TransformBounds(rect); |
michael@0 | 36 | |
michael@0 | 37 | if (strcmp(aLayer->Name(), "ContainerLayer") != 0 && |
michael@0 | 38 | strcmp(aLayer->Name(), "ContainerLayerComposite") != 0) { |
michael@0 | 39 | printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n", |
michael@0 | 40 | aLayer->Name(), (int)PR_IntervalNow(), |
michael@0 | 41 | colorId, aColor, |
michael@0 | 42 | (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | colorId++; |
michael@0 | 46 | |
michael@0 | 47 | for (Layer* child = aLayer->GetFirstChild(); |
michael@0 | 48 | child; child = child->GetNextSibling()) { |
michael@0 | 49 | RenderTraceLayers(child, aColor, aRootTransform, false); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | if (aReset) colorId = 0; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect) { |
michael@0 | 56 | gfx3DMatrix trans = GetRootTransform(aLayer); |
michael@0 | 57 | gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height); |
michael@0 | 58 | trans.TransformBounds(rect); |
michael@0 | 59 | |
michael@0 | 60 | printf_stderr("%s RENDERTRACE %u fillrect #%s %i %i %i %i\n", |
michael@0 | 61 | aLayer->Name(), (int)PR_IntervalNow(), |
michael@0 | 62 | aColor, |
michael@0 | 63 | (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); |
michael@0 | 64 | } |
michael@0 | 65 | void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) { |
michael@0 | 66 | // Clear with an empty rect |
michael@0 | 67 | RenderTraceInvalidateStart(aLayer, aColor, nsIntRect()); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void renderTraceEventStart(const char *aComment, const char *aColor) { |
michael@0 | 71 | printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 10 10\n", |
michael@0 | 72 | aComment, (int)PR_IntervalNow(), aColor); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | void renderTraceEventEnd(const char *aComment, const char *aColor) { |
michael@0 | 76 | printf_stderr("%s RENDERTRACE %u fillrect #%s 0 0 0 0\n", |
michael@0 | 77 | aComment, (int)PR_IntervalNow(), aColor); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | void renderTraceEventEnd(const char *aColor) { |
michael@0 | 81 | renderTraceEventEnd("", aColor); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | #endif |
michael@0 | 88 |