gfx/2d/SourceSurfaceCairo.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 _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
     7 #define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
     9 #include "2D.h"
    11 namespace mozilla {
    12 namespace gfx {
    14 class DrawTargetCairo;
    16 class SourceSurfaceCairo : public SourceSurface
    17 {
    18 public:
    19   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo)
    20   // Create a SourceSurfaceCairo. The surface will not be copied, but simply
    21   // referenced.
    22   // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
    23   // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
    24   // we're destroyed.
    25   SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
    26                      const SurfaceFormat& aFormat,
    27                      DrawTargetCairo* aDrawTarget = nullptr);
    28   virtual ~SourceSurfaceCairo();
    30   virtual SurfaceType GetType() const { return SurfaceType::CAIRO; }
    31   virtual IntSize GetSize() const;
    32   virtual SurfaceFormat GetFormat() const;
    33   virtual TemporaryRef<DataSourceSurface> GetDataSurface();
    35   cairo_surface_t* GetSurface() const;
    37 private: // methods
    38   friend class DrawTargetCairo;
    39   void DrawTargetWillChange();
    41 private: // data
    42   IntSize mSize;
    43   SurfaceFormat mFormat;
    44   cairo_surface_t* mSurface;
    45   DrawTargetCairo* mDrawTarget;
    46 };
    48 class DataSourceSurfaceCairo : public DataSourceSurface
    49 {
    50 public:
    51   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo)
    52   DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
    53   virtual ~DataSourceSurfaceCairo();
    54   virtual unsigned char *GetData();
    55   virtual int32_t Stride();
    57   virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; }
    58   virtual IntSize GetSize() const;
    59   virtual SurfaceFormat GetFormat() const;
    61   cairo_surface_t* GetSurface() const;
    63 private:
    64   cairo_surface_t* mImageSurface;
    65 };
    67 }
    68 }
    70 #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H

mercurial