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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:set ts=2 sts=2 sw=2 et cin:
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 nsSurfaceTexture_h__
8 #define nsSurfaceTexture_h__
9 #ifdef MOZ_WIDGET_ANDROID
11 #include <jni.h>
12 #include "nsIRunnable.h"
13 #include "gfxPlatform.h"
14 #include "GLDefs.h"
16 namespace mozilla {
17 namespace gfx {
18 class Matrix4x4;
19 }
20 }
22 /**
23 * This class is a wrapper around Android's SurfaceTexture class.
24 * Usage is pretty much exactly like the Java class, so see
25 * the Android documentation for details.
26 */
27 class nsSurfaceTexture MOZ_FINAL {
28 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsSurfaceTexture)
30 public:
31 static nsSurfaceTexture* Create(GLuint aTexture);
32 static nsSurfaceTexture* Find(int id);
34 // Returns with reasonable certainty whether or not we'll
35 // be able to create and use a SurfaceTexture
36 static bool Check();
38 // This is an ANativeWindow. Use AndroidBridge::LockWindow and
39 // friends for manipulating it.
40 void* GetNativeWindow();
42 // This attaches the updated data to the TEXTURE_EXTERNAL target
43 void UpdateTexImage();
45 bool GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix);
46 int ID() { return mID; }
48 // The callback is guaranteed to be called on the main thread even
49 // if the upstream callback is received on a different thread
50 void SetFrameAvailableCallback(nsIRunnable* aRunnable);
52 // Only should be called by AndroidJNI when we get a
53 // callback from the underlying SurfaceTexture instance
54 void NotifyFrameAvailable();
55 private:
56 nsSurfaceTexture();
58 // Private destructor, to discourage deletion outside of Release():
59 ~nsSurfaceTexture();
61 bool Init(GLuint aTexture);
63 jobject mSurfaceTexture;
64 void* mNativeWindow;
65 int mID;
66 nsRefPtr<nsIRunnable> mFrameAvailableCallback;
67 };
69 #endif
70 #endif