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: 20; 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 "ImageLayers.h" |
michael@0 | 7 | #include "ImageContainer.h" // for ImageContainer |
michael@0 | 8 | #include "gfxRect.h" // for gfxRect |
michael@0 | 9 | #include "nsDebug.h" // for NS_ASSERTION |
michael@0 | 10 | #include "nsISupportsImpl.h" // for ImageContainer::Release, etc |
michael@0 | 11 | #include "gfx2DGlue.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace layers { |
michael@0 | 15 | |
michael@0 | 16 | ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData) |
michael@0 | 17 | : Layer(aManager, aImplData), mFilter(GraphicsFilter::FILTER_GOOD) |
michael@0 | 18 | , mScaleMode(ScaleMode::SCALE_NONE), mDisallowBigImage(false) |
michael@0 | 19 | {} |
michael@0 | 20 | |
michael@0 | 21 | ImageLayer::~ImageLayer() |
michael@0 | 22 | {} |
michael@0 | 23 | |
michael@0 | 24 | void ImageLayer::SetContainer(ImageContainer* aContainer) |
michael@0 | 25 | { |
michael@0 | 26 | mContainer = aContainer; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | void ImageLayer::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) |
michael@0 | 30 | { |
michael@0 | 31 | gfx::Matrix4x4 local = GetLocalTransform(); |
michael@0 | 32 | |
michael@0 | 33 | // Snap image edges to pixel boundaries |
michael@0 | 34 | gfxRect sourceRect(0, 0, 0, 0); |
michael@0 | 35 | if (mContainer) { |
michael@0 | 36 | sourceRect.SizeTo(gfx::ThebesIntSize(mContainer->GetCurrentSize())); |
michael@0 | 37 | if (mScaleMode != ScaleMode::SCALE_NONE && |
michael@0 | 38 | sourceRect.width != 0.0 && sourceRect.height != 0.0) { |
michael@0 | 39 | NS_ASSERTION(mScaleMode == ScaleMode::STRETCH, |
michael@0 | 40 | "No other scalemodes than stretch and none supported yet."); |
michael@0 | 41 | local.Scale(mScaleToSize.width / sourceRect.width, |
michael@0 | 42 | mScaleToSize.height / sourceRect.height, 1.0); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | // Snap our local transform first, and snap the inherited transform as well. |
michael@0 | 46 | // This makes our snapping equivalent to what would happen if our content |
michael@0 | 47 | // was drawn into a ThebesLayer (gfxContext would snap using the local |
michael@0 | 48 | // transform, then we'd snap again when compositing the ThebesLayer). |
michael@0 | 49 | mEffectiveTransform = |
michael@0 | 50 | SnapTransform(local, sourceRect, nullptr) * |
michael@0 | 51 | SnapTransformTranslation(aTransformToSurface, nullptr); |
michael@0 | 52 | ComputeEffectiveTransformForMaskLayer(aTransformToSurface); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | } |
michael@0 | 56 | } |