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: 4 -*- */ |
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 TEXTUREIMAGEEGL_H_ |
michael@0 | 7 | #define TEXTUREIMAGEEGL_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "GLTextureImage.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | namespace gl { |
michael@0 | 13 | |
michael@0 | 14 | class TextureImageEGL |
michael@0 | 15 | : public TextureImage |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | TextureImageEGL(GLuint aTexture, |
michael@0 | 19 | const nsIntSize& aSize, |
michael@0 | 20 | GLenum aWrapMode, |
michael@0 | 21 | ContentType aContentType, |
michael@0 | 22 | GLContext* aContext, |
michael@0 | 23 | Flags aFlags = TextureImage::NoFlags, |
michael@0 | 24 | TextureState aTextureState = Created, |
michael@0 | 25 | TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown); |
michael@0 | 26 | |
michael@0 | 27 | virtual ~TextureImageEGL(); |
michael@0 | 28 | |
michael@0 | 29 | virtual void GetUpdateRegion(nsIntRegion& aForRegion); |
michael@0 | 30 | |
michael@0 | 31 | virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion); |
michael@0 | 32 | |
michael@0 | 33 | virtual void EndUpdate(); |
michael@0 | 34 | |
michael@0 | 35 | virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0)); |
michael@0 | 36 | |
michael@0 | 37 | virtual void BindTexture(GLenum aTextureUnit); |
michael@0 | 38 | |
michael@0 | 39 | virtual GLuint GetTextureID() |
michael@0 | 40 | { |
michael@0 | 41 | // Ensure the texture is allocated before it is used. |
michael@0 | 42 | if (mTextureState == Created) { |
michael@0 | 43 | Resize(mSize); |
michael@0 | 44 | } |
michael@0 | 45 | return mTexture; |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | virtual bool InUpdate() const { return !!mUpdateDrawTarget; } |
michael@0 | 49 | |
michael@0 | 50 | virtual void Resize(const gfx::IntSize& aSize); |
michael@0 | 51 | |
michael@0 | 52 | bool BindTexImage(); |
michael@0 | 53 | |
michael@0 | 54 | bool ReleaseTexImage(); |
michael@0 | 55 | |
michael@0 | 56 | virtual bool CreateEGLSurface(gfxASurface* aSurface) |
michael@0 | 57 | { |
michael@0 | 58 | return false; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | virtual void DestroyEGLSurface(void); |
michael@0 | 62 | |
michael@0 | 63 | protected: |
michael@0 | 64 | typedef gfxImageFormat ImageFormat; |
michael@0 | 65 | |
michael@0 | 66 | GLContext* mGLContext; |
michael@0 | 67 | |
michael@0 | 68 | nsIntRect mUpdateRect; |
michael@0 | 69 | gfx::SurfaceFormat mUpdateFormat; |
michael@0 | 70 | RefPtr<gfx::DrawTarget> mUpdateDrawTarget; |
michael@0 | 71 | EGLImage mEGLImage; |
michael@0 | 72 | GLuint mTexture; |
michael@0 | 73 | EGLSurface mSurface; |
michael@0 | 74 | EGLConfig mConfig; |
michael@0 | 75 | TextureState mTextureState; |
michael@0 | 76 | |
michael@0 | 77 | bool mBound; |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | already_AddRefed<TextureImage> |
michael@0 | 81 | CreateTextureImageEGL(GLContext *gl, |
michael@0 | 82 | const gfx::IntSize& aSize, |
michael@0 | 83 | TextureImage::ContentType aContentType, |
michael@0 | 84 | GLenum aWrapMode, |
michael@0 | 85 | TextureImage::Flags aFlags, |
michael@0 | 86 | TextureImage::ImageFormat aImageFormat); |
michael@0 | 87 | |
michael@0 | 88 | already_AddRefed<TextureImage> |
michael@0 | 89 | TileGenFuncEGL(GLContext *gl, |
michael@0 | 90 | const nsIntSize& aSize, |
michael@0 | 91 | TextureImage::ContentType aContentType, |
michael@0 | 92 | TextureImage::Flags aFlags, |
michael@0 | 93 | TextureImage::ImageFormat aImageFormat); |
michael@0 | 94 | |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | #endif // TEXTUREIMAGEEGL_H_ |