gfx/layers/ImageLayers.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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 #ifndef GFX_IMAGELAYER_H
michael@0 7 #define GFX_IMAGELAYER_H
michael@0 8
michael@0 9 #include "Layers.h" // for Layer, etc
michael@0 10 #include "GraphicsFilter.h" // for GraphicsFilter
michael@0 11 #include "mozilla/gfx/BaseSize.h" // for BaseSize
michael@0 12 #include "mozilla/gfx/Point.h" // for IntSize
michael@0 13 #include "mozilla/layers/LayersTypes.h"
michael@0 14 #include "nsAutoPtr.h" // for nsRefPtr
michael@0 15 #include "nscore.h" // for nsACString
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace layers {
michael@0 19
michael@0 20 class ImageContainer;
michael@0 21
michael@0 22 /**
michael@0 23 * A Layer which renders an Image.
michael@0 24 */
michael@0 25 class ImageLayer : public Layer {
michael@0 26 public:
michael@0 27 /**
michael@0 28 * CONSTRUCTION PHASE ONLY
michael@0 29 * Set the ImageContainer. aContainer must have the same layer manager
michael@0 30 * as this layer.
michael@0 31 */
michael@0 32 virtual void SetContainer(ImageContainer* aContainer);
michael@0 33
michael@0 34 /**
michael@0 35 * CONSTRUCTION PHASE ONLY
michael@0 36 * Set the filter used to resample this image if necessary.
michael@0 37 */
michael@0 38 void SetFilter(GraphicsFilter aFilter)
michael@0 39 {
michael@0 40 if (mFilter != aFilter) {
michael@0 41 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
michael@0 42 mFilter = aFilter;
michael@0 43 Mutated();
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 /**
michael@0 48 * CONSTRUCTION PHASE ONLY
michael@0 49 * Set the size to scale the image to and the mode at which to scale.
michael@0 50 */
michael@0 51 void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
michael@0 52 {
michael@0 53 if (mScaleToSize != aSize || mScaleMode != aMode) {
michael@0 54 mScaleToSize = aSize;
michael@0 55 mScaleMode = aMode;
michael@0 56 Mutated();
michael@0 57 }
michael@0 58 }
michael@0 59
michael@0 60
michael@0 61 ImageContainer* GetContainer() { return mContainer; }
michael@0 62 GraphicsFilter GetFilter() { return mFilter; }
michael@0 63 const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
michael@0 64 ScaleMode GetScaleMode() { return mScaleMode; }
michael@0 65
michael@0 66 MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
michael@0 67
michael@0 68 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface);
michael@0 69
michael@0 70 /**
michael@0 71 * if true, the image will only be backed by a single tile texture
michael@0 72 */
michael@0 73 void SetDisallowBigImage(bool aDisallowBigImage)
michael@0 74 {
michael@0 75 if (mDisallowBigImage != aDisallowBigImage) {
michael@0 76 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this));
michael@0 77 mDisallowBigImage = aDisallowBigImage;
michael@0 78 Mutated();
michael@0 79 }
michael@0 80 }
michael@0 81
michael@0 82 protected:
michael@0 83 ImageLayer(LayerManager* aManager, void* aImplData);
michael@0 84 ~ImageLayer();
michael@0 85 virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
michael@0 86
michael@0 87
michael@0 88 nsRefPtr<ImageContainer> mContainer;
michael@0 89 GraphicsFilter mFilter;
michael@0 90 gfx::IntSize mScaleToSize;
michael@0 91 ScaleMode mScaleMode;
michael@0 92 bool mDisallowBigImage;
michael@0 93 };
michael@0 94
michael@0 95 }
michael@0 96 }
michael@0 97
michael@0 98 #endif /* GFX_IMAGELAYER_H */

mercurial