gfx/thebes/nsSurfaceTexture.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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

mercurial