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