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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef SHAREDRGBIMAGE_H_
6 #define SHAREDRGBIMAGE_H_
8 #include <stddef.h> // for size_t
9 #include <stdint.h> // for uint8_t
10 #include "ImageContainer.h" // for ISharedImage, Image, etc
11 #include "gfxTypes.h"
12 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
13 #include "mozilla/RefPtr.h" // for RefPtr
14 #include "mozilla/gfx/Point.h" // for IntSize
15 #include "mozilla/gfx/Types.h" // for SurfaceFormat
16 #include "nsCOMPtr.h" // for already_AddRefed
18 namespace mozilla {
19 namespace ipc {
20 class Shmem;
21 }
23 namespace layers {
25 class BufferTextureClient;
26 class ImageClient;
27 class ISurfaceAllocator;
28 class TextureClient;
29 class SurfaceDescriptor;
31 already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
32 nsIntSize aSize,
33 gfxImageFormat aImageFormat);
35 /**
36 * Stores RGB data in shared memory
37 * It is assumed that the image width and stride are equal
38 */
39 class SharedRGBImage : public Image
40 , public ISharedImage
41 {
42 public:
43 SharedRGBImage(ImageClient* aCompositable);
44 ~SharedRGBImage();
46 virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
48 virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
50 virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
52 gfx::IntSize GetSize();
54 size_t GetBufferSize();
56 TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
58 bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
59 private:
60 gfx::IntSize mSize;
61 RefPtr<ImageClient> mCompositable;
62 RefPtr<BufferTextureClient> mTextureClient;
63 };
65 } // namespace layers
66 } // namespace mozilla
68 #endif