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: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GLBLITHELPER_H_
8 #define GLBLITHELPER_H_
10 #include "GLContextTypes.h"
11 #include "GLConsts.h"
12 #include "nsSize.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/gfx/Point.h"
16 namespace mozilla {
17 namespace gl {
19 class GLContext;
21 /**
22 * Helper function that creates a 2D texture aSize.width x aSize.height with
23 * storage type specified by aFormats. Returns GL texture object id.
24 *
25 * See mozilla::gl::CreateTexture.
26 */
27 GLuint CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
28 const gfx::IntSize& aSize);
30 /**
31 * Helper function that creates a 2D texture aSize.width x aSize.height with
32 * storage type aInternalFormat. Returns GL texture object id.
33 *
34 * Initialize textyre parameters to:
35 * GL_TEXTURE_MIN_FILTER = GL_LINEAR
36 * GL_TEXTURE_MAG_FILTER = GL_LINEAR
37 * GL_TEXTURE_WRAP_S = GL_CLAMP_TO_EDGE
38 * GL_TEXTURE_WRAP_T = GL_CLAMP_TO_EDGE
39 */
40 GLuint CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
41 GLenum aType, const gfx::IntSize& aSize);
43 /**
44 * Helper function to create, potentially, multisample render buffers suitable
45 * for offscreen rendering. Buffers of size aSize.width x aSize.height with
46 * storage specified by aFormat. returns GL render buffer object id.
47 */
48 GLuint CreateRenderbuffer(GLContext* aGL, GLenum aFormat, GLsizei aSamples,
49 const gfx::IntSize& aSize);
51 /**
52 * Helper function to create, potentially, multisample render buffers suitable
53 * for offscreen rendering. Buffers of size aSize.width x aSize.height with
54 * storage specified by aFormats. GL render buffer object ids are returned via
55 * aColorMSRB, aDepthRB, and aStencilRB
56 */
57 void CreateRenderbuffersForOffscreen(GLContext* aGL, const GLFormats& aFormats,
58 const gfx::IntSize& aSize, bool aMultisample,
59 GLuint* aColorMSRB, GLuint* aDepthRB,
60 GLuint* aStencilRB);
63 /** Buffer blitting helper */
64 class GLBlitHelper MOZ_FINAL
65 {
66 // The GLContext is the sole owner of the GLBlitHelper.
67 GLContext* mGL;
69 GLuint mTexBlit_Buffer;
70 GLuint mTexBlit_VertShader;
71 GLuint mTex2DBlit_FragShader;
72 GLuint mTex2DRectBlit_FragShader;
73 GLuint mTex2DBlit_Program;
74 GLuint mTex2DRectBlit_Program;
76 void UseBlitProgram();
77 void SetBlitFramebufferForDestTexture(GLuint aTexture);
79 bool UseTexQuadProgram(GLenum target, const gfx::IntSize& srcSize);
80 bool InitTexQuadProgram(GLenum target = LOCAL_GL_TEXTURE_2D);
81 void DeleteTexBlitProgram();
83 public:
85 GLBlitHelper(GLContext* gl);
86 ~GLBlitHelper();
88 // If you don't have |srcFormats| for the 2nd definition,
89 // then you'll need the framebuffer_blit extensions to use
90 // the first BlitFramebufferToFramebuffer.
91 void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
92 const gfx::IntSize& srcSize,
93 const gfx::IntSize& destSize);
94 void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
95 const gfx::IntSize& srcSize,
96 const gfx::IntSize& destSize,
97 const GLFormats& srcFormats);
98 void BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
99 const gfx::IntSize& srcSize,
100 const gfx::IntSize& destSize,
101 GLenum srcTarget = LOCAL_GL_TEXTURE_2D);
102 void BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
103 const gfx::IntSize& srcSize,
104 const gfx::IntSize& destSize,
105 GLenum destTarget = LOCAL_GL_TEXTURE_2D);
106 void BlitTextureToTexture(GLuint srcTex, GLuint destTex,
107 const gfx::IntSize& srcSize,
108 const gfx::IntSize& destSize,
109 GLenum srcTarget = LOCAL_GL_TEXTURE_2D,
110 GLenum destTarget = LOCAL_GL_TEXTURE_2D);
111 };
113 }
114 }
116 #endif // GLBLITHELPER_H_