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.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef GFX_IMAGELAYER_H
     7 #define GFX_IMAGELAYER_H
     9 #include "Layers.h"                     // for Layer, etc
    10 #include "GraphicsFilter.h"             // for GraphicsFilter
    11 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
    12 #include "mozilla/gfx/Point.h"          // for IntSize
    13 #include "mozilla/layers/LayersTypes.h"
    14 #include "nsAutoPtr.h"                  // for nsRefPtr
    15 #include "nscore.h"                     // for nsACString
    17 namespace mozilla {
    18 namespace layers {
    20 class ImageContainer;
    22 /**
    23  * A Layer which renders an Image.
    24  */
    25 class ImageLayer : public Layer {
    26 public:
    27   /**
    28    * CONSTRUCTION PHASE ONLY
    29    * Set the ImageContainer. aContainer must have the same layer manager
    30    * as this layer.
    31    */
    32   virtual void SetContainer(ImageContainer* aContainer);
    34   /**
    35    * CONSTRUCTION PHASE ONLY
    36    * Set the filter used to resample this image if necessary.
    37    */
    38   void SetFilter(GraphicsFilter aFilter)
    39   {
    40     if (mFilter != aFilter) {
    41       MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
    42       mFilter = aFilter;
    43       Mutated();
    44     }
    45   }
    47   /**
    48    * CONSTRUCTION PHASE ONLY
    49    * Set the size to scale the image to and the mode at which to scale.
    50    */
    51   void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
    52   {
    53     if (mScaleToSize != aSize || mScaleMode != aMode) {
    54       mScaleToSize = aSize;
    55       mScaleMode = aMode;
    56       Mutated();
    57     }
    58   }
    61   ImageContainer* GetContainer() { return mContainer; }
    62   GraphicsFilter GetFilter() { return mFilter; }
    63   const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
    64   ScaleMode GetScaleMode() { return mScaleMode; }
    66   MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
    68   virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface);
    70   /**
    71    * if true, the image will only be backed by a single tile texture
    72    */
    73   void SetDisallowBigImage(bool aDisallowBigImage)
    74   {
    75     if (mDisallowBigImage != aDisallowBigImage) {
    76       MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this));
    77       mDisallowBigImage = aDisallowBigImage;
    78       Mutated();
    79     }
    80   }
    82 protected:
    83   ImageLayer(LayerManager* aManager, void* aImplData);
    84   ~ImageLayer();
    85   virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
    88   nsRefPtr<ImageContainer> mContainer;
    89   GraphicsFilter mFilter;
    90   gfx::IntSize mScaleToSize;
    91   ScaleMode mScaleMode;
    92   bool mDisallowBigImage;
    93 };
    95 }
    96 }
    98 #endif /* GFX_IMAGELAYER_H */

mercurial