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