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_SOURCESURFACERAWDATA_H_ |
michael@0 | 7 | #define MOZILLA_GFX_SOURCESURFACERAWDATA_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "2D.h" |
michael@0 | 10 | #include "Tools.h" |
michael@0 | 11 | |
michael@0 | 12 | namespace mozilla { |
michael@0 | 13 | namespace gfx { |
michael@0 | 14 | |
michael@0 | 15 | class SourceSurfaceRawData : public DataSourceSurface |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceRawData) |
michael@0 | 19 | SourceSurfaceRawData() {} |
michael@0 | 20 | ~SourceSurfaceRawData() { if(mOwnData) delete [] mRawData; } |
michael@0 | 21 | |
michael@0 | 22 | virtual uint8_t *GetData() { return mRawData; } |
michael@0 | 23 | virtual int32_t Stride() { return mStride; } |
michael@0 | 24 | |
michael@0 | 25 | virtual SurfaceType GetType() const { return SurfaceType::DATA; } |
michael@0 | 26 | virtual IntSize GetSize() const { return mSize; } |
michael@0 | 27 | virtual SurfaceFormat GetFormat() const { return mFormat; } |
michael@0 | 28 | |
michael@0 | 29 | bool InitWrappingData(unsigned char *aData, |
michael@0 | 30 | const IntSize &aSize, |
michael@0 | 31 | int32_t aStride, |
michael@0 | 32 | SurfaceFormat aFormat, |
michael@0 | 33 | bool aOwnData); |
michael@0 | 34 | |
michael@0 | 35 | private: |
michael@0 | 36 | uint8_t *mRawData; |
michael@0 | 37 | int32_t mStride; |
michael@0 | 38 | SurfaceFormat mFormat; |
michael@0 | 39 | IntSize mSize; |
michael@0 | 40 | bool mOwnData; |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | class SourceSurfaceAlignedRawData : public DataSourceSurface |
michael@0 | 44 | { |
michael@0 | 45 | public: |
michael@0 | 46 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceAlignedRawData) |
michael@0 | 47 | SourceSurfaceAlignedRawData() {} |
michael@0 | 48 | |
michael@0 | 49 | virtual uint8_t *GetData() { return mArray; } |
michael@0 | 50 | virtual int32_t Stride() { return mStride; } |
michael@0 | 51 | |
michael@0 | 52 | virtual SurfaceType GetType() const { return SurfaceType::DATA; } |
michael@0 | 53 | virtual IntSize GetSize() const { return mSize; } |
michael@0 | 54 | virtual SurfaceFormat GetFormat() const { return mFormat; } |
michael@0 | 55 | |
michael@0 | 56 | bool Init(const IntSize &aSize, |
michael@0 | 57 | SurfaceFormat aFormat); |
michael@0 | 58 | bool InitWithStride(const IntSize &aSize, |
michael@0 | 59 | SurfaceFormat aFormat, |
michael@0 | 60 | int32_t aStride); |
michael@0 | 61 | |
michael@0 | 62 | private: |
michael@0 | 63 | AlignedArray<uint8_t> mArray; |
michael@0 | 64 | int32_t mStride; |
michael@0 | 65 | SurfaceFormat mFormat; |
michael@0 | 66 | IntSize mSize; |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | #endif /* MOZILLA_GFX_SOURCESURFACERAWDATA_H_ */ |