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_SOURCESURFACESKIA_H_
7 #define MOZILLA_GFX_SOURCESURFACESKIA_H_
9 #include "2D.h"
10 #include <vector>
11 #include "skia/SkCanvas.h"
12 #include "skia/SkBitmap.h"
14 namespace mozilla {
15 namespace gfx {
17 class DrawTargetSkia;
19 class SourceSurfaceSkia : public DataSourceSurface
20 {
21 public:
22 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia)
23 SourceSurfaceSkia();
24 ~SourceSurfaceSkia();
26 virtual SurfaceType GetType() const { return SurfaceType::SKIA; }
27 virtual IntSize GetSize() const;
28 virtual SurfaceFormat GetFormat() const;
30 SkBitmap& GetBitmap() { return mBitmap; }
32 bool InitFromData(unsigned char* aData,
33 const IntSize &aSize,
34 int32_t aStride,
35 SurfaceFormat aFormat);
37 bool InitFromCanvas(SkCanvas* aCanvas,
38 SurfaceFormat aFormat,
39 DrawTargetSkia* aOwner);
41 virtual unsigned char *GetData();
43 virtual int32_t Stride() { return mStride; }
45 private:
46 friend class DrawTargetSkia;
48 void DrawTargetWillChange();
49 void MaybeUnlock();
51 SkBitmap mBitmap;
52 SurfaceFormat mFormat;
53 IntSize mSize;
54 int32_t mStride;
55 RefPtr<DrawTargetSkia> mDrawTarget;
56 bool mLocked;
57 };
59 }
60 }
62 #endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */