зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1381916
- Remove support for plugins on Android r=jchen,bsmedberg
MozReview-Commit-ID: AcAIC1QQew2
This commit is contained in:
Родитель
25dad4abf2
Коммит
d0bb12024d
|
@ -123,6 +123,6 @@ TEST_DIRS += [
|
|||
'imptests',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'cocoa', 'windows', 'android'):
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'cocoa', 'windows'):
|
||||
TEST_DIRS += ['plugins/test']
|
||||
|
||||
|
|
|
@ -21,43 +21,10 @@ static int gNotOptimized;
|
|||
#define CALLING_CONVENTION_HACK
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
#include "android_npapi.h"
|
||||
#include <android/log.h>
|
||||
#undef ALOG
|
||||
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoJavaEnv", ## args)
|
||||
#endif
|
||||
|
||||
using namespace mozilla::layers;
|
||||
|
||||
namespace mozilla {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
nsresult
|
||||
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
|
||||
NPPluginFuncs* pFuncs, NPError* error)
|
||||
{
|
||||
JNIEnv* env = jni::GetEnvForThread();
|
||||
|
||||
mozilla::AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
if (mNP_Initialize) {
|
||||
*error = mNP_Initialize(bFuncs, pFuncs, env);
|
||||
} else {
|
||||
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
|
||||
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
|
||||
if (!pfNP_Initialize)
|
||||
return NS_ERROR_FAILURE;
|
||||
*error = pfNP_Initialize(bFuncs, pFuncs, env);
|
||||
}
|
||||
|
||||
// Save pointers to functions that get called through PluginLibrary itself.
|
||||
mNPP_New = pFuncs->newp;
|
||||
mNPP_ClearSiteData = pFuncs->clearsitedata;
|
||||
mNPP_GetSitesWithData = pFuncs->getsiteswithdata;
|
||||
return NS_OK;
|
||||
}
|
||||
#elif defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
|
||||
NPPluginFuncs* pFuncs, NPError* error)
|
||||
|
@ -191,7 +158,6 @@ PluginPRLibrary::NPP_New(NPMIMEType pluginType, NPP instance,
|
|||
if (!mNPP_New)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
*error = mNPP_New(pluginType, instance, NP_EMBED, argc, argn, argv, saved);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -204,7 +170,6 @@ PluginPRLibrary::NPP_ClearSiteData(const char* site, uint64_t flags,
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
NPError result = mNPP_ClearSiteData(site, flags, maxAge);
|
||||
|
||||
nsresult rv;
|
||||
|
@ -232,7 +197,6 @@ PluginPRLibrary::NPP_GetSitesWithData(nsCOMPtr<nsIGetSitesWithDataCallback> call
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
char** sites = mNPP_GetSitesWithData();
|
||||
if (!sites) {
|
||||
return NS_OK;
|
||||
|
|
|
@ -1,390 +0,0 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "ANPBase.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPluginsAudio" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_audio_##name
|
||||
|
||||
/* android.media.AudioTrack */
|
||||
struct AudioTrack {
|
||||
jclass at_class;
|
||||
jmethodID constructor;
|
||||
jmethodID flush;
|
||||
jmethodID pause;
|
||||
jmethodID play;
|
||||
jmethodID setvol;
|
||||
jmethodID stop;
|
||||
jmethodID write;
|
||||
jmethodID getpos;
|
||||
jmethodID getstate;
|
||||
jmethodID release;
|
||||
};
|
||||
|
||||
enum AudioTrackMode {
|
||||
MODE_STATIC = 0,
|
||||
MODE_STREAM = 1
|
||||
};
|
||||
|
||||
/* android.media.AudioManager */
|
||||
enum AudioManagerStream {
|
||||
STREAM_VOICE_CALL = 0,
|
||||
STREAM_SYSTEM = 1,
|
||||
STREAM_RING = 2,
|
||||
STREAM_MUSIC = 3,
|
||||
STREAM_ALARM = 4,
|
||||
STREAM_NOTIFICATION = 5,
|
||||
STREAM_DTMF = 8
|
||||
};
|
||||
|
||||
/* android.media.AudioFormat */
|
||||
enum AudioFormatChannel {
|
||||
CHANNEL_OUT_MONO = 4,
|
||||
CHANNEL_OUT_STEREO = 12
|
||||
};
|
||||
|
||||
enum AudioFormatEncoding {
|
||||
ENCODING_PCM_16BIT = 2,
|
||||
ENCODING_PCM_8BIT = 3
|
||||
};
|
||||
|
||||
enum AudioFormatState {
|
||||
STATE_UNINITIALIZED = 0,
|
||||
STATE_INITIALIZED = 1,
|
||||
STATE_NO_STATIC_DATA = 2
|
||||
};
|
||||
|
||||
static struct AudioTrack at;
|
||||
|
||||
static jclass
|
||||
init_jni_bindings(JNIEnv *jenv) {
|
||||
jclass jc =
|
||||
(jclass)jenv->NewGlobalRef(jenv->FindClass("android/media/AudioTrack"));
|
||||
|
||||
at.constructor = jenv->GetMethodID(jc, "<init>", "(IIIIII)V");
|
||||
at.flush = jenv->GetMethodID(jc, "flush", "()V");
|
||||
at.pause = jenv->GetMethodID(jc, "pause", "()V");
|
||||
at.play = jenv->GetMethodID(jc, "play", "()V");
|
||||
at.setvol = jenv->GetMethodID(jc, "setStereoVolume", "(FF)I");
|
||||
at.stop = jenv->GetMethodID(jc, "stop", "()V");
|
||||
at.write = jenv->GetMethodID(jc, "write", "([BII)I");
|
||||
at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I");
|
||||
at.getstate = jenv->GetMethodID(jc, "getState", "()I");
|
||||
at.release = jenv->GetMethodID(jc, "release", "()V");
|
||||
|
||||
return jc;
|
||||
}
|
||||
|
||||
struct ANPAudioTrack {
|
||||
jobject output_unit;
|
||||
jclass at_class;
|
||||
|
||||
unsigned int rate;
|
||||
unsigned int channels;
|
||||
unsigned int bufferSize;
|
||||
unsigned int isStopped;
|
||||
unsigned int keepGoing;
|
||||
|
||||
mozilla::Mutex lock;
|
||||
|
||||
void* user;
|
||||
ANPAudioCallbackProc proc;
|
||||
ANPSampleFormat format;
|
||||
|
||||
ANPAudioTrack() : lock("ANPAudioTrack") { }
|
||||
};
|
||||
|
||||
class AudioRunnable : public mozilla::Runnable
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
AudioRunnable(ANPAudioTrack* aAudioTrack) :
|
||||
Runnable("AudioRunnable")
|
||||
{
|
||||
mTrack = aAudioTrack;
|
||||
}
|
||||
|
||||
ANPAudioTrack* mTrack;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioRunnable::Run()
|
||||
{
|
||||
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 2);
|
||||
|
||||
jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize);
|
||||
if (!bytearray) {
|
||||
LOG("AudioRunnable:: Run. Could not create bytearray");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
jbyte *byte = jenv->GetByteArrayElements(bytearray, nullptr);
|
||||
if (!byte) {
|
||||
LOG("AudioRunnable:: Run. Could not create bytearray");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
ANPAudioBuffer buffer;
|
||||
buffer.channelCount = mTrack->channels;
|
||||
buffer.format = mTrack->format;
|
||||
buffer.bufferData = (void*) byte;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// reset the buffer size
|
||||
buffer.size = mTrack->bufferSize;
|
||||
|
||||
{
|
||||
mozilla::MutexAutoLock lock(mTrack->lock);
|
||||
|
||||
if (!mTrack->keepGoing)
|
||||
break;
|
||||
|
||||
// Get data from the plugin
|
||||
mTrack->proc(kMoreData_ANPAudioEvent, mTrack->user, &buffer);
|
||||
}
|
||||
|
||||
if (buffer.size == 0) {
|
||||
LOG("%p - kMoreData_ANPAudioEvent", mTrack);
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t wroteSoFar = 0;
|
||||
jint retval;
|
||||
do {
|
||||
retval = jenv->CallIntMethod(mTrack->output_unit,
|
||||
at.write,
|
||||
bytearray,
|
||||
wroteSoFar,
|
||||
buffer.size - wroteSoFar);
|
||||
if (retval < 0) {
|
||||
LOG("%p - Write failed %d", mTrack, retval);
|
||||
break;
|
||||
}
|
||||
|
||||
wroteSoFar += retval;
|
||||
|
||||
} while(wroteSoFar < buffer.size);
|
||||
}
|
||||
|
||||
jenv->CallVoidMethod(mTrack->output_unit, at.release);
|
||||
|
||||
jenv->DeleteGlobalRef(mTrack->output_unit);
|
||||
jenv->DeleteGlobalRef(mTrack->at_class);
|
||||
|
||||
delete mTrack;
|
||||
|
||||
jenv->ReleaseByteArrayElements(bytearray, byte, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ANPAudioTrack*
|
||||
anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
|
||||
ANPSampleFormat format,
|
||||
int channelCount, // MONO=1, STEREO=2
|
||||
ANPAudioCallbackProc proc,
|
||||
void* user)
|
||||
{
|
||||
ANPAudioTrack *s = new ANPAudioTrack();
|
||||
if (s == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
|
||||
|
||||
s->at_class = init_jni_bindings(jenv);
|
||||
s->rate = sampleRate;
|
||||
s->channels = channelCount;
|
||||
s->bufferSize = s->rate * s->channels;
|
||||
s->isStopped = true;
|
||||
s->keepGoing = false;
|
||||
s->user = user;
|
||||
s->proc = proc;
|
||||
s->format = format;
|
||||
|
||||
int jformat;
|
||||
switch (format) {
|
||||
case kPCM16Bit_ANPSampleFormat:
|
||||
jformat = ENCODING_PCM_16BIT;
|
||||
break;
|
||||
case kPCM8Bit_ANPSampleFormat:
|
||||
jformat = ENCODING_PCM_8BIT;
|
||||
break;
|
||||
default:
|
||||
LOG("Unknown audio format. defaulting to 16bit.");
|
||||
jformat = ENCODING_PCM_16BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
int jChannels;
|
||||
switch (channelCount) {
|
||||
case 1:
|
||||
jChannels = CHANNEL_OUT_MONO;
|
||||
break;
|
||||
case 2:
|
||||
jChannels = CHANNEL_OUT_STEREO;
|
||||
break;
|
||||
default:
|
||||
LOG("Unknown channel count. defaulting to mono.");
|
||||
jChannels = CHANNEL_OUT_MONO;
|
||||
break;
|
||||
}
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv);
|
||||
|
||||
jobject obj = jenv->NewObject(s->at_class,
|
||||
at.constructor,
|
||||
STREAM_MUSIC,
|
||||
s->rate,
|
||||
jChannels,
|
||||
jformat,
|
||||
s->bufferSize,
|
||||
MODE_STREAM);
|
||||
|
||||
if (autoFrame.CheckForException() || obj == nullptr) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
delete s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jint state = jenv->CallIntMethod(obj, at.getstate);
|
||||
|
||||
if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
delete s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s->output_unit = jenv->NewGlobalRef(obj);
|
||||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
anp_audio_deleteTrack(ANPAudioTrack* s)
|
||||
{
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
mozilla::MutexAutoLock lock(s->lock);
|
||||
s->keepGoing = false;
|
||||
|
||||
// deallocation happens in the AudioThread. There is a
|
||||
// potential leak if anp_audio_start is never called, but
|
||||
// we do not see that from flash.
|
||||
}
|
||||
|
||||
void
|
||||
anp_audio_start(ANPAudioTrack* s)
|
||||
{
|
||||
if (s == nullptr || s->output_unit == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->keepGoing) {
|
||||
// we are already playing. Ignore.
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.play);
|
||||
|
||||
if (autoFrame.CheckForException()) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
delete s;
|
||||
return;
|
||||
}
|
||||
|
||||
s->isStopped = false;
|
||||
s->keepGoing = true;
|
||||
|
||||
// AudioRunnable now owns the ANPAudioTrack
|
||||
RefPtr<AudioRunnable> runnable = new AudioRunnable(s);
|
||||
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
NS_NewNamedThread("Android Audio", getter_AddRefs(thread), runnable);
|
||||
}
|
||||
|
||||
void
|
||||
anp_audio_pause(ANPAudioTrack* s)
|
||||
{
|
||||
if (s == nullptr || s->output_unit == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.pause);
|
||||
}
|
||||
|
||||
void
|
||||
anp_audio_stop(ANPAudioTrack* s)
|
||||
{
|
||||
if (s == nullptr || s->output_unit == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
s->isStopped = true;
|
||||
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.stop);
|
||||
}
|
||||
|
||||
bool
|
||||
anp_audio_isStopped(ANPAudioTrack* s)
|
||||
{
|
||||
return s->isStopped;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
anp_audio_trackLatency(ANPAudioTrack* s) {
|
||||
// Hardcode an estimate of the system's audio latency. Flash hardcodes
|
||||
// similar latency estimates for pre-Honeycomb devices that do not support
|
||||
// ANPAudioTrackInterfaceV1's trackLatency(). The Android stock browser
|
||||
// calls android::AudioTrack::latency(), an internal Android API that is
|
||||
// not available in the public NDK:
|
||||
// https://github.com/android/platform_external_webkit/commit/49bf866973cb3b2a6c74c0eab864e9562e4cbab1
|
||||
return 100; // milliseconds
|
||||
}
|
||||
|
||||
void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, newTrack);
|
||||
ASSIGN(i, deleteTrack);
|
||||
ASSIGN(i, start);
|
||||
ASSIGN(i, pause);
|
||||
ASSIGN(i, stop);
|
||||
ASSIGN(i, isStopped);
|
||||
}
|
||||
|
||||
void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, newTrack);
|
||||
ASSIGN(i, deleteTrack);
|
||||
ASSIGN(i, start);
|
||||
ASSIGN(i, pause);
|
||||
ASSIGN(i, stop);
|
||||
ASSIGN(i, isStopped);
|
||||
ASSIGN(i, trackLatency);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "android_npapi.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
#define NOT_IMPLEMENTED_FATAL() do { \
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \
|
||||
"%s not implemented %s, %d", \
|
||||
__PRETTY_FUNCTION__, __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} while(0)
|
||||
|
||||
#define NOT_IMPLEMENTED() \
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \
|
||||
"!!!!!!!!!!!!!! %s not implemented %s, %d", \
|
||||
__PRETTY_FUNCTION__, __FILE__, __LINE__); \
|
||||
|
||||
void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i);
|
||||
void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1* i);
|
||||
void InitCanvasInterface(ANPCanvasInterfaceV0 *i);
|
||||
void InitEventInterface(ANPEventInterfaceV0 *i);
|
||||
void InitLogInterface(ANPLogInterfaceV0 *i);
|
||||
void InitPaintInterface(ANPPaintInterfaceV0 *i);
|
||||
void InitSurfaceInterface(ANPSurfaceInterfaceV0 *i);
|
||||
void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i);
|
||||
void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i);
|
||||
void InitTypeFaceInterface(ANPTypefaceInterfaceV0 *i);
|
||||
void InitWindowInterface(ANPWindowInterfaceV0 *i);
|
||||
void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i);
|
||||
void InitVideoInterfaceV1(ANPVideoInterfaceV1 *i);
|
||||
void InitOpenGLInterface(ANPOpenGLInterfaceV0 *i);
|
||||
void InitNativeWindowInterface(ANPNativeWindowInterfaceV0 *i);
|
|
@ -1,31 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "assert.h"
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_event_##name
|
||||
|
||||
void
|
||||
anp_event_postEvent(NPP instance, const ANPEvent* event)
|
||||
{
|
||||
LOG("%s", __PRETTY_FUNCTION__);
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
pinst->PostEvent((void*) event);
|
||||
|
||||
LOG("returning from %s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
void InitEventInterface(ANPEventInterfaceV0 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, postEvent);
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ANPKeyCodes_DEFINED
|
||||
#define ANPKeyCodes_DEFINED
|
||||
|
||||
/* List the key codes that are set to a plugin in the ANPKeyEvent.
|
||||
|
||||
These exactly match the values in android/view/KeyEvent.java and the
|
||||
corresponding .h file android/keycodes.h.
|
||||
*/
|
||||
enum ANPKeyCodes {
|
||||
kUnknown_ANPKeyCode = 0,
|
||||
|
||||
kSoftLeft_ANPKeyCode = 1,
|
||||
kSoftRight_ANPKeyCode = 2,
|
||||
kHome_ANPKeyCode = 3,
|
||||
kBack_ANPKeyCode = 4,
|
||||
kCall_ANPKeyCode = 5,
|
||||
kEndCall_ANPKeyCode = 6,
|
||||
k0_ANPKeyCode = 7,
|
||||
k1_ANPKeyCode = 8,
|
||||
k2_ANPKeyCode = 9,
|
||||
k3_ANPKeyCode = 10,
|
||||
k4_ANPKeyCode = 11,
|
||||
k5_ANPKeyCode = 12,
|
||||
k6_ANPKeyCode = 13,
|
||||
k7_ANPKeyCode = 14,
|
||||
k8_ANPKeyCode = 15,
|
||||
k9_ANPKeyCode = 16,
|
||||
kStar_ANPKeyCode = 17,
|
||||
kPound_ANPKeyCode = 18,
|
||||
kDpadUp_ANPKeyCode = 19,
|
||||
kDpadDown_ANPKeyCode = 20,
|
||||
kDpadLeft_ANPKeyCode = 21,
|
||||
kDpadRight_ANPKeyCode = 22,
|
||||
kDpadCenter_ANPKeyCode = 23,
|
||||
kVolumeUp_ANPKeyCode = 24,
|
||||
kVolumeDown_ANPKeyCode = 25,
|
||||
kPower_ANPKeyCode = 26,
|
||||
kCamera_ANPKeyCode = 27,
|
||||
kClear_ANPKeyCode = 28,
|
||||
kA_ANPKeyCode = 29,
|
||||
kB_ANPKeyCode = 30,
|
||||
kC_ANPKeyCode = 31,
|
||||
kD_ANPKeyCode = 32,
|
||||
kE_ANPKeyCode = 33,
|
||||
kF_ANPKeyCode = 34,
|
||||
kG_ANPKeyCode = 35,
|
||||
kH_ANPKeyCode = 36,
|
||||
kI_ANPKeyCode = 37,
|
||||
kJ_ANPKeyCode = 38,
|
||||
kK_ANPKeyCode = 39,
|
||||
kL_ANPKeyCode = 40,
|
||||
kM_ANPKeyCode = 41,
|
||||
kN_ANPKeyCode = 42,
|
||||
kO_ANPKeyCode = 43,
|
||||
kP_ANPKeyCode = 44,
|
||||
kQ_ANPKeyCode = 45,
|
||||
kR_ANPKeyCode = 46,
|
||||
kS_ANPKeyCode = 47,
|
||||
kT_ANPKeyCode = 48,
|
||||
kU_ANPKeyCode = 49,
|
||||
kV_ANPKeyCode = 50,
|
||||
kW_ANPKeyCode = 51,
|
||||
kX_ANPKeyCode = 52,
|
||||
kY_ANPKeyCode = 53,
|
||||
kZ_ANPKeyCode = 54,
|
||||
kComma_ANPKeyCode = 55,
|
||||
kPeriod_ANPKeyCode = 56,
|
||||
kAltLeft_ANPKeyCode = 57,
|
||||
kAltRight_ANPKeyCode = 58,
|
||||
kShiftLeft_ANPKeyCode = 59,
|
||||
kShiftRight_ANPKeyCode = 60,
|
||||
kTab_ANPKeyCode = 61,
|
||||
kSpace_ANPKeyCode = 62,
|
||||
kSym_ANPKeyCode = 63,
|
||||
kExplorer_ANPKeyCode = 64,
|
||||
kEnvelope_ANPKeyCode = 65,
|
||||
kNewline_ANPKeyCode = 66,
|
||||
kDel_ANPKeyCode = 67,
|
||||
kGrave_ANPKeyCode = 68,
|
||||
kMinus_ANPKeyCode = 69,
|
||||
kEquals_ANPKeyCode = 70,
|
||||
kLeftBracket_ANPKeyCode = 71,
|
||||
kRightBracket_ANPKeyCode = 72,
|
||||
kBackslash_ANPKeyCode = 73,
|
||||
kSemicolon_ANPKeyCode = 74,
|
||||
kApostrophe_ANPKeyCode = 75,
|
||||
kSlash_ANPKeyCode = 76,
|
||||
kAt_ANPKeyCode = 77,
|
||||
kNum_ANPKeyCode = 78,
|
||||
kHeadSetHook_ANPKeyCode = 79,
|
||||
kFocus_ANPKeyCode = 80,
|
||||
kPlus_ANPKeyCode = 81,
|
||||
kMenu_ANPKeyCode = 82,
|
||||
kNotification_ANPKeyCode = 83,
|
||||
kSearch_ANPKeyCode = 84,
|
||||
kMediaPlayPause_ANPKeyCode = 85,
|
||||
kMediaStop_ANPKeyCode = 86,
|
||||
kMediaNext_ANPKeyCode = 87,
|
||||
kMediaPrevious_ANPKeyCode = 88,
|
||||
kMediaRewind_ANPKeyCode = 89,
|
||||
kMediaFastForward_ANPKeyCode = 90,
|
||||
kMute_ANPKeyCode = 91,
|
||||
kPageUp_ANPKeyCode = 92,
|
||||
kPageDown_ANPKeyCode = 93,
|
||||
kPictsymbols_ANPKeyCode = 94,
|
||||
kSwitchCharset_ANPKeyCode = 95,
|
||||
kButtonA_ANPKeyCode = 96,
|
||||
kButtonB_ANPKeyCode = 97,
|
||||
kButtonC_ANPKeyCode = 98,
|
||||
kButtonX_ANPKeyCode = 99,
|
||||
kButtonY_ANPKeyCode = 100,
|
||||
kButtonZ_ANPKeyCode = 101,
|
||||
kButtonL1_ANPKeyCode = 102,
|
||||
kButtonR1_ANPKeyCode = 103,
|
||||
kButtonL2_ANPKeyCode = 104,
|
||||
kButtonR2_ANPKeyCode = 105,
|
||||
kButtonThumbL_ANPKeyCode = 106,
|
||||
kButtonThumbR_ANPKeyCode = 107,
|
||||
kButtonStart_ANPKeyCode = 108,
|
||||
kButtonSelect_ANPKeyCode = 109,
|
||||
kButtonMode_ANPKeyCode = 110,
|
||||
|
||||
// NOTE: If you add a new keycode here you must also add it to several other files.
|
||||
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,26 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "assert.h"
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_log_##name
|
||||
|
||||
void
|
||||
anp_log_log(ANPLogType type, const char format[], ...) {
|
||||
|
||||
va_list argp;
|
||||
va_start(argp,format);
|
||||
__android_log_vprint(type == kError_ANPLogType ? ANDROID_LOG_ERROR : type == kWarning_ANPLogType ?
|
||||
ANDROID_LOG_WARN : ANDROID_LOG_INFO, "GeckoPluginLog", format, argp);
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
void InitLogInterface(ANPLogInterfaceV0 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, log);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// must include config.h first for webkit to fiddle with new/delete
|
||||
#include <android/log.h>
|
||||
#include "ANPBase.h"
|
||||
#include "nsIPluginInstanceOwner.h"
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "gfxRect.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_native_window_##name
|
||||
|
||||
static ANPNativeWindow anp_native_window_acquireNativeWindow(NPP instance) {
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
return pinst->AcquireContentWindow();
|
||||
}
|
||||
|
||||
static void anp_native_window_invertPluginContent(NPP instance, bool isContentInverted) {
|
||||
// NativeWindow is TopLeft if uninverted.
|
||||
gl::OriginPos newOriginPos = gl::OriginPos::TopLeft;
|
||||
if (isContentInverted)
|
||||
newOriginPos = gl::OriginPos::BottomLeft;
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
pinst->SetOriginPos(newOriginPos);
|
||||
pinst->RedrawPlugin();
|
||||
}
|
||||
|
||||
|
||||
void InitNativeWindowInterface(ANPNativeWindowInterfaceV0* i) {
|
||||
ASSIGN(i, acquireNativeWindow);
|
||||
ASSIGN(i, invertPluginContent);
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <android/log.h>
|
||||
#include "ANPBase.h"
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_surface_##name
|
||||
|
||||
#define CLEAR_EXCEPTION(env) if (env->ExceptionOccurred()) env->ExceptionClear();
|
||||
|
||||
#define ANDROID_REGION_SIZE 512
|
||||
|
||||
enum {
|
||||
PIXEL_FORMAT_RGBA_8888 = 1,
|
||||
PIXEL_FORMAT_RGB_565 = 4,
|
||||
};
|
||||
|
||||
struct SurfaceInfo {
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
uint32_t s;
|
||||
uint32_t usage;
|
||||
uint32_t format;
|
||||
unsigned char* bits;
|
||||
uint32_t reserved[2];
|
||||
};
|
||||
|
||||
typedef struct ARect {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} ARect;
|
||||
|
||||
|
||||
// used to cache JNI method and field IDs for Surface Objects
|
||||
static struct ANPSurfaceInterfaceJavaGlue {
|
||||
bool initialized;
|
||||
jmethodID getSurfaceHolder;
|
||||
jmethodID getSurface;
|
||||
jfieldID surfacePointer;
|
||||
} gSurfaceJavaGlue;
|
||||
|
||||
static struct ANPSurfaceFunctions {
|
||||
bool initialized;
|
||||
|
||||
int (* lock)(void*, SurfaceInfo*, void*);
|
||||
int (* unlockAndPost)(void*);
|
||||
|
||||
void* (* regionConstructor)(void*);
|
||||
void (* setRegion)(void*, ARect const&);
|
||||
} gSurfaceFunctions;
|
||||
|
||||
|
||||
static inline void* getSurface(JNIEnv* env, jobject view) {
|
||||
if (!env || !view) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gSurfaceJavaGlue.initialized) {
|
||||
|
||||
jclass surfaceViewClass = env->FindClass("android/view/SurfaceView");
|
||||
gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", "()Landroid/view/SurfaceHolder;");
|
||||
|
||||
jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder");
|
||||
gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", "()Landroid/view/Surface;");
|
||||
|
||||
jclass surfaceClass = env->FindClass("android/view/Surface");
|
||||
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
|
||||
"mSurfacePointer", "I");
|
||||
|
||||
if (!gSurfaceJavaGlue.surfacePointer) {
|
||||
CLEAR_EXCEPTION(env);
|
||||
|
||||
// It was something else in 2.2.
|
||||
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
|
||||
"mSurface", "I");
|
||||
|
||||
if (!gSurfaceJavaGlue.surfacePointer) {
|
||||
CLEAR_EXCEPTION(env);
|
||||
|
||||
// And something else in 2.3+
|
||||
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
|
||||
"mNativeSurface", "I");
|
||||
|
||||
CLEAR_EXCEPTION(env);
|
||||
}
|
||||
}
|
||||
|
||||
if (!gSurfaceJavaGlue.surfacePointer) {
|
||||
LOG("Failed to acquire surface pointer");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(surfaceClass);
|
||||
env->DeleteLocalRef(surfaceViewClass);
|
||||
env->DeleteLocalRef(surfaceHolderClass);
|
||||
|
||||
gSurfaceJavaGlue.initialized = (gSurfaceJavaGlue.surfacePointer != nullptr);
|
||||
}
|
||||
|
||||
jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder);
|
||||
jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface);
|
||||
jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer);
|
||||
|
||||
env->DeleteLocalRef(holder);
|
||||
env->DeleteLocalRef(surface);
|
||||
|
||||
return reinterpret_cast<void*>(uintptr_t(surfacePointer));
|
||||
}
|
||||
|
||||
static ANPBitmapFormat convertPixelFormat(int32_t format) {
|
||||
switch (format) {
|
||||
case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_ANPBitmapFormat;
|
||||
case PIXEL_FORMAT_RGB_565: return kRGB_565_ANPBitmapFormat;
|
||||
default: return kUnknown_ANPBitmapFormat;
|
||||
}
|
||||
}
|
||||
|
||||
static int bytesPerPixel(int32_t format) {
|
||||
switch (format) {
|
||||
case PIXEL_FORMAT_RGBA_8888: return 4;
|
||||
case PIXEL_FORMAT_RGB_565: return 2;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static bool init() {
|
||||
if (gSurfaceFunctions.initialized)
|
||||
return true;
|
||||
|
||||
void* handle = dlopen("libsurfaceflinger_client.so", RTLD_LAZY);
|
||||
|
||||
if (!handle) {
|
||||
LOG("Failed to open libsurfaceflinger_client.so");
|
||||
return false;
|
||||
}
|
||||
|
||||
gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionEb");
|
||||
gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv");
|
||||
|
||||
|
||||
if (!gSurfaceFunctions.lock) {
|
||||
// Stuff changed in 3.0/4.0
|
||||
handle = dlopen("libgui.so", RTLD_LAZY);
|
||||
gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE");
|
||||
gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv");
|
||||
}
|
||||
|
||||
handle = dlopen("libui.so", RTLD_LAZY);
|
||||
if (!handle) {
|
||||
LOG("Failed to open libui.so");
|
||||
return false;
|
||||
}
|
||||
|
||||
gSurfaceFunctions.regionConstructor = (void* (*)(void*))dlsym(handle, "_ZN7android6RegionC1Ev");
|
||||
gSurfaceFunctions.setRegion = (void (*)(void*, ARect const&))dlsym(handle, "_ZN7android6Region3setERKNS_4RectE");
|
||||
|
||||
gSurfaceFunctions.initialized = (gSurfaceFunctions.lock && gSurfaceFunctions.unlockAndPost &&
|
||||
gSurfaceFunctions.regionConstructor && gSurfaceFunctions.setRegion);
|
||||
LOG("Initialized? %d\n", gSurfaceFunctions.initialized);
|
||||
return gSurfaceFunctions.initialized;
|
||||
}
|
||||
|
||||
// FIXME: All of this should be changed to use the equivalent things in AndroidBridge, bug 758612
|
||||
static bool anp_surface_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap, ANPRectI* dirtyRect) {
|
||||
if (!bitmap || !surfaceView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void* surface = getSurface(env, surfaceView);
|
||||
|
||||
if (!bitmap || !surface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void* region = nullptr;
|
||||
if (dirtyRect) {
|
||||
region = malloc(ANDROID_REGION_SIZE);
|
||||
gSurfaceFunctions.regionConstructor(region);
|
||||
|
||||
ARect rect;
|
||||
rect.left = dirtyRect->left;
|
||||
rect.top = dirtyRect->top;
|
||||
rect.right = dirtyRect->right;
|
||||
rect.bottom = dirtyRect->bottom;
|
||||
|
||||
gSurfaceFunctions.setRegion(region, rect);
|
||||
}
|
||||
|
||||
SurfaceInfo info;
|
||||
int err = gSurfaceFunctions.lock(surface, &info, region);
|
||||
if (err < 0) {
|
||||
LOG("Failed to lock surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
// the surface may have expanded the dirty region so we must to pass that
|
||||
// information back to the plugin.
|
||||
if (dirtyRect) {
|
||||
ARect* dirtyBounds = (ARect*)region; // The bounds are the first member, so this should work!
|
||||
|
||||
dirtyRect->left = dirtyBounds->left;
|
||||
dirtyRect->right = dirtyBounds->right;
|
||||
dirtyRect->top = dirtyBounds->top;
|
||||
dirtyRect->bottom = dirtyBounds->bottom;
|
||||
}
|
||||
|
||||
if (region)
|
||||
free(region);
|
||||
|
||||
int bpr = info.s * bytesPerPixel(info.format);
|
||||
|
||||
bitmap->format = convertPixelFormat(info.format);
|
||||
bitmap->width = info.w;
|
||||
bitmap->height = info.h;
|
||||
bitmap->rowBytes = bpr;
|
||||
|
||||
if (info.w > 0 && info.h > 0) {
|
||||
bitmap->baseAddr = info.bits;
|
||||
} else {
|
||||
bitmap->baseAddr = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void anp_surface_unlock(JNIEnv* env, jobject surfaceView) {
|
||||
if (!surfaceView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
|
||||
void* surface = getSurface(env, surfaceView);
|
||||
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
gSurfaceFunctions.unlockAndPost(surface);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void InitSurfaceInterface(ANPSurfaceInterfaceV0* i) {
|
||||
ASSIGN(i, lock);
|
||||
ASSIGN(i, unlock);
|
||||
|
||||
// setup the java glue struct
|
||||
gSurfaceJavaGlue.initialized = false;
|
||||
|
||||
// setup the function struct
|
||||
gSurfaceFunctions.initialized = false;
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "ANPBase.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "PluginPRLibrary.h"
|
||||
#include "assert.h"
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_system_##name
|
||||
|
||||
const char*
|
||||
anp_system_getApplicationDataDirectory(NPP instance)
|
||||
{
|
||||
static const char *dir = nullptr;
|
||||
static const char *privateDir = nullptr;
|
||||
|
||||
bool isPrivate = false;
|
||||
|
||||
if (!dir) {
|
||||
dir = getenv("ANDROID_PLUGIN_DATADIR");
|
||||
}
|
||||
|
||||
if (!privateDir) {
|
||||
privateDir = getenv("ANDROID_PLUGIN_DATADIR_PRIVATE");
|
||||
}
|
||||
|
||||
if (!instance) {
|
||||
return dir;
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
if (pinst && NS_SUCCEEDED(pinst->IsPrivateBrowsing(&isPrivate)) && isPrivate) {
|
||||
return privateDir;
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
const char*
|
||||
anp_system_getApplicationDataDirectory()
|
||||
{
|
||||
return anp_system_getApplicationDataDirectory(nullptr);
|
||||
}
|
||||
|
||||
jclass anp_system_loadJavaClass(NPP instance, const char* className)
|
||||
{
|
||||
LOG("%s", __PRETTY_FUNCTION__);
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
mozilla::PluginPRLibrary* lib = static_cast<mozilla::PluginPRLibrary*>(pinst->GetPlugin()->GetLibrary());
|
||||
|
||||
nsCString libName;
|
||||
lib->GetLibraryPath(libName);
|
||||
|
||||
return mozilla::java::GeckoAppShell::LoadPluginClass(className, libName).Forget();
|
||||
}
|
||||
|
||||
void anp_system_setPowerState(NPP instance, ANPPowerState powerState)
|
||||
{
|
||||
nsNPAPIPluginInstance* pinst = nsNPAPIPluginInstance::GetFromNPP(instance);
|
||||
|
||||
if (pinst) {
|
||||
pinst->SetWakeLock(powerState == kScreenOn_ANPPowerState);
|
||||
}
|
||||
}
|
||||
|
||||
void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, getApplicationDataDirectory);
|
||||
ASSIGN(i, loadJavaClass);
|
||||
ASSIGN(i, setPowerState);
|
||||
}
|
||||
|
||||
void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, getApplicationDataDirectory);
|
||||
ASSIGN(i, loadJavaClass);
|
||||
ASSIGN(i, setPowerState);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <android/log.h>
|
||||
#include "ANPBase.h"
|
||||
#include "nsIPluginInstanceOwner.h"
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "gfxRect.h"
|
||||
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_video_##name
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
|
||||
|
||||
static ANPNativeWindow anp_video_acquireNativeWindow(NPP instance) {
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
|
||||
return pinst->AcquireVideoWindow();
|
||||
}
|
||||
|
||||
static void anp_video_setWindowDimensions(NPP instance, const ANPNativeWindow window,
|
||||
const ANPRectF* dimensions) {
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
|
||||
gfxRect rect(dimensions->left, dimensions->top,
|
||||
dimensions->right - dimensions->left,
|
||||
dimensions->bottom - dimensions->top);
|
||||
|
||||
pinst->SetVideoDimensions(window, rect);
|
||||
pinst->RedrawPlugin();
|
||||
}
|
||||
|
||||
static void anp_video_releaseNativeWindow(NPP instance, ANPNativeWindow window) {
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
pinst->ReleaseVideoWindow(window);
|
||||
pinst->RedrawPlugin();
|
||||
}
|
||||
|
||||
static void anp_video_setFramerateCallback(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc callback) {
|
||||
// Bug 722682
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void InitVideoInterfaceV1(ANPVideoInterfaceV1* i) {
|
||||
ASSIGN(i, acquireNativeWindow);
|
||||
ASSIGN(i, setWindowDimensions);
|
||||
ASSIGN(i, releaseNativeWindow);
|
||||
ASSIGN(i, setFramerateCallback);
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "assert.h"
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
#include "nsWindow.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
#undef LOG
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_window_##name
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
void
|
||||
anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
void
|
||||
anp_window_clearVisibleRects(NPP instance)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
void
|
||||
anp_window_showKeyboard(NPP instance, bool value)
|
||||
{
|
||||
InputContext context;
|
||||
context.mIMEState.mEnabled = value ? IMEState::PLUGIN : IMEState::DISABLED;
|
||||
context.mIMEState.mOpen = value ? IMEState::OPEN : IMEState::CLOSED;
|
||||
context.mActionHint.Assign(EmptyString());
|
||||
|
||||
InputContextAction action;
|
||||
action.mCause = InputContextAction::CAUSE_UNKNOWN;
|
||||
action.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED;
|
||||
|
||||
nsWindow* window = nsWindow::TopWindow();
|
||||
if (!window) {
|
||||
LOG("Couldn't get top window?");
|
||||
return;
|
||||
}
|
||||
|
||||
window->SetInputContext(context, action);
|
||||
}
|
||||
|
||||
void
|
||||
anp_window_requestFullScreen(NPP instance)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
|
||||
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
owner->RequestFullScreen();
|
||||
}
|
||||
|
||||
void
|
||||
anp_window_exitFullScreen(NPP instance)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
|
||||
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
owner->ExitFullScreen();
|
||||
}
|
||||
|
||||
void
|
||||
anp_window_requestCenterFitZoom(NPP instance)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
ANPRectI
|
||||
anp_window_visibleRect(NPP instance)
|
||||
{
|
||||
ANPRectI rect = { 0, 0, 0, 0 };
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
|
||||
nsIntSize currentSize = pinst->CurrentSize();
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = currentSize.width;
|
||||
rect.bottom = currentSize.height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
void anp_window_requestFullScreenOrientation(NPP instance, ANPScreenOrientation orientation)
|
||||
{
|
||||
short newOrientation;
|
||||
|
||||
// Convert to the ActivityInfo equivalent
|
||||
switch (orientation) {
|
||||
case kFixedLandscape_ANPScreenOrientation:
|
||||
newOrientation = eScreenOrientation_LandscapePrimary;
|
||||
break;
|
||||
case kFixedPortrait_ANPScreenOrientation:
|
||||
newOrientation = eScreenOrientation_PortraitPrimary;
|
||||
break;
|
||||
case kLandscape_ANPScreenOrientation:
|
||||
newOrientation = eScreenOrientation_LandscapePrimary |
|
||||
eScreenOrientation_LandscapeSecondary;
|
||||
break;
|
||||
case kPortrait_ANPScreenOrientation:
|
||||
newOrientation = eScreenOrientation_PortraitPrimary |
|
||||
eScreenOrientation_PortraitSecondary;
|
||||
break;
|
||||
default:
|
||||
newOrientation = eScreenOrientation_None;
|
||||
break;
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
pinst->SetFullScreenOrientation(newOrientation);
|
||||
}
|
||||
|
||||
void InitWindowInterface(ANPWindowInterfaceV0 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, setVisibleRects);
|
||||
ASSIGN(i, clearVisibleRects);
|
||||
ASSIGN(i, showKeyboard);
|
||||
ASSIGN(i, requestFullScreen);
|
||||
ASSIGN(i, exitFullScreen);
|
||||
ASSIGN(i, requestCenterFitZoom);
|
||||
}
|
||||
|
||||
void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i) {
|
||||
_assert(i->inSize == sizeof(*i));
|
||||
ASSIGN(i, setVisibleRects);
|
||||
ASSIGN(i, clearVisibleRects);
|
||||
ASSIGN(i, showKeyboard);
|
||||
ASSIGN(i, requestFullScreen);
|
||||
ASSIGN(i, exitFullScreen);
|
||||
ASSIGN(i, requestCenterFitZoom);
|
||||
ASSIGN(i, visibleRect);
|
||||
ASSIGN(i, requestFullScreenOrientation);
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,35 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'android_npapi.h',
|
||||
'ANPKeyCodes.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'ANPAudio.cpp',
|
||||
'ANPEvent.cpp',
|
||||
'ANPLog.cpp',
|
||||
'ANPNativeWindow.cpp',
|
||||
'ANPSurface.cpp',
|
||||
'ANPSystem.cpp',
|
||||
'ANPVideo.cpp',
|
||||
'ANPWindow.cpp',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/plugins/base',
|
||||
'/gfx/gl',
|
||||
'/widget',
|
||||
'/widget/android',
|
||||
]
|
||||
|
||||
DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME']
|
||||
|
||||
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
|
@ -4,9 +4,6 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
DIRS += ['android']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIHTTPHeaderListener.idl',
|
||||
'nsIPluginDocument.idl',
|
||||
|
@ -80,16 +77,10 @@ LOCAL_INCLUDES += [
|
|||
'/layout/xul',
|
||||
'/netwerk/base',
|
||||
'/widget',
|
||||
'/widget/android',
|
||||
'/widget/cocoa',
|
||||
'/xpcom/base',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/plugins/base/android',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
LOCAL_INCLUDES += [
|
||||
'/xpcom/base',
|
||||
|
@ -97,8 +88,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
|
|||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include "npapi.h"
|
||||
#include "npruntime.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include <jni.h>
|
||||
#endif
|
||||
|
||||
typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
|
||||
typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
|
||||
|
@ -261,14 +257,9 @@ NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs);
|
|||
typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*);
|
||||
NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs);
|
||||
#else
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv);
|
||||
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv);
|
||||
#else
|
||||
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*);
|
||||
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs);
|
||||
#endif
|
||||
#endif
|
||||
typedef NPError (*NP_ShutdownFunc)(void);
|
||||
NP_EXPORT(NPError) NP_Shutdown(void);
|
||||
typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *);
|
||||
|
|
|
@ -96,16 +96,6 @@ using mozilla::plugins::PluginModuleContentParent;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include <android/log.h>
|
||||
#include "android_npapi.h"
|
||||
#include "ANPBase.h"
|
||||
#include "FennecJNIWrappers.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#undef LOG
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#endif
|
||||
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
#include "AudioChannelService.h"
|
||||
|
||||
|
@ -236,11 +226,7 @@ nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
|||
bool
|
||||
nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline PluginLibrary*
|
||||
|
@ -282,7 +268,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
|
||||
#if defined(XP_MACOSX)
|
||||
if (!pluginLib->HasRequiredFunctions()) {
|
||||
NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
|
||||
delete pluginLib;
|
||||
|
@ -1782,159 +1768,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
|||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
case kLogInterfaceV0_ANPGetValue: {
|
||||
LOG("get log interface");
|
||||
ANPLogInterfaceV0 *i = (ANPLogInterfaceV0 *) result;
|
||||
InitLogInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kBitmapInterfaceV0_ANPGetValue: {
|
||||
LOG("get bitmap interface");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kMatrixInterfaceV0_ANPGetValue: {
|
||||
LOG("get matrix interface");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kPathInterfaceV0_ANPGetValue: {
|
||||
LOG("get path interface");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kTypefaceInterfaceV0_ANPGetValue: {
|
||||
LOG("get typeface interface");
|
||||
ANPTypefaceInterfaceV0 *i = (ANPTypefaceInterfaceV0 *) result;
|
||||
InitTypeFaceInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kPaintInterfaceV0_ANPGetValue: {
|
||||
LOG("get paint interface");
|
||||
ANPPaintInterfaceV0 *i = (ANPPaintInterfaceV0 *) result;
|
||||
InitPaintInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kCanvasInterfaceV0_ANPGetValue: {
|
||||
LOG("get canvas interface");
|
||||
ANPCanvasInterfaceV0 *i = (ANPCanvasInterfaceV0 *) result;
|
||||
InitCanvasInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kWindowInterfaceV0_ANPGetValue: {
|
||||
LOG("get window interface");
|
||||
ANPWindowInterfaceV0 *i = (ANPWindowInterfaceV0 *) result;
|
||||
InitWindowInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kAudioTrackInterfaceV0_ANPGetValue: {
|
||||
LOG("get audio interface");
|
||||
ANPAudioTrackInterfaceV0 *i = (ANPAudioTrackInterfaceV0 *) result;
|
||||
InitAudioTrackInterfaceV0(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kEventInterfaceV0_ANPGetValue: {
|
||||
LOG("get event interface");
|
||||
ANPEventInterfaceV0 *i = (ANPEventInterfaceV0 *) result;
|
||||
InitEventInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kSystemInterfaceV0_ANPGetValue: {
|
||||
LOG("get system interface");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kSurfaceInterfaceV0_ANPGetValue: {
|
||||
LOG("get surface interface");
|
||||
ANPSurfaceInterfaceV0 *i = (ANPSurfaceInterfaceV0 *) result;
|
||||
InitSurfaceInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kSupportedDrawingModel_ANPGetValue: {
|
||||
LOG("get supported drawing model");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kJavaContext_ANPGetValue: {
|
||||
LOG("get java context");
|
||||
|
||||
auto ret = npp && jni::IsFennec()
|
||||
? java::GeckoApp::GetPluginContext()
|
||||
: java::GeckoAppShell::GetApplicationContext();
|
||||
if (!ret) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
*static_cast<jobject*>(result) = ret.Forget();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kAudioTrackInterfaceV1_ANPGetValue: {
|
||||
LOG("get audio interface v1");
|
||||
ANPAudioTrackInterfaceV1 *i = (ANPAudioTrackInterfaceV1 *) result;
|
||||
InitAudioTrackInterfaceV1(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kNativeWindowInterfaceV0_ANPGetValue: {
|
||||
LOG("get native window interface v0");
|
||||
ANPNativeWindowInterfaceV0* i = (ANPNativeWindowInterfaceV0 *) result;
|
||||
InitNativeWindowInterface(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kOpenGLInterfaceV0_ANPGetValue: {
|
||||
LOG("get openGL interface");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kWindowInterfaceV1_ANPGetValue: {
|
||||
LOG("get Window interface V1");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kWindowInterfaceV2_ANPGetValue: {
|
||||
LOG("get Window interface V2");
|
||||
ANPWindowInterfaceV2 *i = (ANPWindowInterfaceV2 *) result;
|
||||
InitWindowInterfaceV2(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kVideoInterfaceV0_ANPGetValue: {
|
||||
LOG("get video interface V0");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case kVideoInterfaceV1_ANPGetValue: {
|
||||
LOG("get video interface V1");
|
||||
ANPVideoInterfaceV1 *i = (ANPVideoInterfaceV1*) result;
|
||||
InitVideoInterfaceV1(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kSystemInterfaceV1_ANPGetValue: {
|
||||
LOG("get system interface v1");
|
||||
ANPSystemInterfaceV1* i = reinterpret_cast<ANPSystemInterfaceV1*>(result);
|
||||
InitSystemInterfaceV1(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case kSystemInterfaceV2_ANPGetValue: {
|
||||
LOG("get system interface v2");
|
||||
ANPSystemInterfaceV2* i = reinterpret_cast<ANPSystemInterfaceV2*>(result);
|
||||
InitSystemInterfaceV2(i);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
// we no longer hand out any XPCOM objects
|
||||
case NPNVDOMElement:
|
||||
case NPNVDOMWindow:
|
||||
|
@ -2030,8 +1863,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifndef MOZ_WIDGET_ANDROID
|
||||
// On android, their 'drawing model' uses the same constant!
|
||||
case NPPVpluginDrawingModel: {
|
||||
if (inst) {
|
||||
inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result));
|
||||
|
@ -2039,7 +1870,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
}
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPPVpluginEventModel: {
|
||||
|
@ -2051,14 +1881,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
case kRequestDrawingModel_ANPSetValue:
|
||||
if (inst)
|
||||
inst->SetANPDrawingModel(NS_PTR_TO_INT32(result));
|
||||
return NPERR_NO_ERROR;
|
||||
case kAcceptEvents_ANPSetValue:
|
||||
return NPERR_NO_ERROR;
|
||||
#endif
|
||||
default:
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
@ -2296,13 +2118,7 @@ _unscheduletimer(NPP instance, uint32_t timerID)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Sometimes Flash calls this with a dead NPP instance. Ensure the one we have
|
||||
// here is valid and maps to a nsNPAPIPluginInstance.
|
||||
nsNPAPIPluginInstance *inst = nsNPAPIPluginInstance::GetFromNPP(instance);
|
||||
#else
|
||||
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
||||
#endif
|
||||
if (!inst)
|
||||
return;
|
||||
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// For ScreenOrientation.h and Hal.h
|
||||
#include "base/basictypes.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nscore.h"
|
||||
#include "prenv.h"
|
||||
|
@ -44,71 +39,6 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
#include "android_npapi.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "GLContext.h"
|
||||
#include "TexturePoolOGL.h"
|
||||
#include "SurfaceTypes.h"
|
||||
#include "EGLUtils.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "GeneratedJNINatives.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gl;
|
||||
|
||||
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
|
||||
|
||||
class PluginEventRunnable : public Runnable
|
||||
{
|
||||
public:
|
||||
PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event)
|
||||
: Runnable("PluginEventRunnable"),
|
||||
mInstance(instance),
|
||||
mEvent(*event),
|
||||
mCanceled(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual nsresult Run() {
|
||||
if (mCanceled)
|
||||
return NS_OK;
|
||||
|
||||
mInstance->HandleEvent(&mEvent, nullptr);
|
||||
mInstance->PopPostedEvent(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Cancel() { mCanceled = true; }
|
||||
private:
|
||||
nsNPAPIPluginInstance* mInstance;
|
||||
ANPEvent mEvent;
|
||||
bool mCanceled;
|
||||
};
|
||||
|
||||
static RefPtr<GLContext> sPluginContext = nullptr;
|
||||
|
||||
static bool EnsureGLContext()
|
||||
{
|
||||
if (!sPluginContext) {
|
||||
const auto flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE;
|
||||
nsCString discardedFailureId;
|
||||
sPluginContext = GLContextProvider::CreateHeadless(flags, &discardedFailureId);
|
||||
}
|
||||
|
||||
return sPluginContext != nullptr;
|
||||
}
|
||||
|
||||
static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins::parent;
|
||||
using namespace mozilla::layers;
|
||||
|
@ -119,13 +49,6 @@ NS_IMPL_ISUPPORTS(nsNPAPIPluginInstance, nsIAudioChannelAgentCallback)
|
|||
|
||||
nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
||||
: mDrawingModel(kDefaultDrawingModel)
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
, mANPDrawingModel(0)
|
||||
, mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary)
|
||||
, mWakeLocked(false)
|
||||
, mFullScreen(false)
|
||||
, mOriginPos(gl::OriginPos::TopLeft)
|
||||
#endif
|
||||
, mRunning(NOT_STARTED)
|
||||
, mWindowless(false)
|
||||
, mTransparent(false)
|
||||
|
@ -138,9 +61,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
|||
#ifdef XP_MACOSX
|
||||
, mCurrentPluginEvent(nullptr)
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
, mOnScreen(true)
|
||||
#endif
|
||||
, mHaveJavaC2PJSObjectQuirk(false)
|
||||
, mCachedParamLength(0)
|
||||
, mCachedParamNames(nullptr)
|
||||
, mCachedParamValues(nullptr)
|
||||
|
@ -150,20 +71,12 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
|||
mNPP.ndata = this;
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
sPluginNPPMap[&mNPP] = this;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
sPluginNPPMap.erase(&mNPP);
|
||||
#endif
|
||||
|
||||
if (mMIMEType) {
|
||||
free(mMIMEType);
|
||||
mMIMEType = nullptr;
|
||||
|
@ -200,19 +113,6 @@ nsNPAPIPluginInstance::Destroy()
|
|||
Stop();
|
||||
mPlugin = nullptr;
|
||||
mAudioChannelAgent = nullptr;
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
if (mContentSurface) {
|
||||
java::SurfaceAllocator::DisposeSurface(mContentSurface);
|
||||
}
|
||||
|
||||
std::map<void*, VideoInfo*>::iterator it;
|
||||
for (it = mVideos.begin(); it != mVideos.end(); it++) {
|
||||
delete it->second;
|
||||
}
|
||||
mVideos.clear();
|
||||
SetWakeLock(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
|
@ -300,14 +200,6 @@ nsresult nsNPAPIPluginInstance::Stop()
|
|||
}
|
||||
mRunning = DESTROYED;
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
for (uint32_t i = 0; i < mPostedEvents.Length(); i++) {
|
||||
mPostedEvents[i]->Cancel();
|
||||
}
|
||||
|
||||
mPostedEvents.Clear();
|
||||
#endif
|
||||
|
||||
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
||||
|
||||
if (error != NPERR_NO_ERROR)
|
||||
|
@ -398,13 +290,8 @@ nsNPAPIPluginInstance::Start()
|
|||
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
|
||||
}
|
||||
|
||||
// Android expects and empty string instead of null.
|
||||
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
|
||||
#else
|
||||
mCachedParamValues[attributes.Length()] = nullptr;
|
||||
#endif
|
||||
mCachedParamValues[attributes.Length()] = nullptr;
|
||||
|
||||
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
|
||||
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
|
||||
|
@ -594,7 +481,6 @@ nsresult nsNPAPIPluginInstance::HandleEvent(void* event, int16_t* result,
|
|||
NS_TRY_SAFE_CALL_RETURN(tmpResult, (*pluginFunctions->event)(&mNPP, event), this,
|
||||
aSafeToReenterGecko);
|
||||
#else
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
tmpResult = (*pluginFunctions->event)(&mNPP, event);
|
||||
#endif
|
||||
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
||||
|
@ -700,270 +586,6 @@ void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
|
||||
static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aAction)
|
||||
{
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = kLifecycle_ANPEventType;
|
||||
event.data.lifecycle.action = aAction;
|
||||
aInstance->HandleEvent(&event, nullptr);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::NotifyForeground(bool aForeground)
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetForeground this=%p\n foreground=%d",this, aForeground));
|
||||
if (RUNNING != mRunning)
|
||||
return;
|
||||
|
||||
SendLifecycleEvent(this, aForeground ? kResume_ANPLifecycleAction : kPause_ANPLifecycleAction);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::NotifyOnScreen(bool aOnScreen)
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetOnScreen this=%p\n onScreen=%d",this, aOnScreen));
|
||||
if (RUNNING != mRunning || mOnScreen == aOnScreen)
|
||||
return;
|
||||
|
||||
mOnScreen = aOnScreen;
|
||||
SendLifecycleEvent(this, aOnScreen ? kOnScreen_ANPLifecycleAction : kOffScreen_ANPLifecycleAction);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::MemoryPressure()
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::MemoryPressure this=%p\n",this));
|
||||
if (RUNNING != mRunning)
|
||||
return;
|
||||
|
||||
SendLifecycleEvent(this, kFreeMemory_ANPLifecycleAction);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this));
|
||||
|
||||
if (RUNNING != mRunning || mFullScreen == aFullScreen)
|
||||
return;
|
||||
|
||||
mFullScreen = aFullScreen;
|
||||
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
||||
|
||||
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||
java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::NotifySize(nsIntSize size)
|
||||
{
|
||||
if (kOpenGL_ANPDrawingModel != GetANPDrawingModel() ||
|
||||
size == mCurrentSize)
|
||||
return;
|
||||
|
||||
mCurrentSize = size;
|
||||
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = kDraw_ANPEventType;
|
||||
event.data.draw.model = kOpenGL_ANPDrawingModel;
|
||||
event.data.draw.data.surfaceSize.width = size.width;
|
||||
event.data.draw.data.surfaceSize.height = size.height;
|
||||
|
||||
HandleEvent(&event, nullptr);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::SetANPDrawingModel(uint32_t aModel)
|
||||
{
|
||||
mANPDrawingModel = aModel;
|
||||
}
|
||||
|
||||
void* nsNPAPIPluginInstance::GetJavaSurface()
|
||||
{
|
||||
void* surface = nullptr;
|
||||
nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface);
|
||||
if (NS_FAILED(rv))
|
||||
return nullptr;
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::PostEvent(void* event)
|
||||
{
|
||||
PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
|
||||
mPostedEvents.AppendElement(RefPtr<PluginEventRunnable>(r));
|
||||
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
|
||||
{
|
||||
if (mFullScreenOrientation == orientation)
|
||||
return;
|
||||
|
||||
uint32_t oldOrientation = mFullScreenOrientation;
|
||||
mFullScreenOrientation = orientation;
|
||||
|
||||
if (mFullScreen) {
|
||||
// We're already fullscreen so immediately apply the orientation change
|
||||
|
||||
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||
java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
||||
// We applied an orientation when we entered fullscreen, but
|
||||
// we don't want it anymore
|
||||
java::GeckoAppShell::UnlockScreenOrientation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
|
||||
{
|
||||
mPostedEvents.RemoveElement(r);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::SetWakeLock(bool aLocked)
|
||||
{
|
||||
if (aLocked == mWakeLocked)
|
||||
return;
|
||||
|
||||
mWakeLocked = aLocked;
|
||||
hal::ModifyWakeLock(NS_LITERAL_STRING("screen"),
|
||||
mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
|
||||
hal::WAKE_LOCK_NO_CHANGE);
|
||||
}
|
||||
|
||||
GLContext* nsNPAPIPluginInstance::GLContext()
|
||||
{
|
||||
if (!EnsureGLContext())
|
||||
return nullptr;
|
||||
|
||||
return sPluginContext;
|
||||
}
|
||||
|
||||
class PluginTextureListener
|
||||
: public java::SurfaceTextureListener::Natives<PluginTextureListener>
|
||||
{
|
||||
using Base = java::SurfaceTextureListener::Natives<PluginTextureListener>;
|
||||
|
||||
const nsCOMPtr<nsIRunnable> mCallback;
|
||||
public:
|
||||
using Base::AttachNative;
|
||||
using Base::DisposeNative;
|
||||
|
||||
PluginTextureListener(nsIRunnable* aCallback) : mCallback(aCallback) {}
|
||||
|
||||
void OnFrameAvailable()
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
mCallback->Run();
|
||||
return;
|
||||
}
|
||||
NS_DispatchToMainThread(mCallback);
|
||||
}
|
||||
};
|
||||
|
||||
java::GeckoSurface::LocalRef nsNPAPIPluginInstance::CreateSurface()
|
||||
{
|
||||
java::GeckoSurface::LocalRef surf = java::SurfaceAllocator::AcquireSurface(0, 0, false);
|
||||
if (!surf) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod("nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable",
|
||||
this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
|
||||
|
||||
java::SurfaceTextureListener::LocalRef listener = java::SurfaceTextureListener::New();
|
||||
|
||||
PluginTextureListener::AttachNative(listener, MakeUnique<PluginTextureListener>(frameCallback.get()));
|
||||
|
||||
java::GeckoSurfaceTexture::LocalRef gst = java::GeckoSurfaceTexture::Lookup(surf->GetHandle());
|
||||
if (!gst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto& st = java::sdk::SurfaceTexture::Ref::From(gst);
|
||||
st->SetOnFrameAvailableListener(listener);
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
|
||||
{
|
||||
if (mRunning == RUNNING && mOwner)
|
||||
mOwner->Recomposite();
|
||||
}
|
||||
|
||||
void* nsNPAPIPluginInstance::AcquireContentWindow()
|
||||
{
|
||||
if (!mContentWindow.NativeWindow()) {
|
||||
mContentSurface = CreateSurface();
|
||||
if (!mContentSurface)
|
||||
return nullptr;
|
||||
|
||||
mContentWindow = AndroidNativeWindow(mContentSurface);
|
||||
}
|
||||
|
||||
return mContentWindow.NativeWindow();
|
||||
}
|
||||
|
||||
java::GeckoSurface::Param
|
||||
nsNPAPIPluginInstance::AsSurface()
|
||||
{
|
||||
return mContentSurface;
|
||||
}
|
||||
|
||||
void* nsNPAPIPluginInstance::AcquireVideoWindow()
|
||||
{
|
||||
java::GeckoSurface::LocalRef surface = CreateSurface();
|
||||
VideoInfo* info = new VideoInfo(surface);
|
||||
|
||||
void* window = info->mNativeWindow.NativeWindow();
|
||||
mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::ReleaseVideoWindow(void* window)
|
||||
{
|
||||
std::map<void*, VideoInfo*>::iterator it = mVideos.find(window);
|
||||
if (it == mVideos.end())
|
||||
return;
|
||||
|
||||
delete it->second;
|
||||
mVideos.erase(window);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::SetVideoDimensions(void* window, gfxRect aDimensions)
|
||||
{
|
||||
std::map<void*, VideoInfo*>::iterator it;
|
||||
|
||||
it = mVideos.find(window);
|
||||
if (it == mVideos.end())
|
||||
return;
|
||||
|
||||
it->second->mDimensions = aDimensions;
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::GetVideos(nsTArray<VideoInfo*>& aVideos)
|
||||
{
|
||||
std::map<void*, VideoInfo*>::iterator it;
|
||||
for (it = mVideos.begin(); it != mVideos.end(); it++)
|
||||
aVideos.AppendElement(it->second);
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
|
||||
{
|
||||
std::map<NPP, nsNPAPIPluginInstance*>::iterator it;
|
||||
|
||||
it = sPluginNPPMap.find(npp);
|
||||
if (it == sPluginNPPMap.end())
|
||||
return nullptr;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
||||
{
|
||||
*aModel = (int32_t)mDrawingModel;
|
||||
|
@ -1062,9 +684,8 @@ nsNPAPIPluginInstance::ShouldCache()
|
|||
nsresult
|
||||
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
|
||||
{
|
||||
#if defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX)
|
||||
#if defined(XP_MACOSX)
|
||||
// All OS X plugins are windowless.
|
||||
// On android, pre-honeycomb, all plugins are treated as windowless.
|
||||
*isWindowless = true;
|
||||
#else
|
||||
*isWindowless = mWindowless;
|
||||
|
@ -1367,7 +988,6 @@ PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
|||
|
||||
PLUGIN_LOG(PLUGIN_LOG_NOISY, ("nsNPAPIPluginInstance running plugin timer callback this=%p\n", npp->ndata));
|
||||
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
// Some plugins (Flash on Android) calls unscheduletimer
|
||||
// from this callback.
|
||||
t->inCallback = true;
|
||||
|
|
|
@ -18,14 +18,6 @@
|
|||
#include <prinrval.h>
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "nsIRunnable.h"
|
||||
#include "GLContextTypes.h"
|
||||
#include "AndroidNativeWindow.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include <map>
|
||||
class PluginEventRunnable;
|
||||
#endif
|
||||
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
@ -164,92 +156,6 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
void NotifyForeground(bool aForeground);
|
||||
void NotifyOnScreen(bool aOnScreen);
|
||||
void MemoryPressure();
|
||||
void NotifyFullScreen(bool aFullScreen);
|
||||
void NotifySize(nsIntSize size);
|
||||
|
||||
nsIntSize CurrentSize() { return mCurrentSize; }
|
||||
|
||||
bool IsOnScreen() {
|
||||
return mOnScreen;
|
||||
}
|
||||
|
||||
uint32_t GetANPDrawingModel() { return mANPDrawingModel; }
|
||||
void SetANPDrawingModel(uint32_t aModel);
|
||||
|
||||
void* GetJavaSurface();
|
||||
|
||||
void PostEvent(void* event);
|
||||
|
||||
// These are really mozilla::dom::ScreenOrientation, but it's
|
||||
// difficult to include that here
|
||||
uint32_t FullScreenOrientation() { return mFullScreenOrientation; }
|
||||
void SetFullScreenOrientation(uint32_t orientation);
|
||||
|
||||
void SetWakeLock(bool aLock);
|
||||
|
||||
mozilla::gl::GLContext* GLContext();
|
||||
|
||||
// For ANPOpenGL
|
||||
class TextureInfo {
|
||||
public:
|
||||
TextureInfo() :
|
||||
mTexture(0), mWidth(0), mHeight(0), mInternalFormat(0)
|
||||
{
|
||||
}
|
||||
|
||||
TextureInfo(GLuint aTexture, int32_t aWidth, int32_t aHeight, GLuint aInternalFormat) :
|
||||
mTexture(aTexture), mWidth(aWidth), mHeight(aHeight), mInternalFormat(aInternalFormat)
|
||||
{
|
||||
}
|
||||
|
||||
GLuint mTexture;
|
||||
int32_t mWidth;
|
||||
int32_t mHeight;
|
||||
GLuint mInternalFormat;
|
||||
};
|
||||
|
||||
// For ANPNativeWindow
|
||||
void* AcquireContentWindow();
|
||||
|
||||
mozilla::java::GeckoSurface::Param AsSurface();
|
||||
|
||||
// For ANPVideo
|
||||
class VideoInfo {
|
||||
public:
|
||||
VideoInfo(mozilla::java::GeckoSurface::Param aSurface)
|
||||
: mSurface(aSurface)
|
||||
, mNativeWindow(aSurface)
|
||||
{
|
||||
}
|
||||
|
||||
~VideoInfo()
|
||||
{
|
||||
mozilla::java::SurfaceAllocator::DisposeSurface(mSurface);
|
||||
}
|
||||
|
||||
mozilla::java::GeckoSurface::GlobalRef mSurface;
|
||||
mozilla::gl::AndroidNativeWindow mNativeWindow;
|
||||
gfxRect mDimensions;
|
||||
};
|
||||
|
||||
void* AcquireVideoWindow();
|
||||
void ReleaseVideoWindow(void* aWindow);
|
||||
void SetVideoDimensions(void* aWindow, gfxRect aDimensions);
|
||||
|
||||
void GetVideos(nsTArray<VideoInfo*>& aVideos);
|
||||
|
||||
void SetOriginPos(mozilla::gl::OriginPos aOriginPos) {
|
||||
mOriginPos = aOriginPos;
|
||||
}
|
||||
mozilla::gl::OriginPos OriginPos() const { return mOriginPos; }
|
||||
|
||||
static nsNPAPIPluginInstance* GetFromNPP(NPP npp);
|
||||
#endif
|
||||
|
||||
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
||||
nsNPAPIPluginStreamListener** listener);
|
||||
|
||||
|
@ -342,24 +248,6 @@ protected:
|
|||
|
||||
NPDrawingModel mDrawingModel;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
uint32_t mANPDrawingModel;
|
||||
|
||||
friend class PluginEventRunnable;
|
||||
|
||||
nsTArray<RefPtr<PluginEventRunnable>> mPostedEvents;
|
||||
void PopPostedEvent(PluginEventRunnable* r);
|
||||
void OnSurfaceTextureFrameAvailable();
|
||||
|
||||
uint32_t mFullScreenOrientation;
|
||||
bool mWakeLocked;
|
||||
bool mFullScreen;
|
||||
mozilla::gl::OriginPos mOriginPos;
|
||||
|
||||
mozilla::java::GeckoSurface::GlobalRef mContentSurface;
|
||||
mozilla::gl::AndroidNativeWindow mContentWindow;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
NOT_STARTED,
|
||||
RUNNING,
|
||||
|
@ -406,13 +294,8 @@ private:
|
|||
// This is only valid when the plugin is actually stopped!
|
||||
mozilla::TimeStamp mStopTime;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mozilla::java::GeckoSurface::LocalRef CreateSurface();
|
||||
std::map<void*, VideoInfo*> mVideos;
|
||||
bool mOnScreen;
|
||||
|
||||
nsIntSize mCurrentSize;
|
||||
#endif
|
||||
// is this instance Java and affected by bug 750480?
|
||||
bool mHaveJavaC2PJSObjectQuirk;
|
||||
|
||||
static uint32_t gInUnsafePluginCalls;
|
||||
|
||||
|
@ -426,20 +309,11 @@ private:
|
|||
bool mMuted;
|
||||
};
|
||||
|
||||
// On Android, we need to guard against plugin code leaking entries in the local
|
||||
// JNI ref table. See https://bugzilla.mozilla.org/show_bug.cgi?id=780831#c21
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#define MAIN_THREAD_JNI_REF_GUARD mozilla::AutoLocalJNIFrame jniFrame
|
||||
#else
|
||||
#define MAIN_THREAD_JNI_REF_GUARD
|
||||
#endif
|
||||
|
||||
void NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState);
|
||||
void NS_NotifyPluginCall(NSPluginCallReentry aReentryState);
|
||||
|
||||
#define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst, pluginCallReentry) \
|
||||
PR_BEGIN_MACRO \
|
||||
MAIN_THREAD_JNI_REF_GUARD; \
|
||||
NS_NotifyBeginPluginCall(pluginCallReentry); \
|
||||
ret = fun; \
|
||||
NS_NotifyPluginCall(pluginCallReentry); \
|
||||
|
@ -447,7 +321,6 @@ PR_END_MACRO
|
|||
|
||||
#define NS_TRY_SAFE_CALL_VOID(fun, pluginInst, pluginCallReentry) \
|
||||
PR_BEGIN_MACRO \
|
||||
MAIN_THREAD_JNI_REF_GUARD; \
|
||||
NS_NotifyBeginPluginCall(pluginCallReentry); \
|
||||
fun; \
|
||||
NS_NotifyPluginCall(pluginCallReentry); \
|
||||
|
|
|
@ -841,7 +841,6 @@ nsNPAPIPluginStreamListener::HandleRedirectNotification(nsIChannel *oldChannel,
|
|||
NS_TRY_SAFE_CALL_VOID((*pluginFunctions->urlredirectnotify)(npp, spec.get(), static_cast<int32_t>(status), mNPStreamWrapper->mNPStream.notifyData), mInst,
|
||||
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
||||
#else
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
(*pluginFunctions->urlredirectnotify)(npp, spec.get(), static_cast<int32_t>(status), mNPStreamWrapper->mNPStream.notifyData);
|
||||
#endif
|
||||
return true;
|
||||
|
|
|
@ -103,11 +103,6 @@
|
|||
#include "winbase.h"
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#endif
|
||||
|
||||
#if MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
#endif
|
||||
|
@ -278,10 +273,6 @@ nsPluginHost::nsPluginHost()
|
|||
if (obsService) {
|
||||
obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
obsService->AddObserver(this, "blocklist-updated", false);
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
obsService->AddObserver(this, "application-foreground", false);
|
||||
obsService->AddObserver(this, "application-background", false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PLUGIN_LOGGING
|
||||
|
@ -877,12 +868,6 @@ nsPluginHost::TrySetUpPluginInstance(const nsACString &aMimeType,
|
|||
|
||||
plugin->GetLibrary()->SetHasLocalInstance();
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_CRASHREPORTER)
|
||||
if (pluginTag->mIsFlashPlugin) {
|
||||
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FlashVersion"), pluginTag->Version());
|
||||
}
|
||||
#endif
|
||||
|
||||
RefPtr<nsNPAPIPluginInstance> instance = new nsNPAPIPluginInstance();
|
||||
|
||||
// This will create the owning reference. The connection must be made between the
|
||||
|
@ -2466,10 +2451,6 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange
|
|||
NS_ITERATIVE_UNREF_LIST(RefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext);
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
#ifdef ANDROID
|
||||
LOG("getting plugins dir failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
mPluginsLoaded = true; // at this point 'some' plugins have been loaded,
|
||||
|
@ -3060,14 +3041,6 @@ nsPluginHost::ReadPluginInfo()
|
|||
if (!reader.NextLine())
|
||||
return rv;
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
// Flash on Android does not populate the version field, but it is tacked on to the description.
|
||||
// For example, "Shockwave Flash 11.1 r115"
|
||||
if (PL_strncmp("Shockwave Flash ", description, 16) == 0 && description[16]) {
|
||||
version = &description[16];
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *name = reader.LinePtr();
|
||||
if (!reader.NextLine())
|
||||
return rv;
|
||||
|
@ -3133,8 +3106,6 @@ nsPluginHost::ReadPluginInfo()
|
|||
mCachedPlugins = tag;
|
||||
}
|
||||
|
||||
// On Android we always want to try to load a plugin again (Flash). Bug 935676.
|
||||
#ifndef MOZ_WIDGET_ANDROID
|
||||
if (!ReadSectionHeader(reader, "INVALID")) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -3156,7 +3127,6 @@ nsPluginHost::ReadPluginInfo()
|
|||
}
|
||||
mInvalidPlugins = invalidTag;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3488,24 +3458,6 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject,
|
|||
SendPluginsToContent();
|
||||
}
|
||||
}
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (!strcmp("application-background", aTopic)) {
|
||||
for(uint32_t i = 0; i < mInstances.Length(); i++) {
|
||||
mInstances[i]->NotifyForeground(false);
|
||||
}
|
||||
}
|
||||
if (!strcmp("application-foreground", aTopic)) {
|
||||
for(uint32_t i = 0; i < mInstances.Length(); i++) {
|
||||
if (mInstances[i]->IsOnScreen())
|
||||
mInstances[i]->NotifyForeground(true);
|
||||
}
|
||||
}
|
||||
if (!strcmp("memory-pressure", aTopic)) {
|
||||
for(uint32_t i = 0; i < mInstances.Length(); i++) {
|
||||
mInstances[i]->MemoryPressure();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,21 +86,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
|||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "ANPBase.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "FennecJNIWrappers.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
static nsPluginInstanceOwner* sFullScreenInstance = nullptr;
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#include <android/log.h>
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
|
@ -163,30 +148,6 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
|
|||
}
|
||||
}
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
static void
|
||||
AttachToContainerAsSurface(ImageContainer* container,
|
||||
nsNPAPIPluginInstance* instance,
|
||||
const LayoutDeviceRect& rect,
|
||||
RefPtr<Image>* out_image)
|
||||
{
|
||||
MOZ_ASSERT(out_image);
|
||||
MOZ_ASSERT(!*out_image);
|
||||
|
||||
java::GeckoSurface::LocalRef surface = instance->AsSurface();
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<Image> img = new SurfaceTextureImage(
|
||||
surface->GetHandle(),
|
||||
gfx::IntSize::Truncate(rect.width, rect.height),
|
||||
true, // continuously update without a transaction
|
||||
instance->OriginPos());
|
||||
*out_image = img;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
nsPluginInstanceOwner::NeedsScrollImageLayer()
|
||||
{
|
||||
|
@ -210,27 +171,6 @@ nsPluginInstanceOwner::GetImageContainer()
|
|||
|
||||
RefPtr<ImageContainer> container;
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
LayoutDeviceRect r = GetPluginRect();
|
||||
|
||||
// NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
|
||||
// into, set y-flip flags, etc, so we do this at the beginning.
|
||||
float resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution();
|
||||
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution)).Size();
|
||||
mInstance->NotifySize(nsIntSize::Truncate(screenSize.width, screenSize.height));
|
||||
|
||||
container = LayerManager::CreateImageContainer();
|
||||
|
||||
if (r.width && r.height) {
|
||||
// Try to get it as an EGLImage first.
|
||||
RefPtr<Image> img;
|
||||
AttachToContainerAsSurface(container, mInstance, r, &img);
|
||||
|
||||
if (img) {
|
||||
container->SetCurrentImageInTransaction(img);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (NeedsScrollImageLayer()) {
|
||||
// windowed plugin under e10s
|
||||
#if defined(XP_WIN)
|
||||
|
@ -240,7 +180,6 @@ nsPluginInstanceOwner::GetImageContainer()
|
|||
// async windowless rendering
|
||||
mInstance->GetImageContainer(getter_AddRefs(container));
|
||||
}
|
||||
#endif
|
||||
|
||||
return container.forget();
|
||||
}
|
||||
|
@ -357,11 +296,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
|
|||
|
||||
mWaitingForPaint = false;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mFullScreen = false;
|
||||
mJavaView = nullptr;
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
mGotCompositionData = false;
|
||||
mSentStartComposition = false;
|
||||
|
@ -386,10 +320,6 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
|||
PLUG_DeletePluginNativeWindow(mPluginWindow);
|
||||
mPluginWindow = nullptr;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
RemovePluginView();
|
||||
#endif
|
||||
|
||||
if (mInstance) {
|
||||
mInstance->SetOwner(nullptr);
|
||||
}
|
||||
|
@ -412,10 +342,6 @@ nsPluginInstanceOwner::SetInstance(nsNPAPIPluginInstance *aInstance)
|
|||
// from our destructor. This fixes bug 613376.
|
||||
if (mInstance && !aInstance) {
|
||||
mInstance->SetOwner(nullptr);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
RemovePluginView();
|
||||
#endif
|
||||
}
|
||||
|
||||
mInstance = aInstance;
|
||||
|
@ -600,10 +526,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
|
|||
if (!mPluginFrame || !invalidRect || !mWidgetVisible)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
|
||||
#if defined(XP_MACOSX)
|
||||
// Each time an asynchronously-drawing plugin sends a new surface to display,
|
||||
// the image in the ImageContainer is updated and InvalidateRect is called.
|
||||
// There are different side effects for (sync) Android plugins.
|
||||
RefPtr<ImageContainer> container;
|
||||
mInstance->GetImageContainer(getter_AddRefs(container));
|
||||
#endif
|
||||
|
@ -1485,209 +1410,8 @@ nsPluginInstanceOwner::GetEventloopNestingLevel()
|
|||
return currentLevel;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
// Modified version of nsFrame::GetOffsetToCrossDoc that stops when it
|
||||
// hits an element with a displayport (or runs out of frames). This is
|
||||
// not really the right thing to do, but it's better than what was here before.
|
||||
static nsPoint
|
||||
GetOffsetRootContent(nsIFrame* aFrame)
|
||||
{
|
||||
// offset will hold the final offset
|
||||
// docOffset holds the currently accumulated offset at the current APD, it
|
||||
// will be converted and added to offset when the current APD changes.
|
||||
nsPoint offset(0, 0), docOffset(0, 0);
|
||||
const nsIFrame* f = aFrame;
|
||||
int32_t currAPD = aFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
int32_t apd = currAPD;
|
||||
while (f) {
|
||||
if (f->GetContent() && nsLayoutUtils::HasDisplayPort(f->GetContent()))
|
||||
break;
|
||||
|
||||
docOffset += f->GetPosition();
|
||||
nsIFrame* parent = f->GetParent();
|
||||
if (parent) {
|
||||
f = parent;
|
||||
} else {
|
||||
nsPoint newOffset(0, 0);
|
||||
f = nsLayoutUtils::GetCrossDocParentFrame(f, &newOffset);
|
||||
int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0;
|
||||
if (!f || newAPD != currAPD) {
|
||||
// Convert docOffset to the right APD and add it to offset.
|
||||
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
|
||||
docOffset.x = docOffset.y = 0;
|
||||
}
|
||||
currAPD = newAPD;
|
||||
docOffset += newOffset;
|
||||
}
|
||||
}
|
||||
|
||||
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
LayoutDeviceRect nsPluginInstanceOwner::GetPluginRect()
|
||||
{
|
||||
// Get the offset of the content relative to the page
|
||||
nsRect bounds = mPluginFrame->GetContentRectRelativeToSelf() + GetOffsetRootContent(mPluginFrame);
|
||||
LayoutDeviceIntRect rect = LayoutDeviceIntRect::FromAppUnitsToNearest(bounds, mPluginFrame->PresContext()->AppUnitsPerDevPixel());
|
||||
return LayoutDeviceRect(rect);
|
||||
}
|
||||
|
||||
bool nsPluginInstanceOwner::AddPluginView(const LayoutDeviceRect& aRect /* = LayoutDeviceRect(0, 0, 0, 0) */)
|
||||
{
|
||||
if (!mJavaView) {
|
||||
mJavaView = mInstance->GetJavaSurface();
|
||||
|
||||
if (!mJavaView)
|
||||
return false;
|
||||
|
||||
mJavaView = (void*)jni::GetGeckoThreadEnv()->NewGlobalRef((jobject)mJavaView);
|
||||
}
|
||||
|
||||
if (mFullScreen && jni::IsFennec()) {
|
||||
java::GeckoApp::AddPluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
sFullScreenInstance = this;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::RemovePluginView()
|
||||
{
|
||||
if (!mInstance || !mJavaView)
|
||||
return;
|
||||
|
||||
if (mFullScreen && jni::IsFennec()) {
|
||||
java::GeckoApp::RemovePluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
}
|
||||
jni::GetGeckoThreadEnv()->DeleteGlobalRef((jobject)mJavaView);
|
||||
mJavaView = nullptr;
|
||||
|
||||
if (mFullScreen)
|
||||
sFullScreenInstance = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::GetVideos(nsTArray<nsNPAPIPluginInstance::VideoInfo*>& aVideos)
|
||||
{
|
||||
if (!mInstance)
|
||||
return;
|
||||
|
||||
mInstance->GetVideos(aVideos);
|
||||
}
|
||||
|
||||
already_AddRefed<ImageContainer>
|
||||
nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo)
|
||||
{
|
||||
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
|
||||
|
||||
if (aVideoInfo->mDimensions.width && aVideoInfo->mDimensions.height) {
|
||||
RefPtr<Image> img = new SurfaceTextureImage(
|
||||
aVideoInfo->mSurface->GetHandle(),
|
||||
gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
|
||||
true, /* continuous */
|
||||
gl::OriginPos::BottomLeft);
|
||||
container->SetCurrentImageInTransaction(img);
|
||||
}
|
||||
|
||||
return container.forget();
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::Invalidate() {
|
||||
NPRect rect;
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = mPluginWindow->width;
|
||||
rect.bottom = mPluginWindow->height;
|
||||
InvalidateRect(&rect);
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::Recomposite() {
|
||||
nsIWidget* const widget = mPluginFrame->GetNearestWidget();
|
||||
NS_ENSURE_TRUE_VOID(widget);
|
||||
|
||||
LayerManager* const lm = widget->GetLayerManager();
|
||||
NS_ENSURE_TRUE_VOID(lm);
|
||||
|
||||
ClientLayerManager* const clm = lm->AsClientLayerManager();
|
||||
NS_ENSURE_TRUE_VOID(clm && clm->GetRoot());
|
||||
|
||||
clm->SendInvalidRegion(
|
||||
clm->GetRoot()->GetLocalVisibleRegion().ToUnknownRegion().GetBounds());
|
||||
clm->ScheduleComposite();
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::RequestFullScreen() {
|
||||
if (mFullScreen)
|
||||
return;
|
||||
|
||||
// Remove whatever view we currently have (if any, fullscreen or otherwise)
|
||||
RemovePluginView();
|
||||
|
||||
mFullScreen = true;
|
||||
AddPluginView();
|
||||
|
||||
mInstance->NotifyFullScreen(mFullScreen);
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::ExitFullScreen() {
|
||||
if (!mFullScreen)
|
||||
return;
|
||||
|
||||
RemovePluginView();
|
||||
|
||||
mFullScreen = false;
|
||||
|
||||
int32_t model = mInstance->GetANPDrawingModel();
|
||||
|
||||
if (model == kSurface_ANPDrawingModel) {
|
||||
// We need to do this immediately, otherwise Flash
|
||||
// sometimes causes a deadlock (bug 762407)
|
||||
AddPluginView(GetPluginRect());
|
||||
}
|
||||
|
||||
mInstance->NotifyFullScreen(mFullScreen);
|
||||
|
||||
// This will cause Paint() to be called, which is where
|
||||
// we normally add/update views and layers
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void nsPluginInstanceOwner::ExitFullScreen(jobject view) {
|
||||
JNIEnv* env = jni::GetGeckoThreadEnv();
|
||||
|
||||
if (sFullScreenInstance && sFullScreenInstance->mInstance &&
|
||||
env->IsSameObject(view, (jobject)sFullScreenInstance->mInstance->GetJavaSurface())) {
|
||||
sFullScreenInstance->ExitFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mInstance) {
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = kLifecycle_ANPEventType;
|
||||
|
||||
nsAutoString eventType;
|
||||
aFocusEvent->GetType(eventType);
|
||||
if (eventType.EqualsLiteral("focus")) {
|
||||
event.data.lifecycle.action = kGainFocus_ANPLifecycleAction;
|
||||
}
|
||||
else if (eventType.EqualsLiteral("blur")) {
|
||||
event.data.lifecycle.action = kLoseFocus_ANPLifecycleAction;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(false, "nsPluginInstanceOwner::DispatchFocusToPlugin, wierd eventType");
|
||||
}
|
||||
mInstance->HandleEvent(&event, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
|
||||
// continue only for cases without child window
|
||||
|
@ -2748,96 +2472,6 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
rv = nsEventStatus_eConsumeNoDefault;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// this code supports windowless plugins
|
||||
{
|
||||
// The plugin needs focus to receive keyboard and touch events
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMElement> elem = do_QueryReferent(mContent);
|
||||
fm->SetFocus(elem, 0);
|
||||
}
|
||||
}
|
||||
switch(anEvent.mClass) {
|
||||
case eMouseEventClass:
|
||||
{
|
||||
switch (anEvent.mMessage) {
|
||||
case eMouseClick:
|
||||
case eMouseDoubleClick:
|
||||
case eMouseAuxClick:
|
||||
// Button up/down events sent instead.
|
||||
return rv;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Get reference point relative to plugin origin.
|
||||
const nsPresContext* presContext = mPluginFrame->PresContext();
|
||||
nsPoint appPoint =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
|
||||
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
|
||||
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
|
||||
presContext->AppUnitsToDevPixels(appPoint.y));
|
||||
|
||||
switch (anEvent.mMessage) {
|
||||
case eMouseMove:
|
||||
{
|
||||
// are these going to be touch events?
|
||||
// pluginPoint.x;
|
||||
// pluginPoint.y;
|
||||
}
|
||||
break;
|
||||
case eMouseDown:
|
||||
{
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = kMouse_ANPEventType;
|
||||
event.data.mouse.action = kDown_ANPMouseAction;
|
||||
event.data.mouse.x = pluginPoint.x;
|
||||
event.data.mouse.y = pluginPoint.y;
|
||||
mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
}
|
||||
break;
|
||||
case eMouseUp:
|
||||
{
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = kMouse_ANPEventType;
|
||||
event.data.mouse.action = kUp_ANPMouseAction;
|
||||
event.data.mouse.x = pluginPoint.x;
|
||||
event.data.mouse.y = pluginPoint.y;
|
||||
mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eKeyboardEventClass:
|
||||
{
|
||||
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
|
||||
LOG("Firing eKeyboardEventClass %d %d\n",
|
||||
keyEvent.mKeyCode, keyEvent.mCharCode);
|
||||
// pluginEvent is initialized by nsWindow::InitKeyEvent().
|
||||
const ANPEvent* pluginEvent = static_cast<const ANPEvent*>(keyEvent.mPluginEvent);
|
||||
if (pluginEvent) {
|
||||
MOZ_ASSERT(pluginEvent->inSize == sizeof(ANPEvent));
|
||||
MOZ_ASSERT(pluginEvent->eventType == kKey_ANPEventType);
|
||||
mInstance->HandleEvent(const_cast<ANPEvent*>(pluginEvent),
|
||||
nullptr,
|
||||
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rv = nsEventStatus_eConsumeNoDefault;
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2884,10 +2518,6 @@ nsPluginInstanceOwner::Destroy()
|
|||
this, true);
|
||||
content->RemoveSystemEventListener(NS_LITERAL_STRING("text"), this, true);
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
RemovePluginView();
|
||||
#endif
|
||||
|
||||
if (mWidget) {
|
||||
if (mPluginWindow) {
|
||||
mPluginWindow->SetPluginWidget(nullptr);
|
||||
|
@ -2957,72 +2587,6 @@ void nsPluginInstanceOwner::Paint(const RECT& aDirty, HDC aDC)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
const gfxRect& aDirtyRect)
|
||||
{
|
||||
if (!mInstance || !mPluginFrame || !mPluginDocumentActiveState || mFullScreen)
|
||||
return;
|
||||
|
||||
int32_t model = mInstance->GetANPDrawingModel();
|
||||
|
||||
if (model == kSurface_ANPDrawingModel) {
|
||||
if (!AddPluginView(GetPluginRect())) {
|
||||
Invalidate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (model != kBitmap_ANPDrawingModel)
|
||||
return;
|
||||
|
||||
#ifdef ANP_BITMAP_DRAWING_MODEL
|
||||
static RefPtr<gfxImageSurface> pluginSurface;
|
||||
|
||||
if (pluginSurface == nullptr ||
|
||||
aFrameRect.width != pluginSurface->Width() ||
|
||||
aFrameRect.height != pluginSurface->Height()) {
|
||||
|
||||
pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height),
|
||||
SurfaceFormat::A8R8G8B8_UINT32);
|
||||
if (!pluginSurface)
|
||||
return;
|
||||
}
|
||||
|
||||
// Clears buffer. I think this is needed.
|
||||
gfxUtils::ClearThebesSurface(pluginSurface);
|
||||
|
||||
ANPEvent event;
|
||||
event.inSize = sizeof(ANPEvent);
|
||||
event.eventType = 4;
|
||||
event.data.draw.model = 1;
|
||||
|
||||
event.data.draw.clip.top = 0;
|
||||
event.data.draw.clip.left = 0;
|
||||
event.data.draw.clip.bottom = aFrameRect.width;
|
||||
event.data.draw.clip.right = aFrameRect.height;
|
||||
|
||||
event.data.draw.data.bitmap.format = kRGBA_8888_ANPBitmapFormat;
|
||||
event.data.draw.data.bitmap.width = aFrameRect.width;
|
||||
event.data.draw.data.bitmap.height = aFrameRect.height;
|
||||
event.data.draw.data.bitmap.baseAddr = pluginSurface->Data();
|
||||
event.data.draw.data.bitmap.rowBytes = aFrameRect.width * 4;
|
||||
|
||||
if (!mInstance)
|
||||
return;
|
||||
|
||||
mInstance->HandleEvent(&event, nullptr);
|
||||
|
||||
aContext->SetOp(gfx::CompositionOp::OP_SOURCE);
|
||||
aContext->SetSource(pluginSurface, gfxPoint(aFrameRect.x, aFrameRect.y));
|
||||
aContext->Clip(aFrameRect);
|
||||
aContext->Paint();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_X11)
|
||||
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
|
@ -3628,24 +3192,6 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
|
|||
#ifndef XP_MACOSX
|
||||
UpdateWindowPositionAndClipRect(true);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mInstance) {
|
||||
if (!mPluginDocumentActiveState) {
|
||||
RemovePluginView();
|
||||
}
|
||||
|
||||
mInstance->NotifyOnScreen(mPluginDocumentActiveState);
|
||||
|
||||
// This is, perhaps, incorrect. It is supposed to be sent
|
||||
// when "the webview has paused or resumed". The side effect
|
||||
// is that Flash video players pause or resume (if they were
|
||||
// playing before) based on the value here. I personally think
|
||||
// we want that on Android when switching to another tab, so
|
||||
// that's why we call it here.
|
||||
mInstance->NotifyForeground(mPluginDocumentActiveState);
|
||||
}
|
||||
#endif // #ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
// We don't have a connection to PluginWidgetParent in the chrome
|
||||
// process when dealing with tab visibility changes, so this needs
|
||||
// to be forwarded over after the active state is updated. If we
|
||||
|
|
|
@ -29,7 +29,7 @@ class nsPluginDOMContextMenuListener;
|
|||
class nsPluginFrame;
|
||||
class nsDisplayListBuilder;
|
||||
|
||||
#if defined(MOZ_X11) || defined(ANDROID)
|
||||
#if defined(MOZ_X11)
|
||||
class gfxContext;
|
||||
#endif
|
||||
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext);
|
||||
void RenderCoreAnimation(CGContextRef aCGContext, int aWidth, int aHeight);
|
||||
void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext);
|
||||
#elif defined(MOZ_X11) || defined(ANDROID)
|
||||
#elif defined(MOZ_X11)
|
||||
void Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
const gfxRect& aDirtyRect);
|
||||
|
@ -254,21 +254,6 @@ public:
|
|||
|
||||
already_AddRefed<nsIURI> GetBaseURI() const;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Returns the image container for the specified VideoInfo
|
||||
void GetVideos(nsTArray<nsNPAPIPluginInstance::VideoInfo*>& aVideos);
|
||||
already_AddRefed<mozilla::layers::ImageContainer> GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo);
|
||||
|
||||
void Invalidate();
|
||||
void Recomposite();
|
||||
|
||||
void RequestFullScreen();
|
||||
void ExitFullScreen();
|
||||
|
||||
// Called from nsAppShell when we removed the fullscreen view.
|
||||
static void ExitFullScreen(jobject view);
|
||||
#endif
|
||||
|
||||
bool GetCompositionString(uint32_t aIndex, nsTArray<uint8_t>* aString,
|
||||
int32_t* aLength);
|
||||
bool SetCandidateWindow(
|
||||
|
@ -302,15 +287,6 @@ private:
|
|||
size == nsIntSize(mPluginWindow->width, mPluginWindow->height);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mozilla::LayoutDeviceRect GetPluginRect();
|
||||
bool AddPluginView(const mozilla::LayoutDeviceRect& aRect = mozilla::LayoutDeviceRect(0, 0, 0, 0));
|
||||
void RemovePluginView();
|
||||
|
||||
bool mFullScreen;
|
||||
void* mJavaView;
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
nsIWidget* GetContainingWidgetIfOffset();
|
||||
already_AddRefed<mozilla::TextComposition> GetTextComposition();
|
||||
|
|
|
@ -695,11 +695,6 @@ nsPluginTag::GetNiceName(nsACString & aResult)
|
|||
NS_IMETHODIMP
|
||||
nsPluginTag::GetBlocklistState(uint32_t *aResult)
|
||||
{
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
*aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
|
||||
return NS_OK;
|
||||
#else
|
||||
|
||||
// If we're in the content process, assume our cache state to always be valid,
|
||||
// as the only way it can be updated is via a plugin list push from the
|
||||
// parent process.
|
||||
|
@ -725,7 +720,6 @@ nsPluginTag::GetBlocklistState(uint32_t *aResult)
|
|||
mCachedBlocklistState = (uint16_t) *aResult;
|
||||
mCachedBlocklistStateValid = true;
|
||||
return NS_OK;
|
||||
#endif // defined(MOZ_WIDGET_ANDROID)
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -213,16 +213,6 @@ bool nsPluginsDir::IsPluginFile(nsIFile* file)
|
|||
if (NS_FAILED(file->GetNativeLeafName(filename)))
|
||||
return false;
|
||||
|
||||
#ifdef ANDROID
|
||||
// It appears that if you load
|
||||
// 'libstagefright_honeycomb.so' on froyo, or
|
||||
// 'libstagefright_froyo.so' on honeycomb, we will abort.
|
||||
// Since these are just helper libs, we can ignore.
|
||||
const char *cFile = filename.get();
|
||||
if (strstr(cFile, "libstagefright") != nullptr)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX);
|
||||
if (filename.Length() > dllSuffix.Length() &&
|
||||
StringEndsWith(filename, dllSuffix))
|
||||
|
|
|
@ -22,10 +22,6 @@ elif toolkit in ('gtk2', 'gtk3'):
|
|||
UNIFIED_SOURCES += [
|
||||
'nptest_gtk2.cpp',
|
||||
]
|
||||
elif toolkit == 'android':
|
||||
UNIFIED_SOURCES += [
|
||||
'nptest_droid.cpp',
|
||||
]
|
||||
elif toolkit == 'windows':
|
||||
UNIFIED_SOURCES += [
|
||||
'nptest_windows.cpp',
|
||||
|
|
|
@ -80,11 +80,6 @@ using mozilla::DefaultXDisplay;
|
|||
#include <winuser.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
#include "GLContext.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
|
||||
#ifdef CreateEvent // Thank you MS.
|
||||
|
@ -938,55 +933,6 @@ nsDisplayPluginReadback::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
|||
return GetDisplayItemBounds(aBuilder, this, mFrame);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
class nsDisplayPluginVideo : public nsDisplayItem {
|
||||
public:
|
||||
nsDisplayPluginVideo(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsNPAPIPluginInstance::VideoInfo* aVideoInfo)
|
||||
: nsDisplayItem(aBuilder, aFrame), mVideoInfo(aVideoInfo)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsDisplayPluginVideo);
|
||||
}
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
virtual ~nsDisplayPluginVideo() {
|
||||
MOZ_COUNT_DTOR(nsDisplayPluginVideo);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
||||
bool* aSnap) override;
|
||||
|
||||
NS_DISPLAY_DECL_NAME("PluginVideo", TYPE_PLUGIN_VIDEO)
|
||||
|
||||
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aContainerParameters) override
|
||||
{
|
||||
return static_cast<nsPluginFrame*>(mFrame)->BuildLayer(aBuilder, aManager, this, aContainerParameters);
|
||||
}
|
||||
|
||||
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aParameters) override
|
||||
{
|
||||
return LAYER_ACTIVE;
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance::VideoInfo* VideoInfo() { return mVideoInfo; }
|
||||
|
||||
private:
|
||||
nsNPAPIPluginInstance::VideoInfo* mVideoInfo;
|
||||
};
|
||||
|
||||
nsRect
|
||||
nsDisplayPluginVideo::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
||||
{
|
||||
*aSnap = false;
|
||||
return GetDisplayItemBounds(aBuilder, this, mFrame);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsRect
|
||||
nsDisplayPlugin::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
||||
{
|
||||
|
@ -1136,9 +1082,6 @@ nsPluginFrame::IsOpaque() const
|
|||
{
|
||||
#if defined(XP_MACOSX)
|
||||
return false;
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
// We don't know, so just assume transparent
|
||||
return false;
|
||||
#else
|
||||
|
||||
if (mInstanceOwner && mInstanceOwner->UseAsyncRendering()) {
|
||||
|
@ -1238,29 +1181,12 @@ nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
nsDisplayItem::ForceActiveLayers()) {
|
||||
state = LAYER_ACTIVE;
|
||||
}
|
||||
// We don't need this on Android, and it just confuses things
|
||||
#if !MOZ_WIDGET_ANDROID
|
||||
if (aBuilder->IsPaintingToWindow() &&
|
||||
state == LAYER_ACTIVE &&
|
||||
IsTransparentMode()) {
|
||||
aLists.Content()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayPluginReadback(aBuilder, this));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
if (aBuilder->IsPaintingToWindow() &&
|
||||
state == LAYER_ACTIVE) {
|
||||
|
||||
nsTArray<nsNPAPIPluginInstance::VideoInfo*> videos;
|
||||
mInstanceOwner->GetVideos(videos);
|
||||
|
||||
for (uint32_t i = 0; i < videos.Length(); i++) {
|
||||
aLists.Content()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayPluginVideo(aBuilder, this, videos[i]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aLists.Content()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayPlugin(aBuilder, this));
|
||||
|
@ -1396,10 +1322,6 @@ nsPluginFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
|
|||
if (!mInstanceOwner)
|
||||
return LAYER_NONE;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// We always want a layer on Honeycomb and later
|
||||
return LAYER_ACTIVE;
|
||||
#else
|
||||
if (mInstanceOwner->NeedsScrollImageLayer()) {
|
||||
return LAYER_ACTIVE;
|
||||
}
|
||||
|
@ -1409,7 +1331,6 @@ nsPluginFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
|
|||
}
|
||||
|
||||
return LAYER_ACTIVE_FORCE;
|
||||
#endif
|
||||
}
|
||||
|
||||
class PluginFrameDidCompositeObserver final : public DidCompositeObserver
|
||||
|
@ -1526,32 +1447,6 @@ nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|||
}
|
||||
lm->AddDidCompositeObserver(mDidCompositeObserver.get());
|
||||
}
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
} else if (aItem->GetType() == nsDisplayItem::TYPE_PLUGIN_VIDEO) {
|
||||
nsDisplayPluginVideo* videoItem = reinterpret_cast<nsDisplayPluginVideo*>(aItem);
|
||||
nsNPAPIPluginInstance::VideoInfo* videoInfo = videoItem->VideoInfo();
|
||||
|
||||
RefPtr<ImageContainer> container = mInstanceOwner->GetImageContainerForVideo(videoInfo);
|
||||
if (!container)
|
||||
return nullptr;
|
||||
|
||||
if (!layer) {
|
||||
// Initialize ImageLayer
|
||||
layer = aManager->CreateImageLayer();
|
||||
if (!layer)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
|
||||
imglayer->SetContainer(container);
|
||||
|
||||
layer->SetContentFlags(IsOpaque() ? Layer::CONTENT_OPAQUE : 0);
|
||||
|
||||
// Set the offset and size according to the video dimensions
|
||||
r.MoveBy(videoInfo->mDimensions.TopLeft());
|
||||
size.width = videoInfo->mDimensions.width;
|
||||
size.height = videoInfo->mDimensions.height;
|
||||
#endif
|
||||
} else {
|
||||
NS_ASSERTION(aItem->GetType() == nsDisplayItem::TYPE_PLUGIN_READBACK,
|
||||
"Unknown item type");
|
||||
|
@ -1600,18 +1495,7 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
|
|||
gfxContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect, const nsRect& aPluginRect)
|
||||
{
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
if (mInstanceOwner) {
|
||||
gfxRect frameGfxRect =
|
||||
PresContext()->AppUnitsToGfxUnits(aPluginRect);
|
||||
gfxRect dirtyGfxRect =
|
||||
PresContext()->AppUnitsToGfxUnits(aDirtyRect);
|
||||
|
||||
mInstanceOwner->Paint(&aRenderingContext, frameGfxRect, dirtyGfxRect);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
# if defined(DEBUG)
|
||||
#if defined(DEBUG)
|
||||
// On Desktop, we should have built a layer as we no longer support in-process
|
||||
// plugins or synchronous painting. We can only get here for windowed plugins
|
||||
// (which draw themselves), or via some error/unload state.
|
||||
|
@ -1620,7 +1504,6 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
|
|||
mInstanceOwner->GetWindow(window);
|
||||
MOZ_ASSERT(!window || window->type == NPWindowTypeWindow);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,5 @@ with Files('nsis/**'):
|
|||
with Files('ply/**'):
|
||||
BUG_COMPONENT = ('Core', 'JavaScript Engine')
|
||||
|
||||
with Files('skia-npapi/**'):
|
||||
BUG_COMPONENT = ('Core', 'Graphics')
|
||||
|
||||
with Files('snappy/**'):
|
||||
BUG_COMPONENT = ('Core', 'XPCOM')
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// must include config.h first for webkit to fiddle with new/delete
|
||||
#include "SkANP.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
static ANPCanvas* anp_newCanvas(const ANPBitmap* bitmap) {
|
||||
SkBitmap bm;
|
||||
return new ANPCanvas(*SkANP::SetBitmap(&bm, *bitmap));
|
||||
}
|
||||
|
||||
static void anp_deleteCanvas(ANPCanvas* canvas) {
|
||||
delete canvas;
|
||||
}
|
||||
|
||||
static void anp_save(ANPCanvas* canvas) {
|
||||
canvas->skcanvas->save();
|
||||
}
|
||||
|
||||
static void anp_restore(ANPCanvas* canvas) {
|
||||
canvas->skcanvas->restore();
|
||||
}
|
||||
|
||||
static void anp_translate(ANPCanvas* canvas, float tx, float ty) {
|
||||
canvas->skcanvas->translate(SkFloatToScalar(tx), SkFloatToScalar(ty));
|
||||
}
|
||||
|
||||
static void anp_scale(ANPCanvas* canvas, float sx, float sy) {
|
||||
canvas->skcanvas->scale(SkFloatToScalar(sx), SkFloatToScalar(sy));
|
||||
}
|
||||
|
||||
static void anp_rotate(ANPCanvas* canvas, float degrees) {
|
||||
canvas->skcanvas->rotate(SkFloatToScalar(degrees));
|
||||
}
|
||||
|
||||
static void anp_skew(ANPCanvas* canvas, float kx, float ky) {
|
||||
canvas->skcanvas->skew(SkFloatToScalar(kx), SkFloatToScalar(ky));
|
||||
}
|
||||
|
||||
static void anp_clipRect(ANPCanvas* canvas, const ANPRectF* rect) {
|
||||
SkRect r;
|
||||
canvas->skcanvas->clipRect(*SkANP::SetRect(&r, *rect));
|
||||
}
|
||||
|
||||
static void anp_clipPath(ANPCanvas* canvas, const ANPPath* path) {
|
||||
canvas->skcanvas->clipPath(*path);
|
||||
}
|
||||
static void anp_concat(ANPCanvas* canvas, const ANPMatrix* matrix) {
|
||||
canvas->skcanvas->concat(*matrix);
|
||||
}
|
||||
|
||||
static void anp_getTotalMatrix(ANPCanvas* canvas, ANPMatrix* matrix) {
|
||||
const SkMatrix& src = canvas->skcanvas->getTotalMatrix();
|
||||
*matrix = *reinterpret_cast<const ANPMatrix*>(&src);
|
||||
}
|
||||
|
||||
static bool anp_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* r,
|
||||
bool antialias) {
|
||||
SkRect bounds;
|
||||
if (canvas->skcanvas->getLocalClipBounds(&bounds)) {
|
||||
SkANP::SetRect(r, bounds);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool anp_getDeviceClipBounds(ANPCanvas* canvas, ANPRectI* r) {
|
||||
SkIRect bounds;
|
||||
if (canvas->skcanvas->getDeviceClipBounds(&bounds)) {
|
||||
SkANP::SetRect(r, bounds);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void anp_drawColor(ANPCanvas* canvas, ANPColor color) {
|
||||
canvas->skcanvas->drawColor(color);
|
||||
}
|
||||
|
||||
static void anp_drawPaint(ANPCanvas* canvas, const ANPPaint* paint) {
|
||||
canvas->skcanvas->drawPaint(*paint);
|
||||
}
|
||||
|
||||
static void anp_drawLine(ANPCanvas* canvas, float x0, float y0,
|
||||
float x1, float y1, const ANPPaint* paint) {
|
||||
canvas->skcanvas->drawLine(SkFloatToScalar(x0), SkFloatToScalar(y0),
|
||||
SkFloatToScalar(x1), SkFloatToScalar(y1), *paint);
|
||||
}
|
||||
|
||||
static void anp_drawRect(ANPCanvas* canvas, const ANPRectF* rect,
|
||||
const ANPPaint* paint) {
|
||||
SkRect r;
|
||||
canvas->skcanvas->drawRect(*SkANP::SetRect(&r, *rect), *paint);
|
||||
}
|
||||
|
||||
static void anp_drawOval(ANPCanvas* canvas, const ANPRectF* rect,
|
||||
const ANPPaint* paint) {
|
||||
SkRect r;
|
||||
canvas->skcanvas->drawOval(*SkANP::SetRect(&r, *rect), *paint);
|
||||
}
|
||||
|
||||
static void anp_drawPath(ANPCanvas* canvas, const ANPPath* path,
|
||||
const ANPPaint* paint) {
|
||||
canvas->skcanvas->drawPath(*path, *paint);
|
||||
}
|
||||
|
||||
static void anp_drawText(ANPCanvas* canvas, const void* text, uint32_t length,
|
||||
float x, float y, const ANPPaint* paint) {
|
||||
canvas->skcanvas->drawText(text, length,
|
||||
SkFloatToScalar(x), SkFloatToScalar(y),
|
||||
*paint);
|
||||
}
|
||||
|
||||
static void anp_drawPosText(ANPCanvas* canvas, const void* text,
|
||||
uint32_t byteLength, const float xy[], const ANPPaint* paint) {
|
||||
canvas->skcanvas->drawPosText(text, byteLength,
|
||||
reinterpret_cast<const SkPoint*>(xy), *paint);
|
||||
}
|
||||
|
||||
static void anp_drawBitmap(ANPCanvas* canvas, const ANPBitmap* bitmap,
|
||||
float x, float y, const ANPPaint* paint) {
|
||||
SkBitmap bm;
|
||||
canvas->skcanvas->drawBitmap(*SkANP::SetBitmap(&bm, *bitmap),
|
||||
SkFloatToScalar(x), SkFloatToScalar(y),
|
||||
paint);
|
||||
}
|
||||
|
||||
static void anp_drawBitmapRect(ANPCanvas* canvas, const ANPBitmap* bitmap,
|
||||
const ANPRectI* src, const ANPRectF* dst,
|
||||
const ANPPaint* paint) {
|
||||
SkBitmap bm;
|
||||
SkRect dstR;
|
||||
SkIRect srcR;
|
||||
|
||||
if (src) {
|
||||
canvas->skcanvas->drawBitmapRect(*SkANP::SetBitmap(&bm, *bitmap),
|
||||
*SkANP::SetRect(&srcR, *src),
|
||||
*SkANP::SetRect(&dstR, *dst),
|
||||
paint);
|
||||
} else {
|
||||
canvas->skcanvas->drawBitmapRect(*SkANP::SetBitmap(&bm, *bitmap),
|
||||
*SkANP::SetRect(&dstR, *dst),
|
||||
paint);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_##name
|
||||
|
||||
void InitCanvasInterface(ANPCanvasInterfaceV0* i) {
|
||||
ASSIGN(i, newCanvas);
|
||||
ASSIGN(i, deleteCanvas);
|
||||
ASSIGN(i, save);
|
||||
ASSIGN(i, restore);
|
||||
ASSIGN(i, translate);
|
||||
ASSIGN(i, scale);
|
||||
ASSIGN(i, rotate);
|
||||
ASSIGN(i, skew);
|
||||
ASSIGN(i, clipRect);
|
||||
ASSIGN(i, clipPath);
|
||||
ASSIGN(i, concat);
|
||||
ASSIGN(i, getTotalMatrix);
|
||||
ASSIGN(i, getLocalClipBounds);
|
||||
ASSIGN(i, getDeviceClipBounds);
|
||||
ASSIGN(i, drawColor);
|
||||
ASSIGN(i, drawPaint);
|
||||
ASSIGN(i, drawLine);
|
||||
ASSIGN(i, drawRect);
|
||||
ASSIGN(i, drawOval);
|
||||
ASSIGN(i, drawPath);
|
||||
ASSIGN(i, drawText);
|
||||
ASSIGN(i, drawPosText);
|
||||
ASSIGN(i, drawBitmap);
|
||||
ASSIGN(i, drawBitmapRect);
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// must include config.h first for webkit to fiddle with new/delete
|
||||
#include "SkANP.h"
|
||||
|
||||
static ANPPaint* anp_newPaint() {
|
||||
return new ANPPaint;
|
||||
}
|
||||
|
||||
static void anp_deletePaint(ANPPaint* paint) {
|
||||
delete paint;
|
||||
}
|
||||
|
||||
static ANPPaintFlags anp_getFlags(const ANPPaint* paint) {
|
||||
return paint->getFlags();
|
||||
}
|
||||
|
||||
static void anp_setFlags(ANPPaint* paint, ANPPaintFlags flags) {
|
||||
paint->setFlags(flags);
|
||||
}
|
||||
|
||||
static ANPColor anp_getColor(const ANPPaint* paint) {
|
||||
return paint->getColor();
|
||||
}
|
||||
|
||||
static void anp_setColor(ANPPaint* paint, ANPColor color) {
|
||||
paint->setColor(color);
|
||||
}
|
||||
|
||||
static ANPPaintStyle anp_getStyle(const ANPPaint* paint) {
|
||||
return paint->getStyle();
|
||||
}
|
||||
|
||||
static void anp_setStyle(ANPPaint* paint, ANPPaintStyle style) {
|
||||
paint->setStyle(static_cast<SkPaint::Style>(style));
|
||||
}
|
||||
|
||||
static float anp_getStrokeWidth(const ANPPaint* paint) {
|
||||
return SkScalarToFloat(paint->getStrokeWidth());
|
||||
}
|
||||
|
||||
static float anp_getStrokeMiter(const ANPPaint* paint) {
|
||||
return SkScalarToFloat(paint->getStrokeMiter());
|
||||
}
|
||||
|
||||
static ANPPaintCap anp_getStrokeCap(const ANPPaint* paint) {
|
||||
return paint->getStrokeCap();
|
||||
}
|
||||
|
||||
static ANPPaintJoin anp_getStrokeJoin(const ANPPaint* paint) {
|
||||
return paint->getStrokeJoin();
|
||||
}
|
||||
|
||||
static void anp_setStrokeWidth(ANPPaint* paint, float width) {
|
||||
paint->setStrokeWidth(SkFloatToScalar(width));
|
||||
}
|
||||
|
||||
static void anp_setStrokeMiter(ANPPaint* paint, float miter) {
|
||||
paint->setStrokeMiter(SkFloatToScalar(miter));
|
||||
}
|
||||
|
||||
static void anp_setStrokeCap(ANPPaint* paint, ANPPaintCap cap) {
|
||||
paint->setStrokeCap(static_cast<SkPaint::Cap>(cap));
|
||||
}
|
||||
|
||||
static void anp_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join) {
|
||||
paint->setStrokeJoin(static_cast<SkPaint::Join>(join));
|
||||
}
|
||||
|
||||
static ANPTextEncoding anp_getTextEncoding(const ANPPaint* paint) {
|
||||
return paint->getTextEncoding();
|
||||
}
|
||||
|
||||
static ANPPaintAlign anp_getTextAlign(const ANPPaint* paint) {
|
||||
return paint->getTextAlign();
|
||||
}
|
||||
|
||||
static float anp_getTextSize(const ANPPaint* paint) {
|
||||
return SkScalarToFloat(paint->getTextSize());
|
||||
}
|
||||
|
||||
static float anp_getTextScaleX(const ANPPaint* paint) {
|
||||
return SkScalarToFloat(paint->getTextScaleX());
|
||||
}
|
||||
|
||||
static float anp_getTextSkewX(const ANPPaint* paint) {
|
||||
return SkScalarToFloat(paint->getTextSkewX());
|
||||
}
|
||||
|
||||
static ANPTypeface* anp_getTypeface(const ANPPaint* paint) {
|
||||
return reinterpret_cast<ANPTypeface*>(paint->getTypeface());
|
||||
}
|
||||
|
||||
static void anp_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding) {
|
||||
paint->setTextEncoding(static_cast<SkPaint::TextEncoding>(encoding));
|
||||
}
|
||||
|
||||
static void anp_setTextAlign(ANPPaint* paint, ANPPaintAlign align) {
|
||||
paint->setTextAlign(static_cast<SkPaint::Align>(align));
|
||||
}
|
||||
|
||||
static void anp_setTextSize(ANPPaint* paint, float textSize) {
|
||||
paint->setTextSize(SkFloatToScalar(textSize));
|
||||
}
|
||||
|
||||
static void anp_setTextScaleX(ANPPaint* paint, float scaleX) {
|
||||
paint->setTextScaleX(SkFloatToScalar(scaleX));
|
||||
}
|
||||
|
||||
static void anp_setTextSkewX(ANPPaint* paint, float skewX) {
|
||||
paint->setTextSkewX(SkFloatToScalar(skewX));
|
||||
}
|
||||
|
||||
static void anp_setTypeface(ANPPaint* paint, ANPTypeface* tf) {
|
||||
paint->setTypeface(sk_ref_sp(tf));
|
||||
}
|
||||
|
||||
static float anp_measureText(ANPPaint* paint, const void* text,
|
||||
uint32_t byteLength, ANPRectF* bounds) {
|
||||
SkScalar w = paint->measureText(text, byteLength,
|
||||
reinterpret_cast<SkRect*>(bounds));
|
||||
return SkScalarToFloat(w);
|
||||
}
|
||||
|
||||
/** Return the number of unichars specifed by the text.
|
||||
If widths is not null, returns the array of advance widths for each
|
||||
unichar.
|
||||
If bounds is not null, returns the array of bounds for each unichar.
|
||||
*/
|
||||
static int anp_getTextWidths(ANPPaint* paint, const void* text,
|
||||
uint32_t byteLength, float widths[], ANPRectF bounds[]) {
|
||||
return paint->getTextWidths(text, byteLength, widths,
|
||||
reinterpret_cast<SkRect*>(bounds));
|
||||
}
|
||||
|
||||
static float anp_getFontMetrics(ANPPaint* paint, ANPFontMetrics* metrics) {
|
||||
SkPaint::FontMetrics fm;
|
||||
SkScalar spacing = paint->getFontMetrics(&fm);
|
||||
if (metrics) {
|
||||
metrics->fTop = SkScalarToFloat(fm.fTop);
|
||||
metrics->fAscent = SkScalarToFloat(fm.fAscent);
|
||||
metrics->fDescent = SkScalarToFloat(fm.fDescent);
|
||||
metrics->fBottom = SkScalarToFloat(fm.fBottom);
|
||||
metrics->fLeading = SkScalarToFloat(fm.fLeading);
|
||||
}
|
||||
return SkScalarToFloat(spacing);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_##name
|
||||
|
||||
void InitPaintInterface(ANPPaintInterfaceV0* i) {
|
||||
ASSIGN(i, newPaint);
|
||||
ASSIGN(i, deletePaint);
|
||||
ASSIGN(i, getFlags);
|
||||
ASSIGN(i, setFlags);
|
||||
ASSIGN(i, getColor);
|
||||
ASSIGN(i, setColor);
|
||||
ASSIGN(i, getStyle);
|
||||
ASSIGN(i, setStyle);
|
||||
ASSIGN(i, getStrokeWidth);
|
||||
ASSIGN(i, getStrokeMiter);
|
||||
ASSIGN(i, getStrokeCap);
|
||||
ASSIGN(i, getStrokeJoin);
|
||||
ASSIGN(i, setStrokeWidth);
|
||||
ASSIGN(i, setStrokeMiter);
|
||||
ASSIGN(i, setStrokeCap);
|
||||
ASSIGN(i, setStrokeJoin);
|
||||
ASSIGN(i, getTextEncoding);
|
||||
ASSIGN(i, getTextAlign);
|
||||
ASSIGN(i, getTextSize);
|
||||
ASSIGN(i, getTextScaleX);
|
||||
ASSIGN(i, getTextSkewX);
|
||||
ASSIGN(i, getTypeface);
|
||||
ASSIGN(i, setTextEncoding);
|
||||
ASSIGN(i, setTextAlign);
|
||||
ASSIGN(i, setTextSize);
|
||||
ASSIGN(i, setTextScaleX);
|
||||
ASSIGN(i, setTextSkewX);
|
||||
ASSIGN(i, setTypeface);
|
||||
ASSIGN(i, measureText);
|
||||
ASSIGN(i, getTextWidths);
|
||||
ASSIGN(i, getFontMetrics);
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// must include config.h first for webkit to fiddle with new/delete
|
||||
#include "SkANP.h"
|
||||
#include "SkStream.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) {
|
||||
sk_sp<SkTypeface> tf = SkTypeface::MakeFromName(name,
|
||||
SkFontStyle::FromOldStyle(s));
|
||||
return reinterpret_cast<ANPTypeface*>(tf.release());
|
||||
}
|
||||
|
||||
static ANPTypeface* anp_createFromTypeface(const ANPTypeface* family,
|
||||
ANPTypefaceStyle s) {
|
||||
sk_sp<SkTypeface> tf = SkTypeface::MakeFromTypeface(const_cast<ANPTypeface*>(family),
|
||||
static_cast<SkTypeface::Style>(s));
|
||||
return reinterpret_cast<ANPTypeface*>(tf.release());
|
||||
}
|
||||
|
||||
static int32_t anp_getRefCount(const ANPTypeface* tf) {
|
||||
return tf ? tf->getRefCnt() : 0;
|
||||
}
|
||||
|
||||
static void anp_ref(ANPTypeface* tf) {
|
||||
SkSafeRef(tf);
|
||||
}
|
||||
|
||||
static void anp_unref(ANPTypeface* tf) {
|
||||
SkSafeUnref(tf);
|
||||
}
|
||||
|
||||
static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) {
|
||||
SkTypeface::Style s = tf ? tf->style() : SkTypeface::kNormal;
|
||||
return static_cast<ANPTypefaceStyle>(s);
|
||||
}
|
||||
|
||||
static int32_t anp_getFontPath(const ANPTypeface* tf, char fileName[],
|
||||
int32_t length, int32_t* index) {
|
||||
return 0;
|
||||
/*
|
||||
SkStream* stream = tf->openStream(index);
|
||||
if (stream->getFileName()) {
|
||||
strcpy(fileName, stream->getFileName());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return strlen(fileName);
|
||||
*/
|
||||
}
|
||||
|
||||
static const char* gFontDir;
|
||||
#define FONT_DIR_SUFFIX "/fonts/"
|
||||
|
||||
static const char* anp_getFontDirectoryPath() {
|
||||
if (NULL == gFontDir) {
|
||||
const char* root = getenv("ANDROID_ROOT");
|
||||
size_t len = strlen(root);
|
||||
char* storage = (char*)malloc(len + sizeof(FONT_DIR_SUFFIX));
|
||||
if (NULL == storage) {
|
||||
return NULL;
|
||||
}
|
||||
memcpy(storage, root, len);
|
||||
memcpy(storage + len, FONT_DIR_SUFFIX, sizeof(FONT_DIR_SUFFIX));
|
||||
// save this assignment for last, so that if multiple threads call us
|
||||
// (which should never happen), we never return an incomplete global.
|
||||
// At worst, we would allocate storage for the path twice.
|
||||
gFontDir = storage;
|
||||
}
|
||||
return gFontDir;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ASSIGN(obj, name) (obj)->name = anp_##name
|
||||
|
||||
void InitTypeFaceInterface(ANPTypefaceInterfaceV0* i) {
|
||||
ASSIGN(i, createFromName);
|
||||
ASSIGN(i, createFromTypeface);
|
||||
ASSIGN(i, getRefCount);
|
||||
ASSIGN(i, ref);
|
||||
ASSIGN(i, unref);
|
||||
ASSIGN(i, getStyle);
|
||||
ASSIGN(i, getFontPath);
|
||||
ASSIGN(i, getFontDirectoryPath);
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// must include config.h first for webkit to fiddle with new/delete
|
||||
#include "SkANP.h"
|
||||
|
||||
SkRect* SkANP::SetRect(SkRect* dst, const ANPRectF& src) {
|
||||
dst->set(SkFloatToScalar(src.left),
|
||||
SkFloatToScalar(src.top),
|
||||
SkFloatToScalar(src.right),
|
||||
SkFloatToScalar(src.bottom));
|
||||
return dst;
|
||||
}
|
||||
|
||||
SkIRect* SkANP::SetRect(SkIRect* dst, const ANPRectI& src) {
|
||||
dst->set(src.left, src.top, src.right, src.bottom);
|
||||
return dst;
|
||||
}
|
||||
|
||||
ANPRectI* SkANP::SetRect(ANPRectI* dst, const SkIRect& src) {
|
||||
dst->left = src.fLeft;
|
||||
dst->top = src.fTop;
|
||||
dst->right = src.fRight;
|
||||
dst->bottom = src.fBottom;
|
||||
return dst;
|
||||
}
|
||||
|
||||
ANPRectF* SkANP::SetRect(ANPRectF* dst, const SkRect& src) {
|
||||
dst->left = SkScalarToFloat(src.fLeft);
|
||||
dst->top = SkScalarToFloat(src.fTop);
|
||||
dst->right = SkScalarToFloat(src.fRight);
|
||||
dst->bottom = SkScalarToFloat(src.fBottom);
|
||||
return dst;
|
||||
}
|
||||
|
||||
SkBitmap* SkANP::SetBitmap(SkBitmap* dst, const ANPBitmap& src) {
|
||||
SkColorType colorType = kUnknown_SkColorType;
|
||||
|
||||
switch (src.format) {
|
||||
case kRGBA_8888_ANPBitmapFormat:
|
||||
// Let Skia choose the correct colour type for us based on its
|
||||
// endianness. This should be correct.
|
||||
colorType = kN32_SkColorType;
|
||||
break;
|
||||
case kRGB_565_ANPBitmapFormat:
|
||||
colorType = kRGB_565_SkColorType;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SkImageInfo info = SkImageInfo::Make(src.width, src.height, colorType, kPremul_SkAlphaType);
|
||||
dst->setInfo(info, src.rowBytes);
|
||||
dst->setPixels(src.baseAddr);
|
||||
return dst;
|
||||
}
|
||||
|
||||
bool SkANP::SetBitmap(ANPBitmap* dst, const SkBitmap& src) {
|
||||
if (!(dst->baseAddr = src.getPixels())) {
|
||||
SkDebugf("SkANP::SetBitmap - getPixels() returned null\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (src.colorType()) {
|
||||
case SkColorType::kRGBA_8888_SkColorType:
|
||||
dst->format = kRGBA_8888_ANPBitmapFormat;
|
||||
break;
|
||||
case SkColorType::kRGB_565_SkColorType:
|
||||
dst->format = kRGB_565_ANPBitmapFormat;
|
||||
break;
|
||||
default:
|
||||
SkDebugf("SkANP::SetBitmap - unsupported src.colorType %d\n", src.colorType());
|
||||
return false;
|
||||
}
|
||||
|
||||
dst->width = src.width();
|
||||
dst->height = src.height();
|
||||
dst->rowBytes = src.rowBytes();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkANP::InitEvent(ANPEvent* event, ANPEventType et) {
|
||||
event->inSize = sizeof(ANPEvent);
|
||||
event->eventType = et;
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, The Android Open Source Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SkANP_DEFINED
|
||||
#define SkANP_DEFINED
|
||||
|
||||
#include "android_npapi.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkTypeface.h"
|
||||
|
||||
struct ANPMatrix : SkMatrix {
|
||||
};
|
||||
|
||||
struct ANPPath : SkPath {
|
||||
};
|
||||
|
||||
struct ANPPaint : SkPaint {
|
||||
};
|
||||
|
||||
struct ANPTypeface : SkTypeface {
|
||||
};
|
||||
|
||||
struct ANPCanvas {
|
||||
SkCanvas* skcanvas;
|
||||
|
||||
// draw into the specified bitmap
|
||||
explicit ANPCanvas(const SkBitmap& bm) {
|
||||
skcanvas = new SkCanvas(bm);
|
||||
}
|
||||
|
||||
// redirect all drawing to the specific SkCanvas
|
||||
explicit ANPCanvas(SkCanvas* other) {
|
||||
skcanvas = other;
|
||||
}
|
||||
|
||||
~ANPCanvas() {
|
||||
delete skcanvas;
|
||||
}
|
||||
};
|
||||
|
||||
class SkANP {
|
||||
public:
|
||||
static SkRect* SetRect(SkRect* dst, const ANPRectF& src);
|
||||
static SkIRect* SetRect(SkIRect* dst, const ANPRectI& src);
|
||||
static ANPRectI* SetRect(ANPRectI* dst, const SkIRect& src);
|
||||
static ANPRectF* SetRect(ANPRectF* dst, const SkRect& src);
|
||||
static SkBitmap* SetBitmap(SkBitmap* dst, const ANPBitmap& src);
|
||||
static bool SetBitmap(ANPBitmap* dst, const SkBitmap& src);
|
||||
|
||||
static void InitEvent(ANPEvent* event, ANPEventType et);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'SkANP.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'ANPCanvas.cpp',
|
||||
'ANPPaint.cpp',
|
||||
'ANPTypeface.cpp',
|
||||
'SkANP.cpp',
|
||||
]
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/plugins/base',
|
||||
'/dom/plugins/base/android',
|
||||
'/gfx/gl',
|
||||
'/gfx/skia/skia/include/config',
|
||||
'/gfx/skia/skia/include/core',
|
||||
]
|
|
@ -90,12 +90,6 @@ DIRS += [
|
|||
'/xpfe/appshell'
|
||||
]
|
||||
|
||||
# This needs to be built after the gfx/ directory
|
||||
# to ensure all dependencies for skia (e.g. mozalloc, xpcom)
|
||||
# have been built
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
DIRS += ['/other-licenses/skia-npapi']
|
||||
|
||||
if CONFIG['MOZ_UNIVERSALCHARDET']:
|
||||
DIRS += ['/extensions/universalchardet']
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "AndroidRect.h"
|
||||
#include "KeyEvent.h"
|
||||
#include "PuppetWidget.h"
|
||||
#include "android_npapi.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsISelection.h"
|
||||
|
||||
|
@ -302,24 +301,6 @@ InitKeyEvent(WidgetKeyboardEvent& aEvent, int32_t aAction, int32_t aKeyCode,
|
|||
aEvent.mModifiers = nsWindow::GetModifiers(aMetaState);
|
||||
aEvent.mKeyCode = domKeyCode;
|
||||
|
||||
if (aEvent.mMessage != eKeyPress) {
|
||||
ANPEvent pluginEvent;
|
||||
pluginEvent.inSize = sizeof(pluginEvent);
|
||||
pluginEvent.eventType = kKey_ANPEventType;
|
||||
pluginEvent.data.key.action = (aEvent.mMessage == eKeyDown) ?
|
||||
kDown_ANPKeyAction : kUp_ANPKeyAction;
|
||||
pluginEvent.data.key.nativeCode = aKeyCode;
|
||||
pluginEvent.data.key.virtualCode = domKeyCode;
|
||||
pluginEvent.data.key.unichar = aDomPrintableKeyValue;
|
||||
pluginEvent.data.key.modifiers =
|
||||
(aMetaState & sdk::KeyEvent::META_SHIFT_MASK
|
||||
? kShift_ANPKeyModifier : 0) |
|
||||
(aMetaState & sdk::KeyEvent::META_ALT_MASK
|
||||
? kAlt_ANPKeyModifier : 0);
|
||||
pluginEvent.data.key.repeatCount = aRepeatCount;
|
||||
aEvent.mPluginEvent.Copy(pluginEvent);
|
||||
}
|
||||
|
||||
aEvent.mIsRepeat =
|
||||
(aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyPress) &&
|
||||
((aFlags & sdk::KeyEvent::FLAG_LONG_PRESS) || aRepeatCount);
|
||||
|
|
|
@ -36,21 +36,6 @@ const JNINativeMethod ANRReporter::Natives<Impl>::methods[] = {
|
|||
::template Wrap<&Impl::RequestNativeStack>)
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
class GeckoApp::Natives : public mozilla::jni::NativeImpl<GeckoApp, Impl>
|
||||
{
|
||||
public:
|
||||
static const JNINativeMethod methods[1];
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
const JNINativeMethod GeckoApp::Natives<Impl>::methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoApp::OnFullScreenPluginHidden_t>(
|
||||
mozilla::jni::NativeStub<GeckoApp::OnFullScreenPluginHidden_t, Impl>
|
||||
::template Wrap<&Impl::OnFullScreenPluginHidden>)
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
class GeckoJavaSampler::Natives : public mozilla::jni::NativeImpl<GeckoJavaSampler, Impl>
|
||||
{
|
||||
|
|
|
@ -44,22 +44,6 @@ auto DownloadsIntegration::ScanMedia(mozilla::jni::String::Param a0, mozilla::jn
|
|||
const char GeckoApp::name[] =
|
||||
"org/mozilla/gecko/GeckoApp";
|
||||
|
||||
constexpr char GeckoApp::AddPluginView_t::name[];
|
||||
constexpr char GeckoApp::AddPluginView_t::signature[];
|
||||
|
||||
auto GeckoApp::AddPluginView(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<AddPluginView_t>::Call(GeckoApp::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoApp::GetPluginContext_t::name[];
|
||||
constexpr char GeckoApp::GetPluginContext_t::signature[];
|
||||
|
||||
auto GeckoApp::GetPluginContext() -> mozilla::jni::Object::LocalRef
|
||||
{
|
||||
return mozilla::jni::Method<GetPluginContext_t>::Call(GeckoApp::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoApp::LaunchOrBringToFront_t::name[];
|
||||
constexpr char GeckoApp::LaunchOrBringToFront_t::signature[];
|
||||
|
||||
|
@ -68,17 +52,6 @@ auto GeckoApp::LaunchOrBringToFront() -> void
|
|||
return mozilla::jni::Method<LaunchOrBringToFront_t>::Call(GeckoApp::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoApp::OnFullScreenPluginHidden_t::name[];
|
||||
constexpr char GeckoApp::OnFullScreenPluginHidden_t::signature[];
|
||||
|
||||
constexpr char GeckoApp::RemovePluginView_t::name[];
|
||||
constexpr char GeckoApp::RemovePluginView_t::signature[];
|
||||
|
||||
auto GeckoApp::RemovePluginView(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<RemovePluginView_t>::Call(GeckoApp::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
const char GeckoApplication::name[] =
|
||||
"org/mozilla/gecko/GeckoApplication";
|
||||
|
||||
|
|
|
@ -136,45 +136,6 @@ public:
|
|||
|
||||
explicit GeckoApp(const Context& ctx) : ObjectBase<GeckoApp>(ctx) {}
|
||||
|
||||
struct AddPluginView_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "addPluginView";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/view/View;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto AddPluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
struct GetPluginContext_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef mozilla::jni::Object::LocalRef ReturnType;
|
||||
typedef mozilla::jni::Object::Param SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getPluginContext";
|
||||
static constexpr char signature[] =
|
||||
"()Landroid/content/Context;";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto GetPluginContext() -> mozilla::jni::Object::LocalRef;
|
||||
|
||||
struct LaunchOrBringToFront_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef void ReturnType;
|
||||
|
@ -194,48 +155,9 @@ public:
|
|||
|
||||
static auto LaunchOrBringToFront() -> void;
|
||||
|
||||
struct OnFullScreenPluginHidden_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "onFullScreenPluginHidden";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/view/View;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::UI;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct RemovePluginView_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "removePluginView";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/view/View;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto RemovePluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
|
||||
template<class Impl> class Natives;
|
||||
};
|
||||
|
||||
class GeckoApplication : public mozilla::jni::ObjectBase<GeckoApplication>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_GeckoApp_h__
|
||||
#define mozilla_GeckoApp_h__
|
||||
|
||||
#include "FennecJNINatives.h"
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class GeckoApp final
|
||||
: public java::GeckoApp::Natives<GeckoApp>
|
||||
{
|
||||
GeckoApp() = delete;
|
||||
|
||||
public:
|
||||
static void OnFullScreenPluginHidden(jni::Object::Param aView)
|
||||
{
|
||||
nsPluginInstanceOwner::ExitFullScreen(aView.Get());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_GeckoApp_h__
|
|
@ -70,7 +70,6 @@
|
|||
#include "GeckoProcessManager.h"
|
||||
#include "GeckoScreenOrientation.h"
|
||||
#include "PrefsHelper.h"
|
||||
#include "fennec/GeckoApp.h"
|
||||
#include "fennec/MemoryMonitor.h"
|
||||
#include "fennec/Telemetry.h"
|
||||
#include "fennec/ThumbnailHelper.h"
|
||||
|
@ -412,7 +411,6 @@ nsAppShell::nsAppShell()
|
|||
|
||||
if (jni::IsFennec()) {
|
||||
mozilla::ANRReporter::Init();
|
||||
mozilla::GeckoApp::Init();
|
||||
mozilla::MemoryMonitor::Init();
|
||||
mozilla::widget::Telemetry::Init();
|
||||
mozilla::ThumbnailHelper::Init();
|
||||
|
|
|
@ -72,7 +72,6 @@ using mozilla::Unused;
|
|||
#include "AndroidBridge.h"
|
||||
#include "AndroidBridgeUtilities.h"
|
||||
#include "AndroidUiThread.h"
|
||||
#include "android_npapi.h"
|
||||
#include "FennecJNINatives.h"
|
||||
#include "GeneratedJNINatives.h"
|
||||
#include "GeckoEditableSupport.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче