mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Merge remote-tracking branch 'origin/master' into custom
This commit is contained in:
commit
2c79eebb23
229 changed files with 212 additions and 23172 deletions
|
|
@ -1018,7 +1018,9 @@ this.PlacesUIUtils = {
|
|||
if (PlacesUtils.nodeIsURI(aNodes[i]))
|
||||
urlsToOpen.push({uri: aNodes[i].uri, isBookmark: PlacesUtils.nodeIsBookmark(aNodes[i])});
|
||||
}
|
||||
this._openTabset(urlsToOpen, aEvent, window);
|
||||
if (this.confirmOpenInTabs(urlsToOpen.length, window)) {
|
||||
this._openTabset(urlsToOpen, aEvent, window);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pref("@GUAO_PREF@.twitter.com","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_D
|
|||
// UA-Sniffing domains below have indicated no interest in supporting Pale Moon (BOO!)
|
||||
pref("@GUAO_PREF@.humblebundle.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)");
|
||||
pref("@GUAO_PREF@.privat24.ua","Mozilla/5.0 (%OS_SLICE% rv:38.0) @GK_SLICE@ Firefox/38.0");
|
||||
pref("@GUAO_PREF@.citi.com","Mozilla/5.0 (%OS_SLICE% rv:81.0) @GK_SLICE@ Firefox/81.0 (Pale Moon)");
|
||||
pref("@GUAO_PREF@.citi.com","Mozilla/5.0 (%OS_SLICE% rv:88.0) @GK_SLICE@ Firefox/88.0 (Pale Moon)");
|
||||
pref("@GUAO_PREF@.netflix.com","Mozilla/5.0 (Windows NT 6.1; rv:45.9) @GK_SLICE@ Firefox/45.9");
|
||||
pref("@GUAO_PREF@.netflximg.net","Mozilla/5.0 (Windows NT 6.1; rv:45.9) @GK_SLICE@ Firefox/45.9");
|
||||
|
||||
|
|
|
|||
|
|
@ -542,20 +542,6 @@ def target_is_unix(target):
|
|||
|
||||
set_define('XP_UNIX', target_is_unix)
|
||||
|
||||
@depends(target)
|
||||
def target_is_darwin(target):
|
||||
if target.kernel == 'Darwin':
|
||||
return True
|
||||
|
||||
set_define('XP_DARWIN', target_is_darwin)
|
||||
|
||||
@depends(target)
|
||||
def target_is_ios(target):
|
||||
if target.kernel == 'Darwin' and target.os == 'iOS':
|
||||
return True
|
||||
|
||||
set_define('XP_IOS', target_is_ios)
|
||||
|
||||
@depends(target)
|
||||
def target_is_osx(target):
|
||||
if target.kernel == 'Darwin' and target.os == 'OSX':
|
||||
|
|
|
|||
4
config/external/nspr/prcpucfg.h
vendored
4
config/external/nspr/prcpucfg.h
vendored
|
|
@ -10,9 +10,7 @@
|
|||
* Need to support conditionals that are defined in both the top-level build
|
||||
* system as well as NSS' build system for now.
|
||||
*/
|
||||
#if defined(XP_DARWIN) || defined(DARWIN)
|
||||
#include "md/_darwin.cfg"
|
||||
#elif defined(XP_WIN) || defined(_WINDOWS)
|
||||
#if defined(XP_WIN) || defined(_WINDOWS)
|
||||
#include "md/_win95.cfg"
|
||||
#elif defined(__FreeBSD__)
|
||||
#include "md/_freebsd.cfg"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
#ifndef mozilla_${HEADER}_h
|
||||
#define mozilla_${HEADER}_h
|
||||
|
||||
// For some reason, Apple's GCC refuses to honor -fno-exceptions when
|
||||
// compiling ObjC.
|
||||
#if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
|
||||
#if defined(__EXCEPTIONS) && __EXCEPTIONS
|
||||
# error "STL code can only be used with -fno-exceptions"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1407,12 +1407,6 @@ Navigator::GetPlatform(nsAString& aPlatform, bool aUsePrefOverriddenValue)
|
|||
aPlatform.AssignLiteral("Win64");
|
||||
#elif defined(WIN32)
|
||||
aPlatform.AssignLiteral("Win32");
|
||||
#elif defined(XP_MACOSX) && defined(__ppc__)
|
||||
aPlatform.AssignLiteral("MacPPC");
|
||||
#elif defined(XP_MACOSX) && defined(__i386__)
|
||||
aPlatform.AssignLiteral("MacIntel");
|
||||
#elif defined(XP_MACOSX) && defined(__x86_64__)
|
||||
aPlatform.AssignLiteral("MacIntel");
|
||||
#else
|
||||
// XXX Communicator uses compiled-in build-time string defines
|
||||
// to indicate the platform it was compiled *for*, not what it is
|
||||
|
|
|
|||
|
|
@ -6842,10 +6842,6 @@ nsContentUtils::HaveEqualPrincipals(nsIDocument* aDoc1, nsIDocument* aDoc2)
|
|||
bool
|
||||
nsContentUtils::HasPluginWithUncontrolledEventDispatch(nsIContent* aContent)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
// We control dispatch to all mac plugins.
|
||||
return false;
|
||||
#else
|
||||
if (!aContent || !aContent->IsInUncomposedDoc()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -6868,7 +6864,6 @@ nsContentUtils::HasPluginWithUncontrolledEventDispatch(nsIContent* aContent)
|
|||
}
|
||||
|
||||
return !isWindowless;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
|||
|
|
@ -66,9 +66,7 @@
|
|||
#include "nsAccessibilityService.h"
|
||||
#endif
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
#include "nsIScriptError.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
|
@ -1270,12 +1268,10 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
|
|||
}
|
||||
}
|
||||
|
||||
// Exit fullscreen if we're focusing a windowed plugin on a non-MacOSX
|
||||
// system. We don't control event dispatch to windowed plugins on non-MacOSX,
|
||||
// so we can't display the "Press ESC to leave fullscreen mode" warning on
|
||||
// key input if a windowed plugin is focused, so just exit fullscreen
|
||||
// to guard against phishing.
|
||||
#ifndef XP_MACOSX
|
||||
// Exit fullscreen if we're focusing a windowed plugin. We don't control
|
||||
// event dispatch to windowed plugins, so we can't display the <Press ESC
|
||||
// to leave fullscreen mode> warning on key input if a windowed plugin is
|
||||
// focused, so just exit fullscreen to guard against phishing.
|
||||
if (contentToFocus &&
|
||||
nsContentUtils::
|
||||
GetRootDocument(contentToFocus->OwnerDoc())->GetFullscreenElement() &&
|
||||
|
|
@ -1287,7 +1283,6 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
|
|||
"FocusedWindowedPluginWhileFullscreen");
|
||||
nsIDocument::AsyncExitFullscreen(contentToFocus->OwnerDoc());
|
||||
}
|
||||
#endif
|
||||
|
||||
// if the FLAG_NOSWITCHFRAME flag is used, only allow the focus to be
|
||||
// shifted away from the current element if the new shell to focus is
|
||||
|
|
|
|||
|
|
@ -6254,18 +6254,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop, bool aCal
|
|||
screen->GetAvailLeft(&screenLeft);
|
||||
screen->GetAvailWidth(&screenWidth);
|
||||
screen->GetAvailHeight(&screenHeight);
|
||||
#if defined(XP_MACOSX)
|
||||
/* The mac's coordinate system is different from the assumed Windows'
|
||||
system. It offsets by the height of the menubar so that a window
|
||||
placed at (0,0) will be entirely visible. Unfortunately that
|
||||
correction is made elsewhere (in Widget) and the meaning of
|
||||
the Avail... coordinates is overloaded. Here we allow a window
|
||||
to be placed at (0,0) because it does make sense to do so.
|
||||
*/
|
||||
screen->GetTop(&screenTop);
|
||||
#else
|
||||
screen->GetAvailTop(&screenTop);
|
||||
#endif
|
||||
|
||||
if (aLeft) {
|
||||
if (screenLeft+screenWidth < *aLeft+winWidth)
|
||||
|
|
@ -7103,16 +7092,6 @@ nsGlobalWindow::Dump(const nsAString& aStr)
|
|||
|
||||
char *cstr = ToNewUTF8String(aStr);
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// have to convert \r to \n so that printing to the console works
|
||||
char *c = cstr, *cEnd = cstr + strlen(cstr);
|
||||
while (c < cEnd) {
|
||||
if (*c == '\r')
|
||||
*c = '\n';
|
||||
c++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cstr) {
|
||||
MOZ_LOG(nsContentUtils::DOMDumpLog(), LogLevel::Debug, ("[Window.Dump] %s", cstr));
|
||||
#ifdef XP_WIN
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@
|
|||
|
||||
#include "nsJSPrincipals.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// AssertMacros.h defines 'check' and conflicts with AccessCheck.h
|
||||
#undef check
|
||||
#endif
|
||||
#include "AccessCheck.h"
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
|
|
|
|||
|
|
@ -95,13 +95,6 @@
|
|||
#endif
|
||||
#endif // XP_WIN
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// HandlePluginCrashed() and HandlePluginInstantiated() needed from here to
|
||||
// fix bug 1147521. Should later be replaced by proper interface methods,
|
||||
// maybe on nsIObjectLoadingContext.
|
||||
#include "mozilla/dom/HTMLObjectElement.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
static const char *kPrefJavaMIME = "plugin.java.mime";
|
||||
|
|
@ -916,10 +909,6 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
|
|||
NS_LITERAL_STRING("PluginInstantiated"));
|
||||
NS_DispatchToCurrentThread(ev);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
HTMLObjectElement::HandlePluginInstantiated(thisContent->AsElement());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2948,10 +2937,6 @@ nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
|
|||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
HTMLObjectElement::HandlePluginCrashed(thisContent->AsElement());
|
||||
#endif
|
||||
|
||||
PluginDestroyed();
|
||||
|
||||
// Switch to fallback/crashed state, notify
|
||||
|
|
@ -3190,10 +3175,6 @@ nsObjectLoadingContent::DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner,
|
|||
return;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
aInstanceOwner->HidePluginWindow();
|
||||
#endif
|
||||
|
||||
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
||||
NS_ASSERTION(pluginHost, "No plugin host?");
|
||||
pluginHost->StopPluginInstance(inst);
|
||||
|
|
|
|||
|
|
@ -37,14 +37,8 @@ nsWindowRoot::nsWindowRoot(nsPIDOMWindowOuter* aWindow)
|
|||
mWindow = aWindow;
|
||||
MOZ_ASSERT(mWindow->IsOuterWindow());
|
||||
|
||||
// Keyboard indicators are not shown on Mac by default.
|
||||
#if defined(XP_MACOSX)
|
||||
mShowAccelerators = false;
|
||||
mShowFocusRings = false;
|
||||
#else
|
||||
mShowAccelerators = true;
|
||||
mShowFocusRings = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsWindowRoot::~nsWindowRoot()
|
||||
|
|
|
|||
|
|
@ -126,13 +126,6 @@ WebGLContext::InitWebGL2(FailureReason* const out_failReason)
|
|||
fnGatherMissing2(gl::GLFeature::occlusion_query_boolean,
|
||||
gl::GLFeature::occlusion_query);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// On OSX, GL core profile is used. This requires texture swizzle
|
||||
// support to emulate legacy texture formats: ALPHA, LUMINANCE,
|
||||
// and LUMINANCE_ALPHA.
|
||||
fnGatherMissing(gl::GLFeature::texture_swizzle);
|
||||
#endif
|
||||
|
||||
fnGatherMissing2(gl::GLFeature::prim_restart_fixed,
|
||||
gl::GLFeature::prim_restart);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa
|
|||
const ScopedLazyBind lazyBind(gl, target, this);
|
||||
mContext->InvalidateBufferFetching();
|
||||
|
||||
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// bug 790879
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
size > INT32_MAX)
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@
|
|||
#include "ScopedGLHelpers.h"
|
||||
#include "TexUnpackBlob.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "ForceDiscreteGPUHelperCGL.h"
|
||||
#endif
|
||||
|
||||
// Local
|
||||
#include "WebGLContextLossHandler.h"
|
||||
#include "WebGLContextUnchecked.h"
|
||||
|
|
@ -2015,15 +2011,6 @@ protected:
|
|||
JSObject* WebGLObjectAsJSObject(JSContext* cx, const WebGLObjectType*,
|
||||
ErrorResult& rv) const;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// see bug 713305. This RAII helper guarantees that we're on the discrete GPU, during its lifetime
|
||||
// Debouncing note: we don't want to switch GPUs too frequently, so try to not create and destroy
|
||||
// these objects at high frequency. Having WebGLContext's hold one such object seems fine,
|
||||
// because WebGLContext objects only go away during GC, which shouldn't happen too frequently.
|
||||
// If in the future GC becomes much more frequent, we may have to revisit then (maybe use a timer).
|
||||
ForceDiscreteGPUHelperCGL mForceDiscreteGPUHelper;
|
||||
#endif
|
||||
|
||||
public:
|
||||
// console logging helpers
|
||||
void GenerateWarning(const char* fmt, ...);
|
||||
|
|
|
|||
|
|
@ -295,16 +295,6 @@ WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
|||
|
||||
////
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (buffer && buffer->Content() == WebGLBuffer::Kind::Undefined &&
|
||||
gl->WorkAroundDriverBugs())
|
||||
{
|
||||
// BindBufferRange will fail if the buffer's contents is undefined.
|
||||
// Bind so driver initializes the buffer.
|
||||
gl->fBindBuffer(target, buffer->mGLName);
|
||||
}
|
||||
#endif
|
||||
|
||||
gl->fBindBufferRange(target, index, buffer ? buffer->mGLName : 0, offset, size);
|
||||
|
||||
////
|
||||
|
|
@ -352,12 +342,6 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
|
|||
if (!checkedSize.isValid())
|
||||
return ErrorOutOfMemory("%s: Size too large for platform.", funcName);
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
if (gl->WorkAroundDriverBugs() && size > 1200000000) {
|
||||
return ErrorOutOfMemory("Allocations larger than 1200000000 fail on MacOS.");
|
||||
}
|
||||
#endif
|
||||
|
||||
const UniqueBuffer zeroBuffer(calloc(size, 1));
|
||||
if (!zeroBuffer)
|
||||
return ErrorOutOfMemory("%s: Failed to allocate zeros.", funcName);
|
||||
|
|
|
|||
|
|
@ -1045,13 +1045,6 @@ WebGLContext::WhatDoesVertexAttrib0Need() const
|
|||
const auto& isAttribArray0Enabled = mBoundVertexArray->mAttribs[0].mEnabled;
|
||||
|
||||
bool legacyAttrib0 = gl->IsCompatibilityProfile();
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
// Failures in conformance/attribs/gl-disabled-vertex-attrib.
|
||||
// Even in Core profiles on NV. Sigh.
|
||||
legacyAttrib0 |= (gl->Vendor() == gl::GLVendor::NVIDIA);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!legacyAttrib0)
|
||||
return WebGLVertexAttrib0Status::Default;
|
||||
|
|
|
|||
|
|
@ -695,18 +695,6 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
|||
gl->fEnable(LOCAL_GL_PROGRAM_POINT_SIZE);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Vendor() == gl::GLVendor::ATI &&
|
||||
!nsCocoaFeatures::IsAtLeastVersion(10,9))
|
||||
{
|
||||
// The Mac ATI driver, in all known OSX version up to and including
|
||||
// 10.8, renders points sprites upside-down. (Apple bug 11778921)
|
||||
gl->fPointParameterf(LOCAL_GL_POINT_SPRITE_COORD_ORIGIN,
|
||||
LOCAL_GL_LOWER_LEFT);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gl->IsSupported(gl::GLFeature::seamless_cube_map_opt_in)) {
|
||||
gl->fEnable(LOCAL_GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -689,24 +689,6 @@ WebGLProgram::GetFragDataLocation(const nsAString& userName_wide) const
|
|||
gl->MakeCurrent();
|
||||
|
||||
const NS_LossyConvertUTF16toASCII userName(userName_wide);
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
// OSX doesn't return locs for indexed names, just the base names.
|
||||
// Indicated by failure in: conformance2/programs/gl-get-frag-data-location.html
|
||||
bool isArray;
|
||||
size_t arrayIndex;
|
||||
nsCString baseUserName;
|
||||
if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex))
|
||||
return -1;
|
||||
|
||||
if (arrayIndex >= mContext->mImplMaxDrawBuffers)
|
||||
return -1;
|
||||
|
||||
const auto baseLoc = GetFragDataByUserName(this, baseUserName);
|
||||
const auto loc = baseLoc + GLint(arrayIndex);
|
||||
return loc;
|
||||
}
|
||||
#endif
|
||||
return GetFragDataByUserName(this, userName);
|
||||
}
|
||||
|
||||
|
|
@ -770,11 +752,6 @@ WebGLProgram::GetProgramParameter(GLenum pname) const
|
|||
return JS::BooleanValue(IsLinked());
|
||||
|
||||
case LOCAL_GL_VALIDATE_STATUS:
|
||||
#ifdef XP_MACOSX
|
||||
// See comment in ValidateProgram.
|
||||
if (gl->WorkAroundDriverBugs())
|
||||
return JS::BooleanValue(true);
|
||||
#endif
|
||||
// Todo: Implement this in our code.
|
||||
return JS::BooleanValue(bool(GetProgramiv(gl, mGLName, pname)));
|
||||
|
||||
|
|
@ -1377,17 +1354,6 @@ WebGLProgram::ValidateProgram() const
|
|||
{
|
||||
mContext->MakeContextCurrent();
|
||||
gl::GLContext* gl = mContext->gl;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// See bug 593867 for NVIDIA and bug 657201 for ATI. The latter is confirmed
|
||||
// with Mac OS 10.6.7.
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
mContext->GenerateWarning("validateProgram: Implemented as a no-op on"
|
||||
" Mac to work around crashes.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
gl->fValidateProgram(mGLName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,34 +63,8 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
|
|||
SH_REGENERATE_STRUCT_NAMES;
|
||||
}
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
// We want to do this everywhere, but to do this on Mac, we need
|
||||
// to do it only on Mac OSX > 10.6 as this causes the shader
|
||||
// compiler in 10.6 to crash
|
||||
// We want to do this everywhere.
|
||||
options |= SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
// Work around https://bugs.webkit.org/show_bug.cgi?id=124684,
|
||||
// https://chromium.googlesource.com/angle/angle/+/5e70cf9d0b1bb
|
||||
options |= SH_UNFOLD_SHORT_CIRCUIT;
|
||||
|
||||
// OS X 10.7/10.8 specific:
|
||||
|
||||
// Work around bug 665578 and bug 769810
|
||||
if (gl->Vendor() == gl::GLVendor::ATI) {
|
||||
options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
|
||||
}
|
||||
// Work around bug 735560
|
||||
if (gl->Vendor() == gl::GLVendor::Intel) {
|
||||
options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
|
||||
}
|
||||
|
||||
// Work around that Mac drivers handle struct scopes incorrectly.
|
||||
options |= SH_REGENERATE_STRUCT_NAMES;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (resources.MaxExpressionComplexity > 0) {
|
||||
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
|
||||
|
|
@ -187,15 +161,6 @@ WebGLContext::CreateShaderValidator(GLenum shaderType) const
|
|||
// If underlying GLES doesn't have highp in frag shaders, it should complain anyways.
|
||||
resources.FragmentPrecisionHigh = mDisableFragHighP ? 0 : 1;
|
||||
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->Vendor() == gl::GLVendor::NVIDIA) {
|
||||
// Work around bug 890432
|
||||
resources.MaxExpressionComplexity = 1000;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int compileOptions = webgl::ChooseValidatorCompileOptions(resources, gl);
|
||||
return webgl::ShaderValidator::Create(shaderType, spec, outputLanguage, resources,
|
||||
compileOptions);
|
||||
|
|
|
|||
|
|
@ -95,10 +95,6 @@
|
|||
#include "Units.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
|
@ -1517,14 +1513,6 @@ EventStateManager::FireContextClick()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Hack to ensure that we don't show a context menu when the user
|
||||
// let go of the mouse after a long cpu-hogging operation prevented
|
||||
// us from handling any OS events. See bug 117589.
|
||||
if (!CGEventSourceButtonState(kCGEventSourceStateCombinedSessionState, kCGMouseButtonLeft))
|
||||
return;
|
||||
#endif
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
// Dispatch to the DOM. We have to fake out the ESM and tell it that the
|
||||
|
|
@ -2841,29 +2829,6 @@ EventStateManager::DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
|
|||
aEvent->mPanDirection = panDirection;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
static bool
|
||||
NodeAllowsClickThrough(nsINode* aNode)
|
||||
{
|
||||
while (aNode) {
|
||||
if (aNode->IsXULElement()) {
|
||||
mozilla::dom::Element* element = aNode->AsElement();
|
||||
static nsIContent::AttrValuesArray strings[] =
|
||||
{&nsGkAtoms::always, &nsGkAtoms::never, nullptr};
|
||||
switch (element->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::clickthrough,
|
||||
strings, eCaseMatters)) {
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
aNode = nsContentUtils::GetCrossDocParentNode(aNode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
EventStateManager::PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent,
|
||||
nsEventStatus& aStatus,
|
||||
|
|
@ -3096,10 +3061,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
// focused frame
|
||||
EnsureDocument(mPresContext);
|
||||
if (mDocument) {
|
||||
#ifdef XP_MACOSX
|
||||
if (!activeContent || !activeContent->IsXULElement())
|
||||
#endif
|
||||
fm->ClearFocus(mDocument->GetWindow());
|
||||
fm->ClearFocus(mDocument->GetWindow());
|
||||
fm->SetFocusedWindow(mDocument->GetWindow());
|
||||
}
|
||||
}
|
||||
|
|
@ -3511,18 +3473,6 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case eMouseActivate:
|
||||
if (mCurrentTarget) {
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
|
||||
if (!NodeAllowsClickThrough(targetContent)) {
|
||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,21 +21,8 @@
|
|||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Some defiens will be conflict with OSX SDK
|
||||
#define TextRange _TextRange
|
||||
#define TextRangeArray _TextRangeArray
|
||||
#define Comment _Comment
|
||||
#endif
|
||||
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#undef TextRange
|
||||
#undef TextRangeArray
|
||||
#undef Comment
|
||||
#endif
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
|||
|
|
@ -156,11 +156,7 @@ HTMLButtonElement::IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t
|
|||
return true;
|
||||
}
|
||||
|
||||
*aIsFocusable =
|
||||
#ifdef XP_MACOSX
|
||||
(!aWithMouse || nsFocusManager::sMouseFocusesFormControl) &&
|
||||
#endif
|
||||
!IsDisabled();
|
||||
*aIsFocusable = !IsDisabled();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -599,9 +599,6 @@ HTMLImageElement::IsHTMLFocusable(bool aWithMouse,
|
|||
}
|
||||
|
||||
*aIsFocusable =
|
||||
#ifdef XP_MACOSX
|
||||
(!aWithMouse || nsFocusManager::sMouseFocusesFormControl) &&
|
||||
#endif
|
||||
(tabIndex >= 0 || HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex));
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -3566,7 +3566,7 @@ HTMLInputElement::Focus(ErrorResult& aError)
|
|||
return;
|
||||
}
|
||||
|
||||
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
||||
#if !defined(ANDROID)
|
||||
bool
|
||||
HTMLInputElement::IsNodeApzAwareInternal() const
|
||||
{
|
||||
|
|
@ -4728,7 +4728,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|||
}
|
||||
break;
|
||||
}
|
||||
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
||||
#if !defined(ANDROID)
|
||||
case eWheel: {
|
||||
// Handle wheel events as increasing / decreasing the input element's
|
||||
// value when it's focused and it's type is number or range.
|
||||
|
|
@ -6665,7 +6665,7 @@ FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget,
|
|||
void
|
||||
HTMLInputElement::UpdateApzAwareFlag()
|
||||
{
|
||||
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
||||
#if !defined(ANDROID)
|
||||
if ((mType == NS_FORM_INPUT_NUMBER) || (mType == NS_FORM_INPUT_RANGE)) {
|
||||
SetMayBeApzAware();
|
||||
}
|
||||
|
|
@ -7239,11 +7239,7 @@ HTMLInputElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t*
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
const bool defaultFocusable = !aWithMouse || nsFocusManager::sMouseFocusesFormControl;
|
||||
#else
|
||||
const bool defaultFocusable = true;
|
||||
#endif
|
||||
|
||||
if (mType == NS_FORM_INPUT_FILE ||
|
||||
mType == NS_FORM_INPUT_NUMBER ||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public:
|
|||
virtual void Focus(ErrorResult& aError) override;
|
||||
|
||||
// nsINode
|
||||
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
||||
#if !defined(ANDROID)
|
||||
virtual bool IsNodeApzAwareInternal() const override;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@
|
|||
#include "nsNPAPIPluginInstance.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsContentUtils.h"
|
||||
#ifdef XP_MACOSX
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "nsFocusManager.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
@ -44,9 +39,6 @@ HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& a
|
|||
|
||||
HTMLObjectElement::~HTMLObjectElement()
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
OnFocusBlurPlugin(this, false);
|
||||
#endif
|
||||
UnregisterActivityObserver();
|
||||
DestroyImageLoadingContent();
|
||||
}
|
||||
|
|
@ -117,131 +109,6 @@ NS_IMPL_ELEMENT_CLONE(HTMLObjectElement)
|
|||
// nsIConstraintValidation
|
||||
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
static nsIWidget* GetWidget(Element* aElement)
|
||||
{
|
||||
return nsContentUtils::WidgetForDocument(aElement->OwnerDoc());
|
||||
}
|
||||
|
||||
Element* HTMLObjectElement::sLastFocused = nullptr; // Weak
|
||||
|
||||
class PluginFocusSetter : public Runnable
|
||||
{
|
||||
public:
|
||||
PluginFocusSetter(nsIWidget* aWidget, Element* aElement)
|
||||
: mWidget(aWidget), mElement(aElement)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (mElement) {
|
||||
HTMLObjectElement::sLastFocused = mElement;
|
||||
bool value = true;
|
||||
mWidget->SetPluginFocused(value);
|
||||
} else if (!HTMLObjectElement::sLastFocused) {
|
||||
bool value = false;
|
||||
mWidget->SetPluginFocused(value);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
nsCOMPtr<Element> mElement;
|
||||
};
|
||||
|
||||
void
|
||||
HTMLObjectElement::OnFocusBlurPlugin(Element* aElement, bool aFocus)
|
||||
{
|
||||
// In general we don't want to call nsIWidget::SetPluginFocused() for any
|
||||
// Element that doesn't have a plugin running. But if SetPluginFocused(true)
|
||||
// was just called for aElement while it had a plugin running, we want to
|
||||
// make sure nsIWidget::SetPluginFocused(false) gets called for it now, even
|
||||
// if aFocus is true.
|
||||
if (aFocus) {
|
||||
nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(aElement);
|
||||
bool hasRunningPlugin = false;
|
||||
if (olc) {
|
||||
// nsIObjectLoadingContent::GetHasRunningPlugin() fails when
|
||||
// nsContentUtils::IsCallerChrome() returns false (which it can do even
|
||||
// when we're processing a trusted focus event). We work around this by
|
||||
// calling nsObjectLoadingContent::HasRunningPlugin() directly.
|
||||
hasRunningPlugin =
|
||||
static_cast<nsObjectLoadingContent*>(olc.get())->HasRunningPlugin();
|
||||
}
|
||||
if (!hasRunningPlugin) {
|
||||
aFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (aFocus || aElement == sLastFocused) {
|
||||
if (!aFocus) {
|
||||
sLastFocused = nullptr;
|
||||
}
|
||||
nsIWidget* widget = GetWidget(aElement);
|
||||
if (widget) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
new PluginFocusSetter(widget, aFocus ? aElement : nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLObjectElement::HandlePluginCrashed(Element* aElement)
|
||||
{
|
||||
OnFocusBlurPlugin(aElement, false);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLObjectElement::HandlePluginInstantiated(Element* aElement)
|
||||
{
|
||||
// If aElement is already focused when a plugin is instantiated, we need
|
||||
// to initiate a call to nsIWidget::SetPluginFocused(true). Otherwise
|
||||
// keyboard input won't work in a click-to-play plugin until aElement
|
||||
// loses focus and regains it.
|
||||
nsIContent* focusedContent = nullptr;
|
||||
nsFocusManager *fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
focusedContent = fm->GetFocusedContent();
|
||||
}
|
||||
if (SameCOMIdentity(focusedContent, aElement)) {
|
||||
OnFocusBlurPlugin(aElement, true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
|
||||
WidgetEvent* aEvent)
|
||||
{
|
||||
if (!aEvent->IsTrusted()) {
|
||||
return;
|
||||
}
|
||||
switch (aEvent->mMessage) {
|
||||
case eFocus: {
|
||||
OnFocusBlurPlugin(aElement, true);
|
||||
break;
|
||||
}
|
||||
case eBlur: {
|
||||
OnFocusBlurPlugin(aElement, false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||
{
|
||||
HandleFocusBlurPlugin(this, aVisitor.mEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // #ifdef XP_MACOSX
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
|
||||
{
|
||||
|
|
@ -282,14 +149,6 @@ void
|
|||
HTMLObjectElement::UnbindFromTree(bool aDeep,
|
||||
bool aNullParent)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
// When a page is reloaded (when an nsIDocument's content is removed), the
|
||||
// focused element isn't necessarily sent an eBlur event. See
|
||||
// nsFocusManager::ContentRemoved(). This means that a widget may think it
|
||||
// still contains a focused plugin when it doesn't -- which in turn can
|
||||
// disable text input in the browser window. See bug 1137229.
|
||||
OnFocusBlurPlugin(this, false);
|
||||
#endif
|
||||
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
||||
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@
|
|||
#include "nsIScriptError.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsContentUtils.h"
|
||||
#ifdef XP_MACOSX
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#endif
|
||||
#include "mozilla/dom/HTMLObjectElement.h"
|
||||
|
||||
|
||||
|
|
@ -42,9 +38,6 @@ HTMLSharedObjectElement::HTMLSharedObjectElement(already_AddRefed<mozilla::dom::
|
|||
|
||||
HTMLSharedObjectElement::~HTMLSharedObjectElement()
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
HTMLObjectElement::OnFocusBlurPlugin(this, false);
|
||||
#endif
|
||||
UnregisterActivityObserver();
|
||||
DestroyImageLoadingContent();
|
||||
}
|
||||
|
|
@ -96,17 +89,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
|||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLSharedObjectElement)
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSharedObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||
{
|
||||
HTMLObjectElement::HandleFocusBlurPlugin(this, aVisitor.mEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // #ifdef XP_MACOSX
|
||||
|
||||
void
|
||||
HTMLSharedObjectElement::AsyncEventRunning(AsyncEventDispatcher* aEvent)
|
||||
{
|
||||
|
|
@ -148,14 +130,6 @@ void
|
|||
HTMLSharedObjectElement::UnbindFromTree(bool aDeep,
|
||||
bool aNullParent)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
// When a page is reloaded (when an nsIDocument's content is removed), the
|
||||
// focused element isn't necessarily sent an eBlur event. See
|
||||
// nsFocusManager::ContentRemoved(). This means that a widget may think it
|
||||
// still contains a focused plugin when it doesn't -- which in turn can
|
||||
// disable text input in the browser window. See bug 1137229.
|
||||
HTMLObjectElement::OnFocusBlurPlugin(this, false);
|
||||
#endif
|
||||
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
||||
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ public:
|
|||
|
||||
virtual int32_t TabIndexDefault() override;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// nsIDOMEventTarget
|
||||
NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
||||
#endif
|
||||
|
||||
// nsIDOMHTMLAppletElement
|
||||
NS_DECL_NSIDOMHTMLAPPLETELEMENT
|
||||
|
||||
|
|
|
|||
|
|
@ -116,15 +116,8 @@ HTMLSummaryElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|||
return disallowOverridingFocusability;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// The parent does not have strong opinion about the focusability of this main
|
||||
// summary element, but we'd like to override it when mouse clicking on Mac OS
|
||||
// like other form elements.
|
||||
*aIsFocusable = !aWithMouse || nsFocusManager::sMouseFocusesFormControl;
|
||||
#else
|
||||
// The main summary element is focusable on other platforms.
|
||||
// The main summary element is focusable on all supported platforms.
|
||||
*aIsFocusable = true;
|
||||
#endif
|
||||
|
||||
// Give a chance to allow the subclass to override aIsFocusable.
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2170,10 +2170,6 @@ nsGenericHTMLFormElement::IsHTMLFocusable(bool aWithMouse,
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
*aIsFocusable =
|
||||
(!aWithMouse || nsFocusManager::sMouseFocusesFormControl) && *aIsFocusable;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@
|
|||
#include "webrtc/MediaEngineWebRTC.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
extern mozilla::LazyLogModule gMediaStreamGraphLog;
|
||||
#define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
|
||||
|
||||
|
|
@ -586,32 +582,6 @@ AudioCallbackDriver::~AudioCallbackDriver()
|
|||
MOZ_ASSERT(mPromisesForOperation.IsEmpty());
|
||||
}
|
||||
|
||||
bool IsMacbookOrMacbookAir()
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
size_t len = 0;
|
||||
sysctlbyname("hw.model", NULL, &len, NULL, 0);
|
||||
if (len) {
|
||||
UniquePtr<char[]> model(new char[len]);
|
||||
// This string can be
|
||||
// MacBook%d,%d for a normal MacBook
|
||||
// MacBookPro%d,%d for a MacBook Pro
|
||||
// MacBookAir%d,%d for a Macbook Air
|
||||
sysctlbyname("hw.model", model.get(), &len, NULL, 0);
|
||||
char* substring = strstr(model.get(), "MacBook");
|
||||
if (substring) {
|
||||
const size_t offset = strlen("MacBook");
|
||||
if (strncmp(model.get() + offset, "Air", len - offset) ||
|
||||
isdigit(model[offset + 1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
AudioCallbackDriver::Init()
|
||||
{
|
||||
|
|
@ -648,13 +618,6 @@ AudioCallbackDriver::Init()
|
|||
}
|
||||
}
|
||||
|
||||
// Macbook and MacBook air don't have enough CPU to run very low latency
|
||||
// MediaStreamGraphs, cap the minimal latency to 512 frames int this case.
|
||||
if (IsMacbookOrMacbookAir()) {
|
||||
latency_frames = std::max((uint32_t) 512, latency_frames);
|
||||
}
|
||||
|
||||
|
||||
input = output;
|
||||
input.channels = mInputChannels; // change to support optional stereo capture
|
||||
|
||||
|
|
@ -1068,44 +1031,6 @@ AudioCallbackDriver::MixerCallback(AudioDataValue* aMixedBuffer,
|
|||
NS_WARNING_ASSERTION(written == aFrames - toWrite, "Dropping frames.");
|
||||
};
|
||||
|
||||
void AudioCallbackDriver::PanOutputIfNeeded(bool aMicrophoneActive)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
cubeb_device* out;
|
||||
int rv;
|
||||
char name[128];
|
||||
size_t length = sizeof(name);
|
||||
|
||||
rv = sysctlbyname("hw.model", name, &length, NULL, 0);
|
||||
if (rv) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncmp(name, "MacBookPro", 10)) {
|
||||
if (cubeb_stream_get_current_device(mAudioStream, &out) == CUBEB_OK) {
|
||||
// Check if we are currently outputing sound on external speakers.
|
||||
if (!strcmp(out->output_name, "ispk")) {
|
||||
// Pan everything to the right speaker.
|
||||
if (aMicrophoneActive) {
|
||||
if (cubeb_stream_set_panning(mAudioStream, 1.0) != CUBEB_OK) {
|
||||
NS_WARNING("Could not pan audio output to the right.");
|
||||
}
|
||||
} else {
|
||||
if (cubeb_stream_set_panning(mAudioStream, 0.0) != CUBEB_OK) {
|
||||
NS_WARNING("Could not pan audio output to the center.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (cubeb_stream_set_panning(mAudioStream, 0.0) != CUBEB_OK) {
|
||||
NS_WARNING("Could not pan audio output to the center.");
|
||||
}
|
||||
}
|
||||
cubeb_stream_device_destroy(mAudioStream, out);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AudioCallbackDriver::DeviceChangedCallback() {
|
||||
// Tell the audio engine the device has changed, it might want to reset some
|
||||
|
|
@ -1114,9 +1039,6 @@ AudioCallbackDriver::DeviceChangedCallback() {
|
|||
if (mAudioInput) {
|
||||
mAudioInput->DeviceChanged();
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
PanOutputIfNeeded(mMicrophoneActive);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1125,10 +1047,6 @@ AudioCallbackDriver::SetMicrophoneActive(bool aActive)
|
|||
MonitorAutoLock mon(mGraphImpl->GetMonitor());
|
||||
|
||||
mMicrophoneActive = aActive;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
PanOutputIfNeeded(mMicrophoneActive);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
|
|||
|
|
@ -456,11 +456,6 @@ public:
|
|||
|
||||
void CompleteAudioContextOperations(AsyncCubebOperation aOperation);
|
||||
private:
|
||||
/**
|
||||
* On certain MacBookPro, the microphone is located near the left speaker.
|
||||
* We need to pan the sound output to the right speaker if we are using the
|
||||
* mic and the built-in speaker, or we will have terrible echo. */
|
||||
void PanOutputIfNeeded(bool aMicrophoneActive);
|
||||
/**
|
||||
* This is called when the output device used by the cubeb stream changes. */
|
||||
void DeviceChangedCallback();
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@
|
|||
#ifdef XP_WIN
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
#include "nsCocoaFeatures.h"
|
||||
#endif
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
|||
|
|
@ -110,14 +110,12 @@ GetPluginFile(const nsAString& aPluginPath,
|
|||
nsAutoString baseName;
|
||||
GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName);
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
|
||||
#elif defined(OS_POSIX)
|
||||
#if defined(OS_POSIX)
|
||||
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so");
|
||||
#elif defined(XP_WIN)
|
||||
nsAutoString binaryName = baseName + NS_LITERAL_STRING(".dll");
|
||||
#else
|
||||
#error not defined
|
||||
#error Unsupported O.S.
|
||||
#endif
|
||||
aLibFile->AppendRelativePath(binaryName);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -32,14 +32,6 @@
|
|||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include <assert.h>
|
||||
#ifdef HASH_NODE_ID_WITH_DEVICE_ID
|
||||
#include <unistd.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_vm.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // HASH_NODE_ID_WITH_DEVICE_ID
|
||||
|
||||
|
|
@ -83,46 +75,6 @@ GetStackAfterCurrentFrame(uint8_t** aOutTop, uint8_t** aOutBottom)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) && defined(HASH_NODE_ID_WITH_DEVICE_ID)
|
||||
static mach_vm_address_t
|
||||
RegionContainingAddress(mach_vm_address_t aAddress)
|
||||
{
|
||||
mach_port_t task;
|
||||
kern_return_t kr = task_for_pid(mach_task_self(), getpid(), &task);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
mach_vm_address_t address = aAddress;
|
||||
mach_vm_size_t size;
|
||||
vm_region_basic_info_data_64_t info;
|
||||
mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
|
||||
mach_port_t object_name;
|
||||
kr = mach_vm_region(task, &address, &size, VM_REGION_BASIC_INFO_64,
|
||||
reinterpret_cast<vm_region_info_t>(&info), &count,
|
||||
&object_name);
|
||||
if (kr != KERN_SUCCESS || size == 0
|
||||
|| address > aAddress || address + size <= aAddress) {
|
||||
// mach_vm_region failed, or couldn't find region at given address.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
MOZ_NEVER_INLINE
|
||||
static bool
|
||||
GetStackAfterCurrentFrame(uint8_t** aOutTop, uint8_t** aOutBottom)
|
||||
{
|
||||
mach_vm_address_t stackFrame =
|
||||
reinterpret_cast<mach_vm_address_t>(__builtin_frame_address(0));
|
||||
*aOutTop = reinterpret_cast<uint8_t*>(stackFrame);
|
||||
// Kernel code shows that stack is always a single region.
|
||||
*aOutBottom = reinterpret_cast<uint8_t*>(RegionContainingAddress(stackFrame));
|
||||
return *aOutBottom && (*aOutBottom < *aOutTop);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HASH_NODE_ID_WITH_DEVICE_ID
|
||||
static void SecureMemset(void* start, uint8_t value, size_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,14 +26,6 @@ public:
|
|||
static FFmpegLibWrapper sLibAV;
|
||||
|
||||
static const char* sLibs[] = {
|
||||
#if defined(XP_DARWIN)
|
||||
"libavcodec.58.dylib",
|
||||
"libavcodec.57.dylib",
|
||||
"libavcodec.56.dylib",
|
||||
"libavcodec.55.dylib",
|
||||
"libavcodec.54.dylib",
|
||||
"libavcodec.53.dylib",
|
||||
#else
|
||||
"libavcodec.so.58",
|
||||
"libavcodec-ffmpeg.so.58",
|
||||
"libavcodec-ffmpeg.so.57",
|
||||
|
|
@ -43,7 +35,6 @@ static const char* sLibs[] = {
|
|||
"libavcodec.so.55",
|
||||
"libavcodec.so.54",
|
||||
"libavcodec.so.53",
|
||||
#endif
|
||||
};
|
||||
|
||||
/* static */ bool
|
||||
|
|
|
|||
|
|
@ -31,12 +31,6 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include <mach/mach_host.h>
|
||||
#include <mach/mach_init.h>
|
||||
#include <mach/host_info.h>
|
||||
#endif
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) \
|
||||
|| defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
|
|
@ -410,27 +404,6 @@ nsresult RTCLoadInfo::UpdateSystemLoad()
|
|||
const uint64_t cpu_times = nice + system + user;
|
||||
const uint64_t total_times = cpu_times + idle;
|
||||
|
||||
UpdateCpuLoad(mTicksPerInterval,
|
||||
total_times,
|
||||
cpu_times,
|
||||
&mSystemLoad);
|
||||
return NS_OK;
|
||||
#elif defined(XP_MACOSX)
|
||||
mach_msg_type_number_t info_cnt = HOST_CPU_LOAD_INFO_COUNT;
|
||||
host_cpu_load_info_data_t load_info;
|
||||
kern_return_t rv = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO,
|
||||
(host_info_t)(&load_info), &info_cnt);
|
||||
|
||||
if (rv != KERN_SUCCESS || info_cnt != HOST_CPU_LOAD_INFO_COUNT) {
|
||||
LOG(("Error from mach/host_statistics call"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const uint64_t cpu_times = load_info.cpu_ticks[CPU_STATE_NICE]
|
||||
+ load_info.cpu_ticks[CPU_STATE_SYSTEM]
|
||||
+ load_info.cpu_ticks[CPU_STATE_USER];
|
||||
const uint64_t total_times = cpu_times + load_info.cpu_ticks[CPU_STATE_IDLE];
|
||||
|
||||
UpdateCpuLoad(mTicksPerInterval,
|
||||
total_times,
|
||||
cpu_times,
|
||||
|
|
|
|||
|
|
@ -873,7 +873,6 @@ AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState)
|
|||
}
|
||||
|
||||
#ifndef WIN32 // Bug 1170547
|
||||
#ifndef XP_MACOSX
|
||||
#ifdef DEBUG
|
||||
|
||||
if (!((mAudioContextState == AudioContextState::Suspended &&
|
||||
|
|
@ -892,7 +891,6 @@ AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState)
|
|||
}
|
||||
|
||||
#endif // DEBUG
|
||||
#endif // XP_MACOSX
|
||||
#endif // WIN32
|
||||
|
||||
MOZ_ASSERT(
|
||||
|
|
|
|||
|
|
@ -339,13 +339,6 @@ MediaEngineCameraVideoSource::SetName(nsString aName)
|
|||
facingMode = VideoFacingModeEnum::User;
|
||||
}
|
||||
#endif // ANDROID
|
||||
#ifdef XP_MACOSX
|
||||
// Kludge to test user-facing cameras on OSX.
|
||||
if (aName.Find(NS_LITERAL_STRING("Face")) != -1) {
|
||||
hasFacingMode = true;
|
||||
facingMode = VideoFacingModeEnum::User;
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
// The cameras' name of Surface book are "Microsoft Camera Front" and
|
||||
// "Microsoft Camera Rear" respectively.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ static int gNotOptimized;
|
|||
using namespace mozilla::layers;
|
||||
|
||||
namespace mozilla {
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
nsresult
|
||||
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
|
||||
NPPluginFuncs* pFuncs, NPError* error)
|
||||
|
|
@ -110,7 +110,7 @@ nsresult
|
|||
PluginPRLibrary::NP_GetValue(void *future, NPPVariable aVariable,
|
||||
void *aValue, NPError* error)
|
||||
{
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
if (mNP_GetValue) {
|
||||
*error = mNP_GetValue(future, aVariable, aValue);
|
||||
} else {
|
||||
|
|
@ -125,7 +125,7 @@ PluginPRLibrary::NP_GetValue(void *future, NPPVariable aVariable,
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
nsresult
|
||||
PluginPRLibrary::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
||||
{
|
||||
|
|
@ -231,17 +231,7 @@ PluginPRLibrary::GetImageContainer(NPP instance, ImageContainer** aContainer)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginPRLibrary::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
|
||||
*aDrawing = false;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
nsresult
|
||||
PluginPRLibrary::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,17 +17,17 @@ class PluginPRLibrary : public PluginLibrary
|
|||
{
|
||||
public:
|
||||
PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) :
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
mNP_Initialize(nullptr),
|
||||
#else
|
||||
mNP_Initialize(nullptr),
|
||||
#endif
|
||||
mNP_Shutdown(nullptr),
|
||||
mNP_GetMIMEDescription(nullptr),
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
mNP_GetValue(nullptr),
|
||||
#endif
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
mNP_GetEntryPoints(nullptr),
|
||||
#endif
|
||||
mNPP_New(nullptr),
|
||||
|
|
@ -60,19 +60,17 @@ public:
|
|||
|
||||
mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc)
|
||||
PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
|
||||
#ifndef XP_MACOSX
|
||||
if (!mNP_GetMIMEDescription)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
mNP_GetValue = (NP_GetValueFunc)
|
||||
PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
|
||||
if (!mNP_GetValue)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
mNP_GetEntryPoints = (NP_GetEntryPointsFunc)
|
||||
PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
|
||||
if (!mNP_GetEntryPoints)
|
||||
|
|
@ -81,7 +79,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs,
|
||||
NPPluginFuncs* aFuncs, NPError* aError) override;
|
||||
#else
|
||||
|
|
@ -95,7 +93,7 @@ public:
|
|||
virtual nsresult NP_GetValue(void* aFuture, NPPVariable aVariable,
|
||||
void* aValue, NPError* aError) override;
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* aFuncs, NPError* aError) override;
|
||||
#endif
|
||||
|
||||
|
|
@ -112,10 +110,7 @@ public:
|
|||
virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
|
||||
virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override;
|
||||
virtual bool IsOOP() override { return false; }
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP aInstance, bool* aDrawing) override;
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult ContentsScaleFactorChanged(NPP aInstance, double aContentsScaleFactor) override;
|
||||
#endif
|
||||
virtual nsresult SetBackgroundUnknown(NPP instance) override;
|
||||
|
|
@ -139,10 +134,10 @@ private:
|
|||
NP_InitializeFunc mNP_Initialize;
|
||||
NP_ShutdownFunc mNP_Shutdown;
|
||||
NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription;
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
NP_GetValueFunc mNP_GetValue;
|
||||
#endif
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
NP_GetEntryPointsFunc mNP_GetEntryPoints;
|
||||
#endif
|
||||
NPP_NewProcPtr mNPP_New;
|
||||
|
|
|
|||
|
|
@ -22,25 +22,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE_CC__) && !defined(XP_UNIX)
|
||||
#ifndef XP_MACOSX
|
||||
#define XP_MACOSX 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) && defined(__LP64__)
|
||||
#define NP_NO_QUICKDRAW
|
||||
#define NP_NO_CARBON
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#ifndef NP_NO_CARBON
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
#include <stdio.h>
|
||||
#if defined(MOZ_X11)
|
||||
|
|
@ -117,12 +98,6 @@ typedef char* NPMIMEType;
|
|||
/* Structures and definitions */
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(__LP64__)
|
||||
#if defined(XP_MACOSX)
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
#endif /* __LP64__ */
|
||||
|
||||
/*
|
||||
* NPP is a plug-in's opaque instance handle
|
||||
*/
|
||||
|
|
@ -280,15 +255,6 @@ typedef struct _NPAudioDeviceChangeDetails
|
|||
|
||||
typedef enum {
|
||||
NPDrawingModelDUMMY
|
||||
#if defined(XP_MACOSX)
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
, NPDrawingModelQuickDraw = 0
|
||||
#endif
|
||||
, NPDrawingModelCoreGraphics = 1
|
||||
, NPDrawingModelOpenGL = 2
|
||||
, NPDrawingModelCoreAnimation = 3
|
||||
, NPDrawingModelInvalidatingCoreAnimation = 4
|
||||
#endif
|
||||
#if defined(XP_WIN)
|
||||
, NPDrawingModelSyncWin = 5
|
||||
#endif
|
||||
|
|
@ -301,15 +267,6 @@ typedef enum {
|
|||
#endif
|
||||
} NPDrawingModel;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
typedef enum {
|
||||
#ifndef NP_NO_CARBON
|
||||
NPEventModelCarbon = 0,
|
||||
#endif
|
||||
NPEventModelCocoa = 1
|
||||
} NPEventModel;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following masks are applied on certain platforms to NPNV and
|
||||
* NPPV selectors that pass around pointers to COM interfaces. Newer
|
||||
|
|
@ -337,12 +294,7 @@ typedef enum {
|
|||
#define _NP_ABI_MIXIN_FOR_GCC3 0
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#define NP_ABI_MACHO_MASK 0x01000000
|
||||
#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
|
||||
#else
|
||||
#define _NP_ABI_MIXIN_FOR_MACHO 0
|
||||
#endif
|
||||
|
||||
#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
|
||||
|
||||
|
|
@ -393,12 +345,6 @@ typedef enum {
|
|||
|
||||
/* Used for negotiating drawing models */
|
||||
NPPVpluginDrawingModel = 1000
|
||||
#if defined(XP_MACOSX)
|
||||
/* Used for negotiating event models */
|
||||
, NPPVpluginEventModel = 1001
|
||||
/* In the NPDrawingModelCoreAnimation drawing model, the browser asks the plug-in for a Core Animation layer. */
|
||||
, NPPVpluginCoreAnimationLayer = 1003
|
||||
#endif
|
||||
/* Notification that the plugin just started or stopped playing audio */
|
||||
, NPPVpluginIsPlayingAudio = 4000
|
||||
#if defined(XP_WIN)
|
||||
|
|
@ -442,39 +388,18 @@ typedef enum {
|
|||
NPNVCSSZoomFactor = 23,
|
||||
|
||||
NPNVpluginDrawingModel = 1000 /* Get the current drawing model (NPDrawingModel) */
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
, NPNVcontentsScaleFactor = 1001
|
||||
#endif
|
||||
#if defined(XP_MACOSX)
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
, NPNVsupportsQuickDrawBool = 2000
|
||||
#endif
|
||||
, NPNVsupportsCoreGraphicsBool = 2001
|
||||
, NPNVsupportsOpenGLBool = 2002
|
||||
, NPNVsupportsCoreAnimationBool = 2003
|
||||
, NPNVsupportsInvalidatingCoreAnimationBool = 2004
|
||||
#endif
|
||||
, NPNVsupportsAsyncBitmapSurfaceBool = 2007
|
||||
#if defined(XP_WIN)
|
||||
, NPNVsupportsAsyncWindowsDXGISurfaceBool = 2008
|
||||
, NPNVpreferredDXGIAdapter = 2009
|
||||
#endif
|
||||
#if defined(XP_MACOSX)
|
||||
#ifndef NP_NO_CARBON
|
||||
, NPNVsupportsCarbonBool = 3000 /* TRUE if the browser supports the Carbon event model */
|
||||
#endif
|
||||
, NPNVsupportsCocoaBool = 3001 /* TRUE if the browser supports the Cocoa event model */
|
||||
, NPNVsupportsUpdatedCocoaTextInputBool = 3002 /* TRUE if the browser supports the updated
|
||||
Cocoa text input specification. */
|
||||
#endif
|
||||
, NPNVmuteAudioBool = 4000 /* Request that the browser wants to mute or unmute the plugin */
|
||||
#if defined(XP_WIN)
|
||||
, NPNVaudioDeviceChangeDetails = 4001 /* Provides information about the new default audio device */
|
||||
#endif
|
||||
#if defined(XP_MACOSX)
|
||||
, NPNVsupportsCompositingCoreAnimationPluginsBool = 74656 /* TRUE if the browser supports
|
||||
CA model compositing */
|
||||
#endif
|
||||
} NPNVariable;
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -509,7 +434,7 @@ typedef struct _NPWindow
|
|||
uint32_t width; /* Maximum window size */
|
||||
uint32_t height;
|
||||
NPRect clipRect; /* Clipping rectangle in port coordinates */
|
||||
#if (defined(XP_UNIX) || defined(XP_SYMBIAN)) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX) || defined(XP_SYMBIAN)
|
||||
void * ws_info; /* Platform-dependent additional data */
|
||||
#endif /* XP_UNIX */
|
||||
NPWindowType type; /* Is this a window or a drawable? */
|
||||
|
|
@ -555,11 +480,7 @@ typedef struct _NPPrint
|
|||
} print;
|
||||
} NPPrint;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#ifndef NP_NO_CARBON
|
||||
typedef EventRecord NPEvent;
|
||||
#endif
|
||||
#elif defined(XP_SYMBIAN)
|
||||
#if defined(XP_SYMBIAN)
|
||||
typedef QEvent NPEvent;
|
||||
#elif defined(XP_WIN)
|
||||
typedef struct _NPEvent
|
||||
|
|
@ -574,13 +495,7 @@ typedef XEvent NPEvent;
|
|||
typedef void* NPEvent;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
typedef void* NPRegion;
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
typedef RgnHandle NPQDRegion;
|
||||
#endif
|
||||
typedef CGPathRef NPCGRegion;
|
||||
#elif defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
typedef HRGN NPRegion;
|
||||
#elif defined(XP_UNIX) && defined(MOZ_X11)
|
||||
typedef Region NPRegion;
|
||||
|
|
@ -594,11 +509,7 @@ typedef struct _NPNSString NPNSString;
|
|||
typedef struct _NPNSWindow NPNSWindow;
|
||||
typedef struct _NPNSMenu NPNSMenu;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
typedef NPNSMenu NPMenu;
|
||||
#else
|
||||
typedef void *NPMenu;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
NPCoordinateSpacePlugin = 1,
|
||||
|
|
@ -608,112 +519,6 @@ typedef enum {
|
|||
NPCoordinateSpaceFlippedScreen
|
||||
} NPCoordinateSpace;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
typedef struct NP_Port
|
||||
{
|
||||
CGrafPtr port;
|
||||
int32_t portx; /* position inside the topmost window */
|
||||
int32_t porty;
|
||||
} NP_Port;
|
||||
#endif /* NP_NO_QUICKDRAW */
|
||||
|
||||
/*
|
||||
* NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
|
||||
* as its drawing model.
|
||||
*/
|
||||
|
||||
typedef struct NP_CGContext
|
||||
{
|
||||
CGContextRef context;
|
||||
void *window; /* A WindowRef under the Carbon event model. */
|
||||
} NP_CGContext;
|
||||
|
||||
/*
|
||||
* NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
|
||||
* drawing model.
|
||||
*/
|
||||
|
||||
typedef struct NP_GLContext
|
||||
{
|
||||
CGLContextObj context;
|
||||
#ifdef NP_NO_CARBON
|
||||
NPNSWindow *window;
|
||||
#else
|
||||
void *window; /* Can be either an NSWindow or a WindowRef depending on the event model */
|
||||
#endif
|
||||
} NP_GLContext;
|
||||
|
||||
typedef enum {
|
||||
NPCocoaEventDrawRect = 1,
|
||||
NPCocoaEventMouseDown,
|
||||
NPCocoaEventMouseUp,
|
||||
NPCocoaEventMouseMoved,
|
||||
NPCocoaEventMouseEntered,
|
||||
NPCocoaEventMouseExited,
|
||||
NPCocoaEventMouseDragged,
|
||||
NPCocoaEventKeyDown,
|
||||
NPCocoaEventKeyUp,
|
||||
NPCocoaEventFlagsChanged,
|
||||
NPCocoaEventFocusChanged,
|
||||
NPCocoaEventWindowFocusChanged,
|
||||
NPCocoaEventScrollWheel,
|
||||
NPCocoaEventTextInput
|
||||
} NPCocoaEventType;
|
||||
|
||||
typedef struct _NPCocoaEvent {
|
||||
NPCocoaEventType type;
|
||||
uint32_t version;
|
||||
union {
|
||||
struct {
|
||||
uint32_t modifierFlags;
|
||||
double pluginX;
|
||||
double pluginY;
|
||||
int32_t buttonNumber;
|
||||
int32_t clickCount;
|
||||
double deltaX;
|
||||
double deltaY;
|
||||
double deltaZ;
|
||||
} mouse;
|
||||
struct {
|
||||
uint32_t modifierFlags;
|
||||
NPNSString *characters;
|
||||
NPNSString *charactersIgnoringModifiers;
|
||||
NPBool isARepeat;
|
||||
uint16_t keyCode;
|
||||
} key;
|
||||
struct {
|
||||
CGContextRef context;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
} draw;
|
||||
struct {
|
||||
NPBool hasFocus;
|
||||
} focus;
|
||||
struct {
|
||||
NPNSString *text;
|
||||
} text;
|
||||
} data;
|
||||
} NPCocoaEvent;
|
||||
|
||||
#ifndef NP_NO_CARBON
|
||||
/* Non-standard event types that can be passed to HandleEvent */
|
||||
enum NPEventType {
|
||||
NPEventType_GetFocusEvent = (osEvt + 16),
|
||||
NPEventType_LoseFocusEvent,
|
||||
NPEventType_AdjustCursorEvent,
|
||||
NPEventType_MenuCommandEvent,
|
||||
NPEventType_ClippingChangedEvent,
|
||||
NPEventType_ScrollingBeginsEvent = 1000,
|
||||
NPEventType_ScrollingEndsEvent
|
||||
};
|
||||
#endif /* NP_NO_CARBON */
|
||||
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
/*
|
||||
* Values for mode passed to NPP_New:
|
||||
*/
|
||||
|
|
@ -736,12 +541,6 @@ enum NPEventType {
|
|||
#define NP_CLEAR_ALL 0
|
||||
#define NP_CLEAR_CACHE (1 << 0)
|
||||
|
||||
#if !defined(__LP64__)
|
||||
#if defined(XP_MACOSX)
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
#endif /* __LP64__ */
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* Error and Reason Code definitions */
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -182,31 +182,6 @@ typedef struct _NPNetscapeFuncs {
|
|||
NPN_SetCurrentAsyncSurfacePtr setcurrentasyncsurface;
|
||||
} NPNetscapeFuncs;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
/*
|
||||
* Mac OS X version(s) of NP_GetMIMEDescription(const char *)
|
||||
* These can be called to retreive MIME information from the plugin dynamically
|
||||
*
|
||||
* Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way
|
||||
* to get mime info from the plugin only on OSX and may not be supported
|
||||
* in furture version -- use NP_GetMIMEDescription instead
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kBPSupportedMIMETypesStructVers_1 = 1
|
||||
};
|
||||
typedef struct _BPSupportedMIMETypes
|
||||
{
|
||||
SInt32 structVersion; /* struct version */
|
||||
Handle typeStrings; /* STR# formated handle, allocated by plug-in */
|
||||
Handle infoStrings; /* STR# formated handle, allocated by plug-in */
|
||||
} BPSupportedMIMETypes;
|
||||
OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags);
|
||||
#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription"
|
||||
typedef const char* (*NP_GetMIMEDescriptionProcPtr)(void);
|
||||
typedef OSErr (*BP_GetSupportedMIMETypesProcPtr)(BPSupportedMIMETypes*, UInt32);
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define OSCALL WINAPI
|
||||
#else
|
||||
|
|
@ -251,15 +226,8 @@ typedef char* (*NP_GetPluginVersionFunc)(void);
|
|||
NP_EXPORT(char*) NP_GetPluginVersion(void);
|
||||
typedef const char* (*NP_GetMIMEDescriptionFunc)(void);
|
||||
NP_EXPORT(const char*) NP_GetMIMEDescription(void);
|
||||
#ifdef XP_MACOSX
|
||||
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*);
|
||||
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs);
|
||||
typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*);
|
||||
NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs);
|
||||
#else
|
||||
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*);
|
||||
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs);
|
||||
#endif
|
||||
typedef NPError (*NP_ShutdownFunc)(void);
|
||||
NP_EXPORT(NPError) NP_Shutdown(void);
|
||||
typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *);
|
||||
|
|
|
|||
|
|
@ -269,14 +269,6 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (!pluginLib->HasRequiredFunctions()) {
|
||||
NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
|
||||
delete pluginLib;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
plugin->mLibrary = pluginLib;
|
||||
pluginLib->SetPlugin(plugin);
|
||||
|
||||
|
|
@ -294,19 +286,6 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
|
|||
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#elif defined(XP_MACOSX)
|
||||
// NP_Initialize must be called before NP_GetEntryPoints on Mac OS X.
|
||||
// We need to match WebKit's behavior.
|
||||
NPError pluginCallError;
|
||||
nsresult rv = pluginLib->NP_Initialize(&sBrowserFuncs, &pluginCallError);
|
||||
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = pluginLib->NP_GetEntryPoints(&plugin->mPluginFuncs, &pluginCallError);
|
||||
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#else
|
||||
NPError pluginCallError;
|
||||
nsresult rv = pluginLib->NP_Initialize(&sBrowserFuncs, &plugin->mPluginFuncs, &pluginCallError);
|
||||
|
|
@ -1729,7 +1708,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
|||
// cases for android_npapi.h's non-standard ANPInterface values.
|
||||
switch (static_cast<int>(variable)) {
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
case NPNVxDisplay : {
|
||||
#if defined(MOZ_X11)
|
||||
if (npp) {
|
||||
|
|
@ -1854,8 +1833,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
|||
}
|
||||
|
||||
case NPNVSupportsWindowless: {
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || \
|
||||
(defined(MOZ_X11) && defined(MOZ_WIDGET_GTK))
|
||||
#if defined(XP_WIN) || (defined(MOZ_X11) && defined(MOZ_WIDGET_GTK))
|
||||
*(NPBool*)result = true;
|
||||
#else
|
||||
*(NPBool*)result = false;
|
||||
|
|
@ -1923,72 +1901,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
|||
return *(char**)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPNVpluginDrawingModel: {
|
||||
if (npp) {
|
||||
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
||||
if (inst) {
|
||||
NPDrawingModel drawingModel;
|
||||
inst->GetDrawingModel((int32_t*)&drawingModel);
|
||||
*(NPDrawingModel*)result = drawingModel;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
case NPNVsupportsQuickDrawBool: {
|
||||
*(NPBool*)result = false;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
case NPNVsupportsCoreGraphicsBool: {
|
||||
*(NPBool*)result = true;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsCoreAnimationBool: {
|
||||
*(NPBool*)result = true;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsInvalidatingCoreAnimationBool: {
|
||||
*(NPBool*)result = true;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsCompositingCoreAnimationPluginsBool: {
|
||||
*(NPBool*)result = PR_TRUE;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifndef NP_NO_CARBON
|
||||
case NPNVsupportsCarbonBool: {
|
||||
*(NPBool*)result = false;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
case NPNVsupportsCocoaBool: {
|
||||
*(NPBool*)result = true;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsUpdatedCocoaTextInputBool: {
|
||||
*(NPBool*)result = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
case NPNVcontentsScaleFactor: {
|
||||
nsNPAPIPluginInstance *inst =
|
||||
(nsNPAPIPluginInstance *) (npp ? npp->ndata : nullptr);
|
||||
|
|
@ -2051,16 +1964,8 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
// actual pointer value is checked rather than its content
|
||||
// when passing booleans
|
||||
case NPPVpluginWindowBool: {
|
||||
#ifdef XP_MACOSX
|
||||
// This setting doesn't apply to OS X (only to Windows and Unix/Linux).
|
||||
// See https://developer.mozilla.org/En/NPN_SetValue#section_5. Return
|
||||
// NPERR_NO_ERROR here to conform to other browsers' behavior on OS X
|
||||
// (e.g. Safari and Opera).
|
||||
return NPERR_NO_ERROR;
|
||||
#else
|
||||
NPBool bWindowless = (result == nullptr);
|
||||
return inst->SetWindowless(bWindowless);
|
||||
#endif
|
||||
}
|
||||
case NPPVpluginTransparentBool: {
|
||||
NPBool bTransparent = (result != nullptr);
|
||||
|
|
@ -2145,18 +2050,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPPVpluginEventModel: {
|
||||
if (inst) {
|
||||
inst->SetEventModel((NPEventModel)NS_PTR_TO_INT32(result));
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
else {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ public:
|
|||
// PluginFuncs() can't fail but results are only valid if GetLibrary() succeeds
|
||||
NPPluginFuncs* PluginFuncs();
|
||||
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
void SetPluginRefNum(short aRefNum);
|
||||
#endif
|
||||
|
||||
// The IPC mechanism notifies the nsNPAPIPlugin if the plugin
|
||||
// crashes and is no longer usable. pluginDumpID/browserDumpID are
|
||||
// the IDs of respective minidumps that were written, or empty if no
|
||||
|
|
|
|||
|
|
@ -60,9 +60,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
|||
, mPlugin(nullptr)
|
||||
, mMIMEType(nullptr)
|
||||
, mOwner(nullptr)
|
||||
#ifdef XP_MACOSX
|
||||
, mCurrentPluginEvent(nullptr)
|
||||
#endif
|
||||
, mHaveJavaC2PJSObjectQuirk(false)
|
||||
, mCachedParamLength(0)
|
||||
, mCachedParamNames(nullptr)
|
||||
|
|
@ -503,9 +500,6 @@ nsresult nsNPAPIPluginInstance::HandleEvent(void* event, int16_t* result,
|
|||
int16_t tmpResult = kNPEventNotHandled;
|
||||
|
||||
if (pluginFunctions->event) {
|
||||
#ifdef XP_MACOSX
|
||||
mCurrentPluginEvent = event;
|
||||
#endif
|
||||
#if defined(XP_WIN)
|
||||
NS_TRY_SAFE_CALL_RETURN(tmpResult, (*pluginFunctions->event)(&mNPP, event), this,
|
||||
aSafeToReenterGecko);
|
||||
|
|
@ -519,9 +513,6 @@ nsresult nsNPAPIPluginInstance::HandleEvent(void* event, int16_t* result,
|
|||
|
||||
if (result)
|
||||
*result = tmpResult;
|
||||
#ifdef XP_MACOSX
|
||||
mCurrentPluginEvent = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
@ -617,19 +608,6 @@ void nsNPAPIPluginInstance::RedrawPlugin()
|
|||
mOwner->RedrawPlugin();
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
|
||||
{
|
||||
// the event model needs to be set for the object frame immediately
|
||||
if (!mOwner) {
|
||||
NS_WARNING("Trying to set event model without a plugin instance owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
mOwner->SetEventModel(aModel);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
||||
{
|
||||
*aModel = (int32_t)mDrawingModel;
|
||||
|
|
@ -638,24 +616,14 @@ nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
|||
|
||||
nsresult nsNPAPIPluginInstance::IsRemoteDrawingCoreAnimation(bool* aDrawing)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PluginLibrary* library = mPlugin->GetLibrary();
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return library->IsRemoteDrawingCoreAnimation(&mNPP, aDrawing);
|
||||
#else
|
||||
/** Mac Stub **/
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNPAPIPluginInstance::ContentsScaleFactorChanged(double aContentsScaleFactor)
|
||||
{
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
@ -732,12 +700,7 @@ nsNPAPIPluginInstance::ShouldCache()
|
|||
nsresult
|
||||
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
// All OS X plugins are windowless.
|
||||
*isWindowless = true;
|
||||
#else
|
||||
*isWindowless = mWindowless;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,6 @@ class nsPluginInstanceOwner;
|
|||
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin;
|
||||
#elif defined(MOZ_X11)
|
||||
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncX;
|
||||
#elif defined(XP_MACOSX)
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelQuickDraw; // Not supported
|
||||
#else
|
||||
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelCoreGraphics;
|
||||
#endif
|
||||
#else
|
||||
const NPDrawingModel kDefaultDrawingModel = static_cast<NPDrawingModel>(0);
|
||||
#endif
|
||||
|
|
@ -146,13 +140,6 @@ public:
|
|||
|
||||
void SetDrawingModel(NPDrawingModel aModel);
|
||||
void RedrawPlugin();
|
||||
#ifdef XP_MACOSX
|
||||
void SetEventModel(NPEventModel aModel);
|
||||
|
||||
void* GetCurrentEvent() {
|
||||
return mCurrentPluginEvent;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
||||
nsNPAPIPluginStreamListener** listener);
|
||||
|
|
@ -291,11 +278,6 @@ private:
|
|||
|
||||
nsTArray<nsNPAPITimer*> mTimers;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// non-null during a HandleEvent call
|
||||
void* mCurrentPluginEvent;
|
||||
#endif
|
||||
|
||||
// Timestamp for the last time this plugin was stopped.
|
||||
// This is only valid when the plugin is actually stopped!
|
||||
mozilla::TimeStamp mStopTime;
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@
|
|||
#include "nsProtocolProxyService.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIFile.h"
|
||||
#if defined(XP_MACOSX)
|
||||
#include "nsILocalFileMac.h"
|
||||
#endif
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFileStreams.h"
|
||||
|
|
@ -1925,19 +1922,7 @@ int64_t GetPluginLastModifiedTime(const nsCOMPtr<nsIFile>& localfile)
|
|||
{
|
||||
PRTime fileModTime = 0;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// On OS X the date of a bundle's "contents" (i.e. of its Info.plist file)
|
||||
// is a much better guide to when it was last modified than the date of
|
||||
// its package directory. See bug 313700.
|
||||
nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface(localfile);
|
||||
if (localFileMac) {
|
||||
localFileMac->GetBundleContentsLastModifiedTime(&fileModTime);
|
||||
} else {
|
||||
localfile->GetLastModifiedTime(&fileModTime);
|
||||
}
|
||||
#else
|
||||
localfile->GetLastModifiedTime(&fileModTime);
|
||||
#endif
|
||||
|
||||
return fileModTime;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,11 +19,6 @@
|
|||
#include "nsWeakReference.h"
|
||||
#include "gfxRect.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "mozilla/gfx/QuartzSupport.h"
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
class nsIInputStream;
|
||||
class nsPluginDOMContextMenuListener;
|
||||
class nsPluginFrame;
|
||||
|
|
@ -104,10 +99,6 @@ public:
|
|||
|
||||
#ifdef XP_WIN
|
||||
void Paint(const RECT& aDirty, HDC aDC);
|
||||
#elif defined(XP_MACOSX)
|
||||
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)
|
||||
void Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
|
|
@ -132,33 +123,11 @@ public:
|
|||
nsresult SetNetscapeWindowAsParent(HWND aWindowToAdopt);
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
enum { ePluginPaintEnable, ePluginPaintDisable };
|
||||
|
||||
void WindowFocusMayHaveChanged();
|
||||
|
||||
bool WindowIsActive();
|
||||
void SendWindowFocusChanged(bool aIsActive);
|
||||
NPDrawingModel GetDrawingModel();
|
||||
bool IsRemoteDrawingCoreAnimation();
|
||||
|
||||
NPEventModel GetEventModel();
|
||||
static void CARefresh(nsITimer *aTimer, void *aClosure);
|
||||
void AddToCARefreshTimer();
|
||||
void RemoveFromCARefreshTimer();
|
||||
// This calls into the plugin (NPP_SetWindow) and can run script.
|
||||
void FixUpPluginWindow(int32_t inPaintState);
|
||||
void HidePluginWindow();
|
||||
// Set plugin port info in the plugin (in the 'window' member of the
|
||||
// NPWindow structure passed to the plugin by SetWindow()).
|
||||
void SetPluginPort();
|
||||
#else // XP_MACOSX
|
||||
void UpdateWindowPositionAndClipRect(bool aSetWindow);
|
||||
void UpdateWindowVisibility(bool aVisible);
|
||||
#endif // XP_MACOSX
|
||||
|
||||
void ResolutionMayHaveChanged();
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
|
||||
#endif
|
||||
|
||||
|
|
@ -214,7 +183,7 @@ public:
|
|||
return mPluginWindow->type == NPWindowTypeDrawable &&
|
||||
(MatchPluginName("Shockwave Flash") ||
|
||||
MatchPluginName("Test Plug-in"));
|
||||
#elif defined(MOZ_X11) || defined(XP_MACOSX)
|
||||
#elif defined(MOZ_X11)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
|
@ -311,15 +280,6 @@ private:
|
|||
nsCOMPtr<nsIWidget> mWidget;
|
||||
RefPtr<nsPluginHost> mPluginHost;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
static nsCOMPtr<nsITimer> *sCATimer;
|
||||
static nsTArray<nsPluginInstanceOwner*> *sCARefreshListeners;
|
||||
bool mSentInitialTopLevelWindowEvent;
|
||||
bool mLastWindowIsActive;
|
||||
bool mLastContentFocused;
|
||||
// True if, the next time the window is activated, we should blur ourselves.
|
||||
bool mShouldBlurOnActivate;
|
||||
#endif
|
||||
double mLastScaleFactor;
|
||||
double mLastCSSZoomFactor;
|
||||
// Initially, the event loop nesting level we were created on, it's updated
|
||||
|
|
@ -335,15 +295,6 @@ private:
|
|||
bool mPluginWindowVisible;
|
||||
bool mPluginDocumentActiveState;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
NPEventModel mEventModel;
|
||||
// This is a hack! UseAsyncRendering() can incorrectly return false
|
||||
// when we don't have an object frame (possible as of bug 90268).
|
||||
// We hack around this by always returning true if we've ever
|
||||
// returned true.
|
||||
bool mUseAsyncRendering;
|
||||
#endif
|
||||
|
||||
// pointer to wrapper for nsIDOMContextMenuListener
|
||||
RefPtr<nsPluginDOMContextMenuListener> mCXMenuListener;
|
||||
|
||||
|
|
@ -357,16 +308,6 @@ private:
|
|||
void CallDefaultProc(const mozilla::WidgetGUIEvent* aEvent);
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
static NPBool ConvertPointPuppet(PuppetWidget *widget, nsPluginFrame* pluginFrame,
|
||||
double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
||||
double *destX, double *destY, NPCoordinateSpace destSpace);
|
||||
static NPBool ConvertPointNoPuppet(nsIWidget *widget, nsPluginFrame* pluginFrame,
|
||||
double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
||||
double *destX, double *destY, NPCoordinateSpace destSpace);
|
||||
void PerformDelayedBlurs();
|
||||
#endif // XP_MACOSX
|
||||
|
||||
int mLastMouseDownButtonType;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ nsPluginNativeWindowPLATFORM::nsPluginNativeWindowPLATFORM() : nsPluginNativeWin
|
|||
width = 0;
|
||||
height = 0;
|
||||
memset(&clipRect, 0, sizeof(clipRect));
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
ws_info = nullptr;
|
||||
#endif
|
||||
type = NPWindowTypeWindow;
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ void nsPluginTag::InitMime(const char* const* aMimeTypes,
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(XP_WIN) && !defined(XP_MACOSX)
|
||||
#if !defined(XP_WIN)
|
||||
static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
|
||||
nsAFlatCString& aString)
|
||||
{
|
||||
|
|
@ -448,7 +448,7 @@ static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
|
|||
|
||||
nsresult nsPluginTag::EnsureMembersAreUTF8()
|
||||
{
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
return NS_OK;
|
||||
#else
|
||||
nsresult rv;
|
||||
|
|
|
|||
|
|
@ -1,193 +0,0 @@
|
|||
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
|
||||
/* 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_dom_plugins_NPEventOSX_h
|
||||
#define mozilla_dom_plugins_NPEventOSX_h 1
|
||||
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace plugins {
|
||||
|
||||
struct NPRemoteEvent {
|
||||
NPCocoaEvent event;
|
||||
double contentsScaleFactor;
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::plugins::NPRemoteEvent>
|
||||
{
|
||||
typedef mozilla::plugins::NPRemoteEvent paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
aMsg->WriteInt(aParam.event.type);
|
||||
aMsg->WriteUInt32(aParam.event.version);
|
||||
switch (aParam.event.type) {
|
||||
case NPCocoaEventMouseDown:
|
||||
case NPCocoaEventMouseUp:
|
||||
case NPCocoaEventMouseMoved:
|
||||
case NPCocoaEventMouseEntered:
|
||||
case NPCocoaEventMouseExited:
|
||||
case NPCocoaEventMouseDragged:
|
||||
case NPCocoaEventScrollWheel:
|
||||
aMsg->WriteUInt32(aParam.event.data.mouse.modifierFlags);
|
||||
aMsg->WriteDouble(aParam.event.data.mouse.pluginX);
|
||||
aMsg->WriteDouble(aParam.event.data.mouse.pluginY);
|
||||
aMsg->WriteInt32(aParam.event.data.mouse.buttonNumber);
|
||||
aMsg->WriteInt32(aParam.event.data.mouse.clickCount);
|
||||
aMsg->WriteDouble(aParam.event.data.mouse.deltaX);
|
||||
aMsg->WriteDouble(aParam.event.data.mouse.deltaY);
|
||||
aMsg->WriteDouble(aParam.event.data.mouse.deltaZ);
|
||||
break;
|
||||
case NPCocoaEventKeyDown:
|
||||
case NPCocoaEventKeyUp:
|
||||
case NPCocoaEventFlagsChanged:
|
||||
aMsg->WriteUInt32(aParam.event.data.key.modifierFlags);
|
||||
WriteParam(aMsg, aParam.event.data.key.characters);
|
||||
WriteParam(aMsg, aParam.event.data.key.charactersIgnoringModifiers);
|
||||
aMsg->WriteUnsignedChar(aParam.event.data.key.isARepeat);
|
||||
aMsg->WriteUInt16(aParam.event.data.key.keyCode);
|
||||
break;
|
||||
case NPCocoaEventFocusChanged:
|
||||
case NPCocoaEventWindowFocusChanged:
|
||||
aMsg->WriteUnsignedChar(aParam.event.data.focus.hasFocus);
|
||||
break;
|
||||
case NPCocoaEventDrawRect:
|
||||
// We don't write out the context pointer, it would always be
|
||||
// nullptr and is just filled in as such on the read.
|
||||
aMsg->WriteDouble(aParam.event.data.draw.x);
|
||||
aMsg->WriteDouble(aParam.event.data.draw.y);
|
||||
aMsg->WriteDouble(aParam.event.data.draw.width);
|
||||
aMsg->WriteDouble(aParam.event.data.draw.height);
|
||||
break;
|
||||
case NPCocoaEventTextInput:
|
||||
WriteParam(aMsg, aParam.event.data.text.text);
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("Attempted to serialize unknown event type.");
|
||||
return;
|
||||
}
|
||||
aMsg->WriteDouble(aParam.contentsScaleFactor);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
int type = 0;
|
||||
if (!aMsg->ReadInt(aIter, &type)) {
|
||||
return false;
|
||||
}
|
||||
aResult->event.type = static_cast<NPCocoaEventType>(type);
|
||||
|
||||
if (!aMsg->ReadUInt32(aIter, &aResult->event.version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (aResult->event.type) {
|
||||
case NPCocoaEventMouseDown:
|
||||
case NPCocoaEventMouseUp:
|
||||
case NPCocoaEventMouseMoved:
|
||||
case NPCocoaEventMouseEntered:
|
||||
case NPCocoaEventMouseExited:
|
||||
case NPCocoaEventMouseDragged:
|
||||
case NPCocoaEventScrollWheel:
|
||||
if (!aMsg->ReadUInt32(aIter, &aResult->event.data.mouse.modifierFlags)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.mouse.pluginX)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.mouse.pluginY)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadInt32(aIter, &aResult->event.data.mouse.buttonNumber)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadInt32(aIter, &aResult->event.data.mouse.clickCount)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.mouse.deltaX)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.mouse.deltaY)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.mouse.deltaZ)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NPCocoaEventKeyDown:
|
||||
case NPCocoaEventKeyUp:
|
||||
case NPCocoaEventFlagsChanged:
|
||||
if (!aMsg->ReadUInt32(aIter, &aResult->event.data.key.modifierFlags)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadParam(aMsg, aIter, &aResult->event.data.key.characters)) {
|
||||
return false;
|
||||
}
|
||||
if (!ReadParam(aMsg, aIter, &aResult->event.data.key.charactersIgnoringModifiers)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadUnsignedChar(aIter, &aResult->event.data.key.isARepeat)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadUInt16(aIter, &aResult->event.data.key.keyCode)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NPCocoaEventFocusChanged:
|
||||
case NPCocoaEventWindowFocusChanged:
|
||||
if (!aMsg->ReadUnsignedChar(aIter, &aResult->event.data.focus.hasFocus)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NPCocoaEventDrawRect:
|
||||
aResult->event.data.draw.context = nullptr;
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.draw.x)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.draw.y)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.draw.width)) {
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->event.data.draw.height)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NPCocoaEventTextInput:
|
||||
if (!ReadParam(aMsg, aIter, &aResult->event.data.text.text)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("Attempted to de-serialize unknown event type.");
|
||||
return false;
|
||||
}
|
||||
if (!aMsg->ReadDouble(aIter, &aResult->contentsScaleFactor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Log(const paramType& aParam, std::wstring* aLog)
|
||||
{
|
||||
aLog->append(L"(NPCocoaEvent)");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // ifndef mozilla_dom_plugins_NPEventOSX_h
|
||||
|
|
@ -103,11 +103,7 @@ using mozilla::gfx::SharedDIB;
|
|||
const int kFlashWMUSERMessageThrottleDelayMs = 5;
|
||||
|
||||
static const TCHAR kPluginIgnoreSubclassProperty[] = TEXT("PluginIgnoreSubclassProperty");
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include "PluginUtilsOSX.h"
|
||||
#endif // defined(XP_MACOSX)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* We can't use gfxPlatform::CreateDrawTargetForSurface() because calling
|
||||
|
|
@ -141,7 +137,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
|
|||
, mMode(aMode)
|
||||
, mNames(aNames)
|
||||
, mValues(aValues)
|
||||
#if defined(XP_DARWIN) || defined (XP_WIN)
|
||||
#if defined (XP_WIN)
|
||||
, mContentsScaleFactor(1.0)
|
||||
#endif
|
||||
, mPostingKeyEvents(0)
|
||||
|
|
@ -198,7 +194,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
|
|||
mWindow.type = NPWindowTypeWindow;
|
||||
mData.ndata = (void*) this;
|
||||
mData.pdata = nullptr;
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
mWindow.ws_info = &mWsInfo;
|
||||
memset(&mWsInfo, 0, sizeof(mWsInfo));
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
|
|
@ -207,7 +203,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
|
|||
#else
|
||||
mWsInfo.display = DefaultXDisplay();
|
||||
#endif
|
||||
#endif // MOZ_X11 && XP_UNIX && !XP_MACOSX
|
||||
#endif // MOZ_X11 && XP_UNIX
|
||||
#if defined(OS_WIN)
|
||||
InitPopupMenuHook();
|
||||
if (GetQuirks() & QUIRK_UNITY_FIXUP_MOUSE_CAPTURE) {
|
||||
|
|
@ -274,23 +270,6 @@ PluginInstanceChild::DoNPP_New()
|
|||
|
||||
Initialize();
|
||||
|
||||
#if defined(XP_MACOSX) && defined(__i386__)
|
||||
// If an i386 Mac OS X plugin has selected the Carbon event model then
|
||||
// we have to fail. We do not support putting Carbon event model plugins
|
||||
// out of process. Note that Carbon is the default model so out of process
|
||||
// plugins need to actively negotiate something else in order to work
|
||||
// out of process.
|
||||
if (EventModel() == NPEventModelCarbon) {
|
||||
// Send notification that a plugin tried to negotiate Carbon NPAPI so that
|
||||
// users can be notified that restarting the browser in i386 mode may allow
|
||||
// them to use the plugin.
|
||||
SendNegotiatedCarbon();
|
||||
|
||||
// Fail to instantiate.
|
||||
rv = NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
@ -498,58 +477,12 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPNVsupportsCoreGraphicsBool: {
|
||||
*((NPBool*)aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsCoreAnimationBool: {
|
||||
*((NPBool*)aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsInvalidatingCoreAnimationBool: {
|
||||
*((NPBool*)aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsCompositingCoreAnimationPluginsBool: {
|
||||
*((NPBool*)aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
case NPNVsupportsCocoaBool: {
|
||||
*((NPBool*)aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifndef NP_NO_CARBON
|
||||
case NPNVsupportsCarbonBool: {
|
||||
*((NPBool*)aValue) = false;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
case NPNVsupportsUpdatedCocoaTextInputBool: {
|
||||
*static_cast<NPBool*>(aValue) = true;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
case NPNVsupportsQuickDrawBool: {
|
||||
*((NPBool*)aValue) = false;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif /* NP_NO_QUICKDRAW */
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
case NPNVcontentsScaleFactor: {
|
||||
*static_cast<double*>(aValue) = mContentsScaleFactor;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
#endif /* defined(XP_MACOSX) || defined(XP_WIN) */
|
||||
#endif /* defined(XP_WIN) */
|
||||
|
||||
case NPNVCSSZoomFactor: {
|
||||
*static_cast<double*>(aValue) = mCSSZoomFactor;
|
||||
|
|
@ -654,36 +587,12 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
|
|||
|
||||
mDrawingModel = drawingModel;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (drawingModel == NPDrawingModelCoreAnimation) {
|
||||
mCARefreshTimer = ScheduleTimer(DEFAULT_REFRESH_MS, true, CAUpdate);
|
||||
}
|
||||
#endif
|
||||
|
||||
PLUGIN_LOG_DEBUG((" Plugin requested drawing model id #%i\n",
|
||||
mDrawingModel));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPPVpluginEventModel: {
|
||||
NPError rv;
|
||||
int eventModel = (int16_t) (intptr_t) aValue;
|
||||
|
||||
if (!CallNPN_SetValue_NPPVpluginEventModel(eventModel, &rv))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
#if defined(__i386__)
|
||||
mEventModel = static_cast<NPEventModel>(eventModel);
|
||||
#endif
|
||||
|
||||
PLUGIN_LOG_DEBUG((" Plugin requested event model id # %i\n",
|
||||
eventModel));
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
case NPPVpluginIsPlayingAudio: {
|
||||
NPError rv = NPERR_GENERIC_ERROR;
|
||||
if (!CallNPN_SetValue_NPPVpluginIsPlayingAudio((NPBool)(intptr_t)aValue, &rv)) {
|
||||
|
|
@ -907,21 +816,10 @@ PluginInstanceChild::AnswerNPP_HandleEvent(const NPRemoteEvent& event,
|
|||
event.event.xgraphicsexpose.drawable));
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Mac OS X does not define an NPEvent structure. It defines more specific types.
|
||||
NPCocoaEvent evcopy = event.event;
|
||||
|
||||
// Make sure we reset mCurrentEvent in case of an exception
|
||||
AutoRestore<const NPCocoaEvent*> savePreviousEvent(mCurrentEvent);
|
||||
|
||||
// Track the current event for NPN_PopUpContextMenu.
|
||||
mCurrentEvent = &event.event;
|
||||
#else
|
||||
// Make a copy since we may modify values.
|
||||
NPEvent evcopy = event.event;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
// event.contentsScaleFactor <= 0 is a signal we shouldn't use it,
|
||||
// for example when AnswerNPP_HandleEvent() is called from elsewhere
|
||||
// in the child process (not via rpc code from the parent process).
|
||||
|
|
@ -947,18 +845,6 @@ PluginInstanceChild::AnswerNPP_HandleEvent(const NPRemoteEvent& event,
|
|||
else
|
||||
*handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&evcopy));
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Release any reference counted objects created in the child process.
|
||||
if (evcopy.type == NPCocoaEventKeyDown ||
|
||||
evcopy.type == NPCocoaEventKeyUp) {
|
||||
::CFRelease((CFStringRef)evcopy.data.key.characters);
|
||||
::CFRelease((CFStringRef)evcopy.data.key.charactersIgnoringModifiers);
|
||||
}
|
||||
else if (evcopy.type == NPCocoaEventTextInput) {
|
||||
::CFRelease((CFStringRef)evcopy.data.text.text);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
if (GraphicsExpose == event.event.type) {
|
||||
// Make sure the X server completes the drawing before the parent
|
||||
|
|
@ -975,73 +861,6 @@ PluginInstanceChild::AnswerNPP_HandleEvent(const NPRemoteEvent& event,
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
bool
|
||||
PluginInstanceChild::AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
|
||||
Shmem&& mem,
|
||||
int16_t* handled,
|
||||
Shmem* rtnmem)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
AutoStackHelper guard(this);
|
||||
|
||||
PaintTracker pt;
|
||||
|
||||
NPCocoaEvent evcopy = event.event;
|
||||
mContentsScaleFactor = event.contentsScaleFactor;
|
||||
|
||||
if (evcopy.type == NPCocoaEventDrawRect) {
|
||||
int scaleFactor = ceil(mContentsScaleFactor);
|
||||
if (!mShColorSpace) {
|
||||
mShColorSpace = CreateSystemColorSpace();
|
||||
if (!mShColorSpace) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate ColorSpace."));
|
||||
*handled = false;
|
||||
*rtnmem = mem;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!mShContext) {
|
||||
void* cgContextByte = mem.get<char>();
|
||||
mShContext = ::CGBitmapContextCreate(cgContextByte,
|
||||
mWindow.width * scaleFactor,
|
||||
mWindow.height * scaleFactor, 8,
|
||||
mWindow.width * 4 * scaleFactor, mShColorSpace,
|
||||
kCGImageAlphaPremultipliedFirst |
|
||||
kCGBitmapByteOrder32Host);
|
||||
|
||||
if (!mShContext) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate CGBitmapContext."));
|
||||
*handled = false;
|
||||
*rtnmem = mem;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
CGRect clearRect = ::CGRectMake(0, 0, mWindow.width, mWindow.height);
|
||||
::CGContextClearRect(mShContext, clearRect);
|
||||
evcopy.data.draw.context = mShContext;
|
||||
} else {
|
||||
PLUGIN_LOG_DEBUG(("Invalid event type for AnswerNNP_HandleEvent_Shmem."));
|
||||
*handled = false;
|
||||
*rtnmem = mem;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mPluginIface->event) {
|
||||
*handled = false;
|
||||
} else {
|
||||
::CGContextSaveGState(evcopy.data.draw.context);
|
||||
*handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&evcopy));
|
||||
::CGContextRestoreGState(evcopy.data.draw.context);
|
||||
}
|
||||
|
||||
*rtnmem = mem;
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
bool
|
||||
PluginInstanceChild::AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
|
||||
Shmem&& mem,
|
||||
|
|
@ -1052,101 +871,7 @@ PluginInstanceChild::AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
|
|||
*rtnmem = mem;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
void CallCGDraw(CGContextRef ref, void* aPluginInstance, nsIntRect aUpdateRect) {
|
||||
PluginInstanceChild* pluginInstance = (PluginInstanceChild*)aPluginInstance;
|
||||
|
||||
pluginInstance->CGDraw(ref, aUpdateRect);
|
||||
}
|
||||
|
||||
bool
|
||||
PluginInstanceChild::CGDraw(CGContextRef ref, nsIntRect aUpdateRect) {
|
||||
|
||||
NPCocoaEvent drawEvent;
|
||||
drawEvent.type = NPCocoaEventDrawRect;
|
||||
drawEvent.version = 0;
|
||||
drawEvent.data.draw.x = aUpdateRect.x;
|
||||
drawEvent.data.draw.y = aUpdateRect.y;
|
||||
drawEvent.data.draw.width = aUpdateRect.width;
|
||||
drawEvent.data.draw.height = aUpdateRect.height;
|
||||
drawEvent.data.draw.context = ref;
|
||||
|
||||
NPRemoteEvent remoteDrawEvent = {drawEvent};
|
||||
// Signal to AnswerNPP_HandleEvent() not to use this value
|
||||
remoteDrawEvent.contentsScaleFactor = -1.0;
|
||||
|
||||
int16_t handled;
|
||||
AnswerNPP_HandleEvent(remoteDrawEvent, &handled);
|
||||
return handled == true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
||||
const uint32_t &surfaceid,
|
||||
int16_t* handled)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
AutoStackHelper guard(this);
|
||||
|
||||
PaintTracker pt;
|
||||
|
||||
NPCocoaEvent evcopy = event.event;
|
||||
mContentsScaleFactor = event.contentsScaleFactor;
|
||||
RefPtr<MacIOSurface> surf = MacIOSurface::LookupSurface(surfaceid,
|
||||
mContentsScaleFactor);
|
||||
if (!surf) {
|
||||
NS_ERROR("Invalid IOSurface.");
|
||||
*handled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mCARenderer) {
|
||||
mCARenderer = new nsCARenderer();
|
||||
}
|
||||
|
||||
if (evcopy.type == NPCocoaEventDrawRect) {
|
||||
mCARenderer->AttachIOSurface(surf);
|
||||
if (!mCARenderer->isInit()) {
|
||||
void *caLayer = nullptr;
|
||||
NPError result = mPluginIface->getvalue(GetNPP(),
|
||||
NPPVpluginCoreAnimationLayer,
|
||||
&caLayer);
|
||||
|
||||
if (result != NPERR_NO_ERROR || !caLayer) {
|
||||
PLUGIN_LOG_DEBUG(("Plugin requested CoreAnimation but did not "
|
||||
"provide CALayer."));
|
||||
*handled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
mCARenderer->SetupRenderer(caLayer, mWindow.width, mWindow.height,
|
||||
mContentsScaleFactor,
|
||||
GetQuirks() & QUIRK_ALLOW_OFFLINE_RENDERER ?
|
||||
ALLOW_OFFLINE_RENDERER : DISALLOW_OFFLINE_RENDERER);
|
||||
|
||||
// Flash needs to have the window set again after this step
|
||||
if (mPluginIface->setwindow)
|
||||
(void) mPluginIface->setwindow(&mData, &mWindow);
|
||||
}
|
||||
} else {
|
||||
PLUGIN_LOG_DEBUG(("Invalid event type for "
|
||||
"AnswerNNP_HandleEvent_IOSurface."));
|
||||
*handled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
mCARenderer->Render(mWindow.width, mWindow.height,
|
||||
mContentsScaleFactor, nullptr);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
bool
|
||||
PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
||||
const uint32_t &surfaceid,
|
||||
|
|
@ -1155,7 +880,6 @@ PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
|||
NS_RUNTIMEABORT("NPP_HandleEvent_IOSurface is a OSX-only message");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
PluginInstanceChild::RecvWindowPosChanged(const NPRemoteEvent& event)
|
||||
|
|
@ -1175,24 +899,16 @@ PluginInstanceChild::RecvWindowPosChanged(const NPRemoteEvent& event)
|
|||
bool
|
||||
PluginInstanceChild::RecvContentsScaleFactorChanged(const double& aContentsScaleFactor)
|
||||
{
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
mContentsScaleFactor = aContentsScaleFactor;
|
||||
#if defined(XP_MACOSX)
|
||||
if (mShContext) {
|
||||
// Release the shared context so that it is reallocated
|
||||
// with the new size.
|
||||
::CGContextRelease(mShContext);
|
||||
mShContext = nullptr;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
#else
|
||||
NS_RUNTIMEABORT("ContentsScaleFactorChanged is an Windows or OSX only message");
|
||||
NS_RUNTIMEABORT("ContentsScaleFactorChanged is a Windows-only message");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
// Create a new window from NPWindow
|
||||
bool PluginInstanceChild::CreateWindow(const NPRemoteWindow& aWindow)
|
||||
{
|
||||
|
|
@ -1290,7 +1006,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
|
|||
AssertPluginThread();
|
||||
AutoStackHelper guard(this);
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
NS_ASSERTION(mWsInfo.display, "We should have a valid display!");
|
||||
|
||||
// The minimum info is sent over IPC to allow this
|
||||
|
|
@ -1407,26 +1123,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
|
|||
break;
|
||||
}
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
|
||||
mWindow.x = aWindow.x;
|
||||
mWindow.y = aWindow.y;
|
||||
mWindow.width = aWindow.width;
|
||||
mWindow.height = aWindow.height;
|
||||
mWindow.clipRect = aWindow.clipRect;
|
||||
mWindow.type = aWindow.type;
|
||||
mContentsScaleFactor = aWindow.contentsScaleFactor;
|
||||
|
||||
if (mShContext) {
|
||||
// Release the shared context so that it is reallocated
|
||||
// with the new size.
|
||||
::CGContextRelease(mShContext);
|
||||
mShContext = nullptr;
|
||||
}
|
||||
|
||||
if (mPluginIface->setwindow)
|
||||
(void) mPluginIface->setwindow(&mData, &mWindow);
|
||||
|
||||
#elif defined(MOZ_WIDGET_UIKIT)
|
||||
// Don't care
|
||||
#else
|
||||
|
|
@ -3372,7 +3068,7 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
|
|||
mWindow.height = aWindow.height;
|
||||
mWindow.clipRect = aWindow.clipRect;
|
||||
mWindow.type = aWindow.type;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
mContentsScaleFactor = aWindow.contentsScaleFactor;
|
||||
#endif
|
||||
|
||||
|
|
@ -3520,7 +3216,6 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
|
|||
bool
|
||||
PluginInstanceChild::EnsureCurrentBuffer(void)
|
||||
{
|
||||
#ifndef XP_DARWIN
|
||||
nsIntRect toInvalidate(0, 0, 0, 0);
|
||||
IntSize winSize = IntSize(mWindow.width, mWindow.height);
|
||||
|
||||
|
|
@ -3564,61 +3259,6 @@ PluginInstanceChild::EnsureCurrentBuffer(void)
|
|||
NS_ERROR("Cannot create helper surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#elif defined(XP_MACOSX)
|
||||
|
||||
if (!mDoubleBufferCARenderer.HasCALayer()) {
|
||||
void *caLayer = nullptr;
|
||||
if (mDrawingModel == NPDrawingModelCoreGraphics) {
|
||||
if (!mCGLayer) {
|
||||
caLayer = mozilla::plugins::PluginUtilsOSX::GetCGLayer(CallCGDraw,
|
||||
this,
|
||||
mContentsScaleFactor);
|
||||
|
||||
if (!caLayer) {
|
||||
PLUGIN_LOG_DEBUG(("GetCGLayer failed."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mCGLayer = caLayer;
|
||||
} else {
|
||||
NPError result = mPluginIface->getvalue(GetNPP(),
|
||||
NPPVpluginCoreAnimationLayer,
|
||||
&caLayer);
|
||||
if (result != NPERR_NO_ERROR || !caLayer) {
|
||||
PLUGIN_LOG_DEBUG(("Plugin requested CoreAnimation but did not "
|
||||
"provide CALayer."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mDoubleBufferCARenderer.SetCALayer(caLayer);
|
||||
}
|
||||
|
||||
if (mDoubleBufferCARenderer.HasFrontSurface() &&
|
||||
(mDoubleBufferCARenderer.GetFrontSurfaceWidth() != mWindow.width ||
|
||||
mDoubleBufferCARenderer.GetFrontSurfaceHeight() != mWindow.height ||
|
||||
mDoubleBufferCARenderer.GetContentsScaleFactor() != mContentsScaleFactor)) {
|
||||
mDoubleBufferCARenderer.ClearFrontSurface();
|
||||
}
|
||||
|
||||
if (!mDoubleBufferCARenderer.HasFrontSurface()) {
|
||||
bool allocSurface = mDoubleBufferCARenderer.InitFrontSurface(
|
||||
mWindow.width, mWindow.height, mContentsScaleFactor,
|
||||
GetQuirks() & QUIRK_ALLOW_OFFLINE_RENDERER ?
|
||||
ALLOW_OFFLINE_RENDERER : DISALLOW_OFFLINE_RENDERER);
|
||||
if (!allocSurface) {
|
||||
PLUGIN_LOG_DEBUG(("Fail to allocate front IOSurface"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPluginIface->setwindow)
|
||||
(void) mPluginIface->setwindow(&mData, &mWindow);
|
||||
|
||||
nsIntRect toInvalidate(0, 0, mWindow.width, mWindow.height);
|
||||
mAccumulatedInvalidRect.UnionRect(mAccumulatedInvalidRect, toInvalidate);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -3662,8 +3302,6 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
// Adjusting the window isn't needed for OSX
|
||||
#ifndef XP_WIN
|
||||
// On Windows, we translate the device context, in order for the window
|
||||
// origin to be correct.
|
||||
|
|
@ -3684,7 +3322,6 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
|
|||
mWindow.clipRect.right = clipRect.XMost();
|
||||
mWindow.clipRect.bottom = clipRect.YMost();
|
||||
}
|
||||
#endif // XP_MACOSX
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Windowless plugins on Windows need a WM_WINDOWPOSCHANGED event to update
|
||||
|
|
@ -4655,7 +4292,7 @@ PluginInstanceChild::Destroy()
|
|||
xt_client_xloop_destroy();
|
||||
}
|
||||
#endif
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
DeleteWindow();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ protected:
|
|||
virtual bool
|
||||
RecvNPP_DidComposite() override;
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
bool CreateWindow(const NPRemoteWindow& aWindow);
|
||||
void DeleteWindow();
|
||||
#endif
|
||||
|
|
@ -414,7 +414,7 @@ private:
|
|||
InfallibleTArray<nsCString> mValues;
|
||||
NPP_t mData;
|
||||
NPWindow mWindow;
|
||||
#if defined(XP_DARWIN) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double mContentsScaleFactor;
|
||||
#endif
|
||||
double mCSSZoomFactor;
|
||||
|
|
@ -456,7 +456,7 @@ private:
|
|||
PluginScriptableObjectChild* mCachedWindowActor;
|
||||
PluginScriptableObjectChild* mCachedElementActor;
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
NPSetWindowCallbackStruct mWsInfo;
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
bool mXEmbed;
|
||||
|
|
@ -520,15 +520,10 @@ private:
|
|||
bool CanPaintOnBackground();
|
||||
|
||||
bool IsVisible() {
|
||||
#ifdef XP_MACOSX
|
||||
return mWindow.clipRect.top != mWindow.clipRect.bottom &&
|
||||
mWindow.clipRect.left != mWindow.clipRect.right;
|
||||
#else
|
||||
return mWindow.clipRect.top != 0 ||
|
||||
mWindow.clipRect.left != 0 ||
|
||||
mWindow.clipRect.bottom != 0 ||
|
||||
mWindow.clipRect.right != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ShowPluginFrame - in general does four things:
|
||||
|
|
@ -609,12 +604,6 @@ private:
|
|||
// surface which is on ParentProcess side
|
||||
RefPtr<gfxASurface> mBackSurface;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Current IOSurface available for rendering
|
||||
// We can't use thebes gfxASurface like other platforms.
|
||||
PluginUtilsOSX::nsDoubleBufferCARenderer mDoubleBufferCARenderer;
|
||||
#endif
|
||||
|
||||
// (Not to be confused with mBackSurface). This is a recent copy
|
||||
// of the opaque pixels under our object frame, if
|
||||
// |mIsTransparent|. We ask the plugin render directly onto a
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@
|
|||
# include "mozilla/layers/TextureD3D11.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "MacIOSurfaceImage.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windowsx.h>
|
||||
#include "gfxWindowsPlatform.h"
|
||||
|
|
@ -67,9 +63,7 @@ extern const wchar_t* kFlashFullscreenClass;
|
|||
#elif defined(MOZ_WIDGET_GTK)
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include <gdk/gdk.h>
|
||||
#elif defined(XP_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif // defined(XP_MACOSX)
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins;
|
||||
|
|
@ -134,11 +128,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
|||
, mPluginWndProc(nullptr)
|
||||
, mNestedEventState(false)
|
||||
#endif // defined(XP_WIN)
|
||||
#if defined(XP_MACOSX)
|
||||
, mShWidth(0)
|
||||
, mShHeight(0)
|
||||
, mShColorSpace(nullptr)
|
||||
#endif
|
||||
{
|
||||
#if defined(OS_WIN)
|
||||
if (!sPluginInstanceList) {
|
||||
|
|
@ -267,8 +256,6 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle*
|
|||
HWND id;
|
||||
#elif defined(MOZ_X11)
|
||||
XID id;
|
||||
#elif defined(XP_DARWIN)
|
||||
intptr_t id;
|
||||
#else
|
||||
#warning Implement me
|
||||
#endif
|
||||
|
|
@ -458,14 +445,7 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
|
|||
bool allowed = false;
|
||||
|
||||
switch (drawingModel) {
|
||||
#if defined(XP_MACOSX)
|
||||
case NPDrawingModelCoreAnimation:
|
||||
case NPDrawingModelInvalidatingCoreAnimation:
|
||||
case NPDrawingModelOpenGL:
|
||||
case NPDrawingModelCoreGraphics:
|
||||
allowed = true;
|
||||
break;
|
||||
#elif defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
case NPDrawingModelSyncWin:
|
||||
allowed = true;
|
||||
break;
|
||||
|
|
@ -494,16 +474,6 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
|
|||
|
||||
int requestModel = drawingModel;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (drawingModel == NPDrawingModelCoreAnimation ||
|
||||
drawingModel == NPDrawingModelInvalidatingCoreAnimation) {
|
||||
// We need to request CoreGraphics otherwise
|
||||
// the nsPluginFrame will try to draw a CALayer
|
||||
// that can not be shared across process.
|
||||
requestModel = NPDrawingModelCoreGraphics;
|
||||
}
|
||||
#endif
|
||||
|
||||
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
|
||||
(void*)(intptr_t)requestModel);
|
||||
|
||||
|
|
@ -514,14 +484,8 @@ bool
|
|||
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginEventModel(
|
||||
const int& eventModel, NPError* result)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
*result = mNPNIface->setvalue(mNPP, NPPVpluginEventModel,
|
||||
(void*)(intptr_t)eventModel);
|
||||
return true;
|
||||
#else
|
||||
*result = NPERR_GENERIC_ERROR;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -877,35 +841,6 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
|
|||
}
|
||||
surface = gfxSharedImageSurface::Open(newSurface.get_Shmem());
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
else if (newSurface.type() == SurfaceDescriptor::TIOSurfaceDescriptor) {
|
||||
IOSurfaceDescriptor iodesc = newSurface.get_IOSurfaceDescriptor();
|
||||
|
||||
RefPtr<MacIOSurface> newIOSurface =
|
||||
MacIOSurface::LookupSurface(iodesc.surfaceId(),
|
||||
iodesc.contentsScaleFactor());
|
||||
|
||||
if (!newIOSurface) {
|
||||
NS_WARNING("Got bad IOSurfaceDescriptor in RecvShow");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mFrontIOSurface)
|
||||
*prevSurface = IOSurfaceDescriptor(mFrontIOSurface->GetIOSurfaceID(),
|
||||
mFrontIOSurface->GetContentsScaleFactor());
|
||||
else
|
||||
*prevSurface = null_t();
|
||||
|
||||
mFrontIOSurface = newIOSurface;
|
||||
|
||||
RecvNPN_InvalidateRect(updatedRect);
|
||||
|
||||
PLUGIN_LOG_DEBUG((" (RecvShow invalidated for surface %p)",
|
||||
mFrontSurface.get()));
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_X11
|
||||
else if (newSurface.type() == SurfaceDescriptor::TSurfaceDescriptorX11) {
|
||||
surface = newSurface.get_SurfaceDescriptorX11().OpenForeign();
|
||||
|
|
@ -988,7 +923,7 @@ PluginInstanceParent::AsyncSetWindow(NPWindow* aWindow)
|
|||
window.height = aWindow->height;
|
||||
window.clipRect = aWindow->clipRect;
|
||||
window.type = aWindow->type;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double scaleFactor = 1.0;
|
||||
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &scaleFactor);
|
||||
window.contentsScaleFactor = scaleFactor;
|
||||
|
|
@ -1018,19 +953,7 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
MacIOSurface* ioSurface = nullptr;
|
||||
|
||||
if (mFrontIOSurface) {
|
||||
ioSurface = mFrontIOSurface;
|
||||
} else if (mIOSurface) {
|
||||
ioSurface = mIOSurface;
|
||||
}
|
||||
|
||||
if (!mFrontSurface && !ioSurface)
|
||||
#else
|
||||
if (!mFrontSurface)
|
||||
#endif
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
ImageContainer *container = GetImageContainer();
|
||||
|
|
@ -1039,17 +962,6 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (ioSurface) {
|
||||
RefPtr<Image> image = new MacIOSurfaceImage(ioSurface);
|
||||
container->SetCurrentImageInTransaction(image);
|
||||
|
||||
NS_IF_ADDREF(container);
|
||||
*aContainer = container;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IF_ADDREF(container);
|
||||
*aContainer = container;
|
||||
return NS_OK;
|
||||
|
|
@ -1072,16 +984,6 @@ PluginInstanceParent::GetImageSize(nsIntSize* aSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (mFrontIOSurface) {
|
||||
*aSize = nsIntSize(mFrontIOSurface->GetWidth(), mFrontIOSurface->GetHeight());
|
||||
return NS_OK;
|
||||
} else if (mIOSurface) {
|
||||
*aSize = nsIntSize(mIOSurface->GetWidth(), mIOSurface->GetHeight());
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
|
@ -1094,23 +996,14 @@ PluginInstanceParent::DidComposite()
|
|||
Unused << SendNPP_DidComposite();
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
nsresult
|
||||
PluginInstanceParent::IsRemoteDrawingCoreAnimation(bool *aDrawing)
|
||||
{
|
||||
*aDrawing = (NPDrawingModelCoreAnimation == (NPDrawingModel)mDrawingModel ||
|
||||
NPDrawingModelInvalidatingCoreAnimation == (NPDrawingModel)mDrawingModel);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
nsresult
|
||||
PluginInstanceParent::ContentsScaleFactorChanged(double aContentsScaleFactor)
|
||||
{
|
||||
bool rv = SendContentsScaleFactorChanged(aContentsScaleFactor);
|
||||
return rv ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif // #ifdef XP_MACOSX
|
||||
#endif // #ifdef XP_WIN
|
||||
|
||||
nsresult
|
||||
PluginInstanceParent::SetBackgroundUnknown()
|
||||
|
|
@ -1362,40 +1255,14 @@ PluginInstanceParent::NPP_SetWindow(const NPWindow* aWindow)
|
|||
window.type = aWindow->type;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double floatScaleFactor = 1.0;
|
||||
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &floatScaleFactor);
|
||||
int scaleFactor = ceil(floatScaleFactor);
|
||||
window.contentsScaleFactor = floatScaleFactor;
|
||||
#endif
|
||||
#if defined(XP_MACOSX)
|
||||
if (mShWidth != window.width * scaleFactor || mShHeight != window.height * scaleFactor) {
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation ||
|
||||
mDrawingModel == NPDrawingModelInvalidatingCoreAnimation) {
|
||||
mIOSurface = MacIOSurface::CreateIOSurface(window.width, window.height,
|
||||
floatScaleFactor);
|
||||
} else if (uint32_t(mShWidth * mShHeight) !=
|
||||
window.width * scaleFactor * window.height * scaleFactor) {
|
||||
if (mShWidth != 0 && mShHeight != 0) {
|
||||
DeallocShmem(mShSurface);
|
||||
mShWidth = 0;
|
||||
mShHeight = 0;
|
||||
}
|
||||
|
||||
if (window.width != 0 && window.height != 0) {
|
||||
if (!AllocShmem(window.width * scaleFactor * window.height*4 * scaleFactor,
|
||||
SharedMemory::TYPE_BASIC, &mShSurface)) {
|
||||
PLUGIN_LOG_DEBUG(("Shared memory could not be allocated."));
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
mShWidth = window.width * scaleFactor;
|
||||
mShHeight = window.height * scaleFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
const NPSetWindowCallbackStruct* ws_info =
|
||||
static_cast<NPSetWindowCallbackStruct*>(aWindow->ws_info);
|
||||
window.visualID = ws_info->visual ? ws_info->visual->visualid : 0;
|
||||
|
|
@ -1556,14 +1423,10 @@ PluginInstanceParent::NPP_HandleEvent(void* event)
|
|||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
NPCocoaEvent* npevent = reinterpret_cast<NPCocoaEvent*>(event);
|
||||
#else
|
||||
NPEvent* npevent = reinterpret_cast<NPEvent*>(event);
|
||||
#endif
|
||||
NPRemoteEvent npremoteevent;
|
||||
npremoteevent.event = *npevent;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double scaleFactor = 1.0;
|
||||
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &scaleFactor);
|
||||
npremoteevent.contentsScaleFactor = scaleFactor;
|
||||
|
|
@ -1653,111 +1516,6 @@ PluginInstanceParent::NPP_HandleEvent(void* event)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (npevent->type == NPCocoaEventDrawRect) {
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation ||
|
||||
mDrawingModel == NPDrawingModelInvalidatingCoreAnimation) {
|
||||
if (!mIOSurface) {
|
||||
NS_ERROR("No IOSurface allocated.");
|
||||
return false;
|
||||
}
|
||||
if (!CallNPP_HandleEvent_IOSurface(npremoteevent,
|
||||
mIOSurface->GetIOSurfaceID(),
|
||||
&handled))
|
||||
return false; // no good way to handle errors here...
|
||||
|
||||
CGContextRef cgContext = npevent->data.draw.context;
|
||||
if (!mShColorSpace) {
|
||||
mShColorSpace = CreateSystemColorSpace();
|
||||
}
|
||||
if (!mShColorSpace) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate ColorSpace."));
|
||||
return false;
|
||||
}
|
||||
if (cgContext) {
|
||||
nsCARenderer::DrawSurfaceToCGContext(cgContext, mIOSurface,
|
||||
mShColorSpace,
|
||||
npevent->data.draw.x,
|
||||
npevent->data.draw.y,
|
||||
npevent->data.draw.width,
|
||||
npevent->data.draw.height);
|
||||
}
|
||||
return true;
|
||||
} else if (mFrontIOSurface) {
|
||||
CGContextRef cgContext = npevent->data.draw.context;
|
||||
if (!mShColorSpace) {
|
||||
mShColorSpace = CreateSystemColorSpace();
|
||||
}
|
||||
if (!mShColorSpace) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate ColorSpace."));
|
||||
return false;
|
||||
}
|
||||
if (cgContext) {
|
||||
nsCARenderer::DrawSurfaceToCGContext(cgContext, mFrontIOSurface,
|
||||
mShColorSpace,
|
||||
npevent->data.draw.x,
|
||||
npevent->data.draw.y,
|
||||
npevent->data.draw.width,
|
||||
npevent->data.draw.height);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (mShWidth == 0 && mShHeight == 0) {
|
||||
PLUGIN_LOG_DEBUG(("NPCocoaEventDrawRect on window of size 0."));
|
||||
return false;
|
||||
}
|
||||
if (!mShSurface.IsReadable()) {
|
||||
PLUGIN_LOG_DEBUG(("Shmem is not readable."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CallNPP_HandleEvent_Shmem(npremoteevent, mShSurface,
|
||||
&handled, &mShSurface))
|
||||
return false; // no good way to handle errors here...
|
||||
|
||||
if (!mShSurface.IsReadable()) {
|
||||
PLUGIN_LOG_DEBUG(("Shmem not returned. Either the plugin crashed "
|
||||
"or we have a bug."));
|
||||
return false;
|
||||
}
|
||||
|
||||
char* shContextByte = mShSurface.get<char>();
|
||||
|
||||
if (!mShColorSpace) {
|
||||
mShColorSpace = CreateSystemColorSpace();
|
||||
}
|
||||
if (!mShColorSpace) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate ColorSpace."));
|
||||
return false;
|
||||
}
|
||||
CGContextRef shContext = ::CGBitmapContextCreate(shContextByte,
|
||||
mShWidth, mShHeight, 8,
|
||||
mShWidth*4, mShColorSpace,
|
||||
kCGImageAlphaPremultipliedFirst |
|
||||
kCGBitmapByteOrder32Host);
|
||||
if (!shContext) {
|
||||
PLUGIN_LOG_DEBUG(("Could not allocate CGBitmapContext."));
|
||||
return false;
|
||||
}
|
||||
|
||||
CGImageRef shImage = ::CGBitmapContextCreateImage(shContext);
|
||||
if (shImage) {
|
||||
CGContextRef cgContext = npevent->data.draw.context;
|
||||
|
||||
::CGContextDrawImage(cgContext,
|
||||
CGRectMake(0,0,mShWidth,mShHeight),
|
||||
shImage);
|
||||
::CGImageRelease(shImage);
|
||||
} else {
|
||||
::CGContextRelease(shContext);
|
||||
return false;
|
||||
}
|
||||
::CGContextRelease(shContext);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!CallNPP_HandleEvent(npremoteevent, &handled))
|
||||
return 0; // no good way to handle errors here...
|
||||
|
||||
|
|
|
|||
|
|
@ -322,10 +322,7 @@ public:
|
|||
nsresult AsyncSetWindow(NPWindow* window);
|
||||
nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
|
||||
nsresult GetImageSize(nsIntSize* aSize);
|
||||
#ifdef XP_MACOSX
|
||||
nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
|
||||
#endif
|
||||
nsresult SetBackgroundUnknown();
|
||||
|
|
|
|||
|
|
@ -1,137 +0,0 @@
|
|||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
|
||||
#define DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "nsPoint.h"
|
||||
#include "npapi.h"
|
||||
|
||||
// Make this includable from non-Objective-C code.
|
||||
#ifndef __OBJC__
|
||||
class NSCursor;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
// The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
|
||||
// QuickDraw APIs defined in it are still present) -- so we need to supply the
|
||||
// relevant parts of its contents here. It's likely that Apple will eventually
|
||||
// remove the APIs themselves (probably in OS X 10.8), so we need to make them
|
||||
// weak imports, and test for their presence before using them.
|
||||
#if !defined(__QUICKDRAWAPI__)
|
||||
|
||||
typedef short Bits16[16];
|
||||
struct Cursor {
|
||||
Bits16 data;
|
||||
Bits16 mask;
|
||||
Point hotSpot;
|
||||
};
|
||||
typedef struct Cursor Cursor;
|
||||
|
||||
#endif /* __QUICKDRAWAPI__ */
|
||||
|
||||
namespace mac_plugin_interposing {
|
||||
|
||||
// Class used to serialize NSCursor objects over IPC between processes.
|
||||
class NSCursorInfo {
|
||||
public:
|
||||
enum Type {
|
||||
TypeCustom,
|
||||
TypeArrow,
|
||||
TypeClosedHand,
|
||||
TypeContextualMenu, // Only supported on OS X 10.6 and up
|
||||
TypeCrosshair,
|
||||
TypeDisappearingItem,
|
||||
TypeDragCopy, // Only supported on OS X 10.6 and up
|
||||
TypeDragLink, // Only supported on OS X 10.6 and up
|
||||
TypeIBeam,
|
||||
TypeNotAllowed, // Only supported on OS X 10.6 and up
|
||||
TypeOpenHand,
|
||||
TypePointingHand,
|
||||
TypeResizeDown,
|
||||
TypeResizeLeft,
|
||||
TypeResizeLeftRight,
|
||||
TypeResizeRight,
|
||||
TypeResizeUp,
|
||||
TypeResizeUpDown,
|
||||
TypeTransparent // Special type
|
||||
};
|
||||
|
||||
NSCursorInfo();
|
||||
explicit NSCursorInfo(NSCursor* aCursor);
|
||||
explicit NSCursorInfo(const Cursor* aCursor);
|
||||
~NSCursorInfo();
|
||||
|
||||
NSCursor* GetNSCursor() const;
|
||||
Type GetType() const;
|
||||
const char* GetTypeName() const;
|
||||
nsPoint GetHotSpot() const;
|
||||
uint8_t* GetCustomImageData() const;
|
||||
uint32_t GetCustomImageDataLength() const;
|
||||
|
||||
void SetType(Type aType);
|
||||
void SetHotSpot(nsPoint aHotSpot);
|
||||
void SetCustomImageData(uint8_t* aData, uint32_t aDataLength);
|
||||
|
||||
static bool GetNativeCursorsSupported();
|
||||
|
||||
private:
|
||||
NSCursor* GetTransparentCursor() const;
|
||||
|
||||
Type mType;
|
||||
// The hot spot's coordinate system is the cursor's coordinate system, and
|
||||
// has an upper-left origin (in both Cocoa and pre-Cocoa systems).
|
||||
nsPoint mHotSpot;
|
||||
uint8_t* mCustomImageData;
|
||||
uint32_t mCustomImageDataLength;
|
||||
static int32_t mNativeCursorsSupported;
|
||||
};
|
||||
|
||||
namespace parent {
|
||||
|
||||
void OnPluginShowWindow(uint32_t window_id, CGRect window_bounds, bool modal);
|
||||
void OnPluginHideWindow(uint32_t window_id, pid_t aPluginPid);
|
||||
void OnSetCursor(const NSCursorInfo& cursorInfo);
|
||||
void OnShowCursor(bool show);
|
||||
void OnPushCursor(const NSCursorInfo& cursorInfo);
|
||||
void OnPopCursor();
|
||||
|
||||
} // namespace parent
|
||||
|
||||
namespace child {
|
||||
|
||||
void SetUpCocoaInterposing();
|
||||
|
||||
} // namespace child
|
||||
|
||||
} // namespace mac_plugin_interposing
|
||||
|
||||
#endif /* DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
virtual bool HasRequiredFunctions() = 0;
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) = 0;
|
||||
#else
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) = 0;
|
||||
|
|
@ -66,7 +66,7 @@ public:
|
|||
virtual nsresult NP_GetMIMEDescription(const char** mimeDesc) = 0;
|
||||
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
|
||||
void *aValue, NPError* error) = 0;
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) = 0;
|
||||
#endif
|
||||
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
|
||||
|
|
@ -83,10 +83,7 @@ public:
|
|||
virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize) = 0;
|
||||
virtual void DidComposite(NPP instance) = 0;
|
||||
virtual bool IsOOP() = 0;
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) = 0;
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) = 0;
|
||||
#endif
|
||||
#if defined(XP_WIN)
|
||||
|
|
|
|||
|
|
@ -49,13 +49,10 @@ namespace plugins {
|
|||
|
||||
NPRemoteWindow::NPRemoteWindow() :
|
||||
window(0), x(0), y(0), width(0), height(0), type(NPWindowTypeDrawable)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
, visualID(0)
|
||||
, colormap(0)
|
||||
#endif /* XP_UNIX */
|
||||
#if defined(XP_MACOSX)
|
||||
,contentsScaleFactor(1.0)
|
||||
#endif
|
||||
{
|
||||
clipRect.top = 0;
|
||||
clipRect.left = 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=4 ts=4 et :
|
||||
* 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/. */
|
||||
|
|
@ -23,11 +22,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsHashKeys.h"
|
||||
#ifdef XP_MACOSX
|
||||
#include "PluginInterposeOSX.h"
|
||||
#else
|
||||
namespace mac_plugin_interposing { class NSCursorInfo { }; }
|
||||
#endif
|
||||
using mac_plugin_interposing::NSCursorInfo;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -87,11 +82,11 @@ struct NPRemoteWindow
|
|||
uint32_t height;
|
||||
NPRect clipRect;
|
||||
NPWindowType type;
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
VisualID visualID;
|
||||
Colormap colormap;
|
||||
#endif /* XP_UNIX */
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double contentsScaleFactor;
|
||||
#endif
|
||||
};
|
||||
|
|
@ -111,8 +106,6 @@ struct NPAudioDeviceChangeDetailsIPC
|
|||
typedef HWND NativeWindowHandle;
|
||||
#elif defined(MOZ_X11)
|
||||
typedef XID NativeWindowHandle;
|
||||
#elif defined(XP_DARWIN)
|
||||
typedef intptr_t NativeWindowHandle; // never actually used, will always be 0
|
||||
#else
|
||||
#error Need NativeWindowHandle for this platform
|
||||
#endif
|
||||
|
|
@ -156,11 +149,6 @@ NPPVariableToString(NPPVariable aVar)
|
|||
|
||||
VARSTR(NPPVpluginWantsAllNetworkStreams);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
VARSTR(NPPVpluginDrawingModel);
|
||||
VARSTR(NPPVpluginEventModel);
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
VARSTR(NPPVpluginRequiresAudioDeviceChanges);
|
||||
#endif
|
||||
|
|
@ -357,11 +345,11 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
|
|||
WriteParam(aMsg, aParam.height);
|
||||
WriteParam(aMsg, aParam.clipRect);
|
||||
WriteParam(aMsg, aParam.type);
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
aMsg->WriteULong(aParam.visualID);
|
||||
aMsg->WriteULong(aParam.colormap);
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
aMsg->WriteDouble(aParam.contentsScaleFactor);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -382,7 +370,7 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
|
|||
ReadParam(aMsg, aIter, &type)))
|
||||
return false;
|
||||
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
unsigned long visualID;
|
||||
unsigned long colormap;
|
||||
if (!(aMsg->ReadULong(aIter, &visualID) &&
|
||||
|
|
@ -390,7 +378,7 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
|
|||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
double contentsScaleFactor;
|
||||
if (!aMsg->ReadDouble(aIter, &contentsScaleFactor))
|
||||
return false;
|
||||
|
|
@ -403,11 +391,11 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
|
|||
aResult->height = height;
|
||||
aResult->clipRect = clipRect;
|
||||
aResult->type = type;
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11) && defined(XP_UNIX)
|
||||
aResult->visualID = visualID;
|
||||
aResult->colormap = colormap;
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
aResult->contentsScaleFactor = contentsScaleFactor;
|
||||
#endif
|
||||
return true;
|
||||
|
|
@ -422,161 +410,6 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
template <>
|
||||
struct ParamTraits<NPNSString*>
|
||||
{
|
||||
typedef NPNSString* paramType;
|
||||
|
||||
// Empty string writes a length of 0 and no buffer.
|
||||
// We don't write a nullptr terminating character in buffers.
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
CFStringRef cfString = (CFStringRef)aParam;
|
||||
|
||||
// Write true if we have a string, false represents nullptr.
|
||||
aMsg->WriteBool(!!cfString);
|
||||
if (!cfString) {
|
||||
return;
|
||||
}
|
||||
|
||||
long length = ::CFStringGetLength(cfString);
|
||||
WriteParam(aMsg, length);
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to get characters without any allocation/conversion.
|
||||
if (::CFStringGetCharactersPtr(cfString)) {
|
||||
aMsg->WriteBytes(::CFStringGetCharactersPtr(cfString), length * sizeof(UniChar));
|
||||
} else {
|
||||
UniChar *buffer = (UniChar*)moz_xmalloc(length * sizeof(UniChar));
|
||||
::CFStringGetCharacters(cfString, ::CFRangeMake(0, length), buffer);
|
||||
aMsg->WriteBytes(buffer, length * sizeof(UniChar));
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
bool haveString = false;
|
||||
if (!aMsg->ReadBool(aIter, &haveString)) {
|
||||
return false;
|
||||
}
|
||||
if (!haveString) {
|
||||
*aResult = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
long length;
|
||||
if (!ReadParam(aMsg, aIter, &length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid integer multiplication overflow.
|
||||
if (length > INT_MAX / static_cast<long>(sizeof(UniChar))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto chars = mozilla::MakeUnique<UniChar[]>(length);
|
||||
if (length != 0) {
|
||||
if (!aMsg->ReadBytesInto(aIter, chars.get(), length * sizeof(UniChar))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = (NPNSString*)::CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8*)chars.get(),
|
||||
length * sizeof(UniChar),
|
||||
kCFStringEncodingUTF16, false);
|
||||
if (!*aResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
template <>
|
||||
struct ParamTraits<NSCursorInfo>
|
||||
{
|
||||
typedef NSCursorInfo paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
NSCursorInfo::Type type = aParam.GetType();
|
||||
|
||||
aMsg->WriteInt(type);
|
||||
|
||||
nsPoint hotSpot = aParam.GetHotSpot();
|
||||
WriteParam(aMsg, hotSpot.x);
|
||||
WriteParam(aMsg, hotSpot.y);
|
||||
|
||||
uint32_t dataLength = aParam.GetCustomImageDataLength();
|
||||
WriteParam(aMsg, dataLength);
|
||||
if (dataLength == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* buffer = (uint8_t*)moz_xmalloc(dataLength);
|
||||
memcpy(buffer, aParam.GetCustomImageData(), dataLength);
|
||||
aMsg->WriteBytes(buffer, dataLength);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
NSCursorInfo::Type type;
|
||||
if (!aMsg->ReadInt(aIter, (int*)&type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nscoord hotSpotX, hotSpotY;
|
||||
if (!ReadParam(aMsg, aIter, &hotSpotX) ||
|
||||
!ReadParam(aMsg, aIter, &hotSpotY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t dataLength;
|
||||
if (!ReadParam(aMsg, aIter, &dataLength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto data = mozilla::MakeUnique<uint8_t[]>(dataLength);
|
||||
if (dataLength != 0) {
|
||||
if (!aMsg->ReadBytesInto(aIter, data.get(), dataLength)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
aResult->SetType(type);
|
||||
aResult->SetHotSpot(nsPoint(hotSpotX, hotSpotY));
|
||||
aResult->SetCustomImageData(data.get(), dataLength);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Log(const paramType& aParam, std::wstring* aLog)
|
||||
{
|
||||
const char* typeName = aParam.GetTypeName();
|
||||
nsPoint hotSpot = aParam.GetHotSpot();
|
||||
int hotSpotX, hotSpotY;
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
hotSpotX = rint(hotSpot.x);
|
||||
hotSpotY = rint(hotSpot.y);
|
||||
#else
|
||||
hotSpotX = hotSpot.x;
|
||||
hotSpotY = hotSpot.y;
|
||||
#endif
|
||||
uint32_t dataLength = aParam.GetCustomImageDataLength();
|
||||
uint8_t* data = aParam.GetCustomImageData();
|
||||
|
||||
aLog->append(StringPrintf(L"[%s, (%i %i), %u, %p]",
|
||||
typeName, hotSpotX, hotSpotY, dataLength, data));
|
||||
}
|
||||
};
|
||||
#else
|
||||
template<>
|
||||
struct ParamTraits<NSCursorInfo>
|
||||
{
|
||||
|
|
@ -589,7 +422,6 @@ struct ParamTraits<NSCursorInfo>
|
|||
return false;
|
||||
}
|
||||
};
|
||||
#endif // #ifdef XP_MACOSX
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::plugins::IPCByteRange>
|
||||
|
|
@ -732,9 +564,7 @@ struct ParamTraits<mozilla::plugins::NPAudioDeviceChangeDetailsIPC>
|
|||
//
|
||||
// NB: these guards are based on those where struct NPEvent is defined
|
||||
// in npapi.h. They should be kept in sync.
|
||||
#if defined(XP_MACOSX)
|
||||
# include "mozilla/plugins/NPEventOSX.h"
|
||||
#elif defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/plugins/NPEventWindows.h"
|
||||
#elif defined(XP_UNIX)
|
||||
# include "mozilla/plugins/NPEventUnix.h"
|
||||
|
|
|
|||
|
|
@ -132,12 +132,6 @@ PluginModuleChild::PluginModuleChild(bool aIsChrome)
|
|||
MOZ_ASSERT(!gChromeInstance);
|
||||
gChromeInstance = this;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (aIsChrome) {
|
||||
mac_plugin_interposing::child::SetUpCocoaInterposing();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PluginModuleChild::~PluginModuleChild()
|
||||
|
|
@ -259,15 +253,9 @@ PluginModuleChild::InitForChrome(const std::string& aPluginFilename,
|
|||
if (StringBeginsWith(nsDependentCString(info.fDescription), flash10Head)) {
|
||||
AddQuirk(QUIRK_FLASH_EXPOSE_COORD_TRANSLATION);
|
||||
}
|
||||
#endif
|
||||
#if defined(XP_MACOSX)
|
||||
const char* namePrefix = "Plugin Content";
|
||||
char nameBuffer[80];
|
||||
SprintfLiteral(nameBuffer, "%s (%s)", namePrefix, info.fName);
|
||||
mozilla::plugins::PluginUtilsOSX::SetProcessName(nameBuffer);
|
||||
#endif
|
||||
pluginFile.FreePluginInfo(info);
|
||||
#if defined(MOZ_X11) || defined(XP_MACOSX)
|
||||
#if defined(MOZ_X11)
|
||||
if (!mLibrary)
|
||||
#endif
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: sw=4 ts=4 et :
|
||||
* 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/. */
|
||||
|
|
@ -48,9 +47,6 @@
|
|||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <glib.h>
|
||||
#elif XP_MACOSX
|
||||
#include "PluginInterposeOSX.h"
|
||||
#include "PluginUtilsOSX.h"
|
||||
#endif
|
||||
|
||||
using base::KillProcess;
|
||||
|
|
@ -508,7 +504,7 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
|
|||
if (NS_SUCCEEDED(mAsyncInitRv))
|
||||
#endif
|
||||
{
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
mAsyncInitRv = NP_Initialize(mNPNIface,
|
||||
mNPPIface,
|
||||
&mAsyncInitError);
|
||||
|
|
@ -517,13 +513,6 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
|
|||
&mAsyncInitError);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
if (NS_SUCCEEDED(mAsyncInitRv)) {
|
||||
mAsyncInitRv = NP_GetEntryPoints(mNPPIface,
|
||||
&mAsyncInitError);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1668,13 +1657,8 @@ PluginModuleParent::GetSettings(PluginSettings* aSettings)
|
|||
aSettings->supportsWindowless() = GetSetting(NPNVSupportsWindowless);
|
||||
aSettings->userAgent() = NullableString(mNPNIface->uagent(nullptr));
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
aSettings->nativeCursorsSupported() =
|
||||
Preferences::GetBool("dom.ipc.plugins.nativeCursorSupport", false);
|
||||
#else
|
||||
// Need to initialize this to satisfy IPDL.
|
||||
aSettings->nativeCursorsSupported() = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1692,7 +1676,7 @@ PluginModuleChromeParent::CachedSettingChanged(const char* aPref, void* aModule)
|
|||
module->CachedSettingChanged();
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
nsresult
|
||||
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
|
||||
{
|
||||
|
|
@ -1830,7 +1814,7 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
|
||||
nsresult
|
||||
PluginModuleContentParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
||||
|
|
@ -1853,20 +1837,10 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
if (!mSubprocess->IsConnected()) {
|
||||
// The subprocess isn't connected yet. Defer NP_Initialize until
|
||||
// OnProcessLaunched is invoked.
|
||||
mInitOnAsyncConnect = true;
|
||||
*error = NPERR_NO_ERROR;
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
if (mInitOnAsyncConnect) {
|
||||
*error = NPERR_NO_ERROR;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
PluginSettings settings;
|
||||
GetSettings(&settings);
|
||||
|
|
@ -2058,7 +2032,7 @@ PluginModuleParent::NP_GetValue(void *future, NPPVariable aVariable,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
nsresult
|
||||
PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
||||
{
|
||||
|
|
@ -2067,16 +2041,7 @@ PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
|||
*error = NPERR_NO_ERROR;
|
||||
if (mIsStartingAsync && !IsChrome()) {
|
||||
mNPPIface = pFuncs;
|
||||
#if defined(XP_MACOSX)
|
||||
if (mNPInitialized) {
|
||||
SetPluginFuncs(pFuncs);
|
||||
InitAsyncSurrogates();
|
||||
} else {
|
||||
PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
|
||||
}
|
||||
#else
|
||||
PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
|
||||
#endif
|
||||
} else {
|
||||
SetPluginFuncs(pFuncs);
|
||||
}
|
||||
|
|
@ -2087,14 +2052,6 @@ PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
|||
nsresult
|
||||
PluginModuleChromeParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
||||
{
|
||||
#if defined(XP_MACOSX)
|
||||
if (mInitOnAsyncConnect) {
|
||||
PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
|
||||
mNPPIface = pFuncs;
|
||||
*error = NPERR_NO_ERROR;
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
if (mIsStartingAsync) {
|
||||
PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
|
||||
}
|
||||
|
|
@ -2104,7 +2061,6 @@ PluginModuleChromeParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* erro
|
|||
*error = NPERR_NO_ERROR;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// We need to have the plugin process update its function table here by
|
||||
// actually calling NP_GetEntryPoints. The parent's function table will
|
||||
|
|
@ -2325,18 +2281,7 @@ PluginModuleParent::NPP_GetSitesWithData(nsCOMPtr<nsIGetSitesWithDataCallback> c
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginModuleParent::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
|
||||
{
|
||||
PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
|
||||
if (!i)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return i->IsRemoteDrawingCoreAnimation(aDrawing);
|
||||
}
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
nsresult
|
||||
PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
|
||||
{
|
||||
|
|
@ -2346,17 +2291,9 @@ PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsSca
|
|||
|
||||
return i->ContentsScaleFactorChanged(aContentsScaleFactor);
|
||||
}
|
||||
#endif // #if defined(XP_MACOSX)
|
||||
#endif // #if defined(XP_WIN)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
bool
|
||||
PluginModuleParent::AnswerProcessSomeEvents()
|
||||
{
|
||||
mozilla::plugins::PluginUtilsOSX::InvokeNativeEventLoop();
|
||||
return true;
|
||||
}
|
||||
|
||||
#elif !defined(MOZ_WIDGET_GTK)
|
||||
#if !defined(MOZ_WIDGET_GTK)
|
||||
bool
|
||||
PluginModuleParent::AnswerProcessSomeEvents()
|
||||
{
|
||||
|
|
@ -2414,85 +2351,54 @@ PluginModuleParent::RecvPluginShowWindow(const uint32_t& aWindowId, const bool&
|
|||
const size_t& aWidth, const size_t& aHeight)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
CGRect windowBound = ::CGRectMake(aX, aY, aWidth, aHeight);
|
||||
mac_plugin_interposing::parent::OnPluginShowWindow(aWindowId, windowBound, aModal);
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvPluginShowWindow not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvPluginHideWindow(const uint32_t& aWindowId)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnPluginHideWindow(aWindowId, OtherPid());
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvPluginHideWindow not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvSetCursor(const NSCursorInfo& aCursorInfo)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnSetCursor(aCursorInfo);
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvSetCursor not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvShowCursor(const bool& aShow)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnShowCursor(aShow);
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvShowCursor not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvPushCursor(const NSCursorInfo& aCursorInfo)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnPushCursor(aCursorInfo);
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvPushCursor not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvPopCursor()
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnPopCursor();
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
"PluginInstanceParent::RecvPopCursor not implemented!");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ protected:
|
|||
const mozilla::NativeEventData& aNativeKeyData,
|
||||
bool aIsConsumed) override;
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
|
||||
#else
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
|
||||
|
|
@ -257,7 +257,7 @@ protected:
|
|||
virtual nsresult NP_GetMIMEDescription(const char** mimeDesc) override;
|
||||
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
|
||||
void *aValue, NPError* error) override;
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) override;
|
||||
#endif
|
||||
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
|
||||
|
|
@ -278,10 +278,7 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) override;
|
||||
#endif
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) override;
|
||||
#endif
|
||||
|
||||
|
|
@ -355,7 +352,7 @@ class PluginModuleContentParent : public PluginModuleParent
|
|||
|
||||
virtual ~PluginModuleContentParent();
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
|
||||
#endif
|
||||
|
||||
|
|
@ -479,13 +476,13 @@ private:
|
|||
PluginProcessParent* Process() const { return mSubprocess; }
|
||||
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
#if defined(XP_UNIX)
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
|
||||
#else
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#if defined(XP_WIN)
|
||||
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) override;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: sw=4 ts=4 et :
|
||||
* 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/. */
|
||||
|
|
@ -13,13 +12,6 @@
|
|||
#include "base/string_util.h"
|
||||
#include "nsDebugImpl.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include "nsCocoaFeatures.h"
|
||||
// An undocumented CoreGraphics framework method, present in the same form
|
||||
// since at least OS X 10.5.
|
||||
extern "C" CGError CGSSetDebugOptions(int options);
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
bool ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath);
|
||||
#endif
|
||||
|
|
@ -40,42 +32,6 @@ PluginProcessChild::Init()
|
|||
{
|
||||
nsDebugImpl::SetMultiprocessMode("NPAPI");
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// Remove the trigger for "dyld interposing" that we added in
|
||||
// GeckoChildProcessHost::PerformAsyncLaunchInternal(), in the host
|
||||
// process just before we were launched. Dyld interposing will still
|
||||
// happen in our process (the plugin child process). But we don't want
|
||||
// it to happen in any processes that the plugin might launch from our
|
||||
// process.
|
||||
nsCString interpose(PR_GetEnv("DYLD_INSERT_LIBRARIES"));
|
||||
if (!interpose.IsEmpty()) {
|
||||
// If we added the path to libplugin_child_interpose.dylib to an
|
||||
// existing DYLD_INSERT_LIBRARIES, we appended it to the end, after a
|
||||
// ":" path seperator.
|
||||
int32_t lastSeparatorPos = interpose.RFind(":");
|
||||
int32_t lastTriggerPos = interpose.RFind("libplugin_child_interpose.dylib");
|
||||
bool needsReset = false;
|
||||
if (lastTriggerPos != -1) {
|
||||
if (lastSeparatorPos == -1) {
|
||||
interpose.Truncate();
|
||||
needsReset = true;
|
||||
} else if (lastTriggerPos > lastSeparatorPos) {
|
||||
interpose.SetLength(lastSeparatorPos);
|
||||
needsReset = true;
|
||||
}
|
||||
}
|
||||
if (needsReset) {
|
||||
nsCString setInterpose("DYLD_INSERT_LIBRARIES=");
|
||||
if (!interpose.IsEmpty()) {
|
||||
setInterpose.Append(interpose);
|
||||
}
|
||||
// Values passed to PR_SetEnv() must be seperately allocated.
|
||||
char* setInterposePtr = strdup(setInterpose.get());
|
||||
PR_SetEnv(setInterposePtr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Certain plugins, such as flash, steal the unhandled exception filter
|
||||
// thus we never get crash reports when they fault. This call fixes it.
|
||||
message_loop()->set_exception_restoration(true);
|
||||
|
|
@ -115,17 +71,6 @@ PluginProcessChild::Init()
|
|||
bool retval = mPlugin.InitForChrome(pluginFilename, ParentPid(),
|
||||
IOThreadChild::message_loop(),
|
||||
IOThreadChild::channel());
|
||||
#if defined(XP_MACOSX)
|
||||
if (nsCocoaFeatures::OnYosemiteOrLater()) {
|
||||
// Explicitly turn off CGEvent logging. This works around bug 1092855.
|
||||
// If there are already CGEvents in the log, turning off logging also
|
||||
// causes those events to be written to disk. But at this point no
|
||||
// CGEvents have yet been processed. CGEvents are events (usually
|
||||
// input events) pulled from the WindowServer. An option of 0x80000008
|
||||
// turns on CGEvent logging.
|
||||
CGSSetDebugOptions(0x80000007);
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,13 +49,6 @@ PluginProcessParent::Launch(mozilla::UniquePtr<LaunchCompleteTask> aLaunchComple
|
|||
uint32_t containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
|
||||
|
||||
uint32_t pluginLibArchitectures = currentArchitecture;
|
||||
#ifdef XP_MACOSX
|
||||
nsresult rv = GetArchitecturesForBinary(mPluginFilePath.c_str(), &pluginLibArchitectures);
|
||||
if (NS_FAILED(rv)) {
|
||||
// If the call failed just assume that we want the current architecture.
|
||||
pluginLibArchitectures = currentArchitecture;
|
||||
}
|
||||
#endif
|
||||
|
||||
ProcessArchitecture selectedArchitecture = currentArchitecture;
|
||||
if (!(pluginLibArchitectures & containerArchitectures & currentArchitecture)) {
|
||||
|
|
|
|||
|
|
@ -49,16 +49,6 @@ int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Whitelist Flash and Quicktime to support offline renderer
|
||||
NS_NAMED_LITERAL_CSTRING(quicktime, "QuickTime Plugin.plugin");
|
||||
if (specialType == nsPluginHost::eSpecialType_Flash) {
|
||||
quirks |= QUIRK_ALLOW_OFFLINE_RENDERER;
|
||||
} else if (FindInReadable(quicktime, aPluginFilename)) {
|
||||
quirks |= QUIRK_ALLOW_OFFLINE_RENDERER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OS_WIN
|
||||
if (specialType == nsPluginHost::eSpecialType_Unity) {
|
||||
quirks |= QUIRK_UNITY_FIXUP_MOUSE_CAPTURE;
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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 dom_plugins_PluginUtilsOSX_h
|
||||
#define dom_plugins_PluginUtilsOSX_h 1
|
||||
|
||||
#include "npapi.h"
|
||||
#include "mozilla/gfx/QuartzSupport.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
namespace PluginUtilsOSX {
|
||||
|
||||
// Need to call back into the browser's message loop to process event.
|
||||
typedef void (*RemoteProcessEvents) (void*);
|
||||
|
||||
NPError ShowCocoaContextMenu(void* aMenu, int aX, int aY, void* pluginModule, RemoteProcessEvents remoteEvent);
|
||||
|
||||
void InvokeNativeEventLoop();
|
||||
|
||||
// Need to call back and send a cocoa draw event to the plugin.
|
||||
typedef void (*DrawPluginFunc) (CGContextRef, void*, nsIntRect aUpdateRect);
|
||||
|
||||
void* GetCGLayer(DrawPluginFunc aFunc, void* aPluginInstance, double aContentsScaleFactor);
|
||||
void ReleaseCGLayer(void* cgLayer);
|
||||
void Repaint(void* cgLayer, nsIntRect aRect);
|
||||
|
||||
bool SetProcessName(const char* aProcessName);
|
||||
|
||||
/*
|
||||
* Provides a wrapper around nsCARenderer to manage double buffering
|
||||
* without having to unbind nsCARenderer on every surface swaps.
|
||||
*
|
||||
* The double buffer renderer begins with no initialize surfaces.
|
||||
* The buffers can be initialized and cleared individually.
|
||||
* Swapping still occurs regardless if the buffers are initialized.
|
||||
*/
|
||||
class nsDoubleBufferCARenderer {
|
||||
public:
|
||||
nsDoubleBufferCARenderer() : mCALayer(nullptr), mContentsScaleFactor(1.0) {}
|
||||
// Returns width in "display pixels". A "display pixel" is the smallest
|
||||
// fully addressable part of a display. But in HiDPI modes each "display
|
||||
// pixel" corresponds to more than one device pixel. Multiply display pixels
|
||||
// by mContentsScaleFactor to get device pixels.
|
||||
size_t GetFrontSurfaceWidth();
|
||||
// Returns height in "display pixels". Multiply by
|
||||
// mContentsScaleFactor to get device pixels.
|
||||
size_t GetFrontSurfaceHeight();
|
||||
double GetFrontSurfaceContentsScaleFactor();
|
||||
// Returns width in "display pixels". Multiply by
|
||||
// mContentsScaleFactor to get device pixels.
|
||||
size_t GetBackSurfaceWidth();
|
||||
// Returns height in "display pixels". Multiply by
|
||||
// mContentsScaleFactor to get device pixels.
|
||||
size_t GetBackSurfaceHeight();
|
||||
double GetBackSurfaceContentsScaleFactor();
|
||||
IOSurfaceID GetFrontSurfaceID();
|
||||
|
||||
bool HasBackSurface();
|
||||
bool HasFrontSurface();
|
||||
bool HasCALayer();
|
||||
|
||||
void SetCALayer(void *aCALayer);
|
||||
// aWidth and aHeight are in "display pixels". Multiply by
|
||||
// aContentsScaleFactor to get device pixels.
|
||||
bool InitFrontSurface(size_t aWidth, size_t aHeight,
|
||||
double aContentsScaleFactor,
|
||||
AllowOfflineRendererEnum aAllowOfflineRenderer);
|
||||
void Render();
|
||||
void SwapSurfaces();
|
||||
void ClearFrontSurface();
|
||||
void ClearBackSurface();
|
||||
|
||||
double GetContentsScaleFactor() { return mContentsScaleFactor; }
|
||||
|
||||
private:
|
||||
void *mCALayer;
|
||||
RefPtr<nsCARenderer> mCARenderer;
|
||||
RefPtr<MacIOSurface> mFrontSurface;
|
||||
RefPtr<MacIOSurface> mBackSurface;
|
||||
double mContentsScaleFactor;
|
||||
};
|
||||
|
||||
} // namespace PluginUtilsOSX
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
#endif //dom_plugins_PluginUtilsOSX_h
|
||||
|
|
@ -1,462 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include "PluginUtilsOSX.h"
|
||||
|
||||
// Remove definitions for try/catch interfering with ObjCException macros.
|
||||
#include "nsObjCExceptions.h"
|
||||
#include "nsCocoaUtils.h"
|
||||
|
||||
#include "nsDebug.h"
|
||||
|
||||
#include "mozilla/Sprintf.h"
|
||||
|
||||
@interface CALayer (ContentsScale)
|
||||
- (double)contentsScale;
|
||||
- (void)setContentsScale:(double)scale;
|
||||
@end
|
||||
|
||||
using namespace mozilla::plugins::PluginUtilsOSX;
|
||||
|
||||
@interface CGBridgeLayer : CALayer {
|
||||
DrawPluginFunc mDrawFunc;
|
||||
void* mPluginInstance;
|
||||
nsIntRect mUpdateRect;
|
||||
}
|
||||
- (void)setDrawFunc:(DrawPluginFunc)aFunc
|
||||
pluginInstance:(void*)aPluginInstance;
|
||||
- (void)updateRect:(nsIntRect)aRect;
|
||||
|
||||
@end
|
||||
|
||||
// CGBitmapContextSetData() is an undocumented function present (with
|
||||
// the same signature) since at least OS X 10.5. As the name suggests,
|
||||
// it's used to replace the "data" in a bitmap context that was
|
||||
// originally specified in a call to CGBitmapContextCreate() or
|
||||
// CGBitmapContextCreateWithData().
|
||||
typedef void (*CGBitmapContextSetDataFunc) (CGContextRef c,
|
||||
size_t x,
|
||||
size_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
void* data,
|
||||
size_t bitsPerComponent,
|
||||
size_t bitsPerPixel,
|
||||
size_t bytesPerRow);
|
||||
CGBitmapContextSetDataFunc CGBitmapContextSetDataPtr = NULL;
|
||||
|
||||
@implementation CGBridgeLayer
|
||||
- (void) updateRect:(nsIntRect)aRect
|
||||
{
|
||||
mUpdateRect.UnionRect(mUpdateRect, aRect);
|
||||
}
|
||||
|
||||
- (void) setDrawFunc:(DrawPluginFunc)aFunc
|
||||
pluginInstance:(void*)aPluginInstance
|
||||
{
|
||||
mDrawFunc = aFunc;
|
||||
mPluginInstance = aPluginInstance;
|
||||
}
|
||||
|
||||
- (void)drawInContext:(CGContextRef)aCGContext
|
||||
{
|
||||
::CGContextSaveGState(aCGContext);
|
||||
::CGContextTranslateCTM(aCGContext, 0, self.bounds.size.height);
|
||||
::CGContextScaleCTM(aCGContext, (CGFloat) 1, (CGFloat) -1);
|
||||
|
||||
mUpdateRect = nsIntRect::Truncate(0, 0, self.bounds.size.width, self.bounds.size.height);
|
||||
|
||||
mDrawFunc(aCGContext, mPluginInstance, mUpdateRect);
|
||||
|
||||
::CGContextRestoreGState(aCGContext);
|
||||
|
||||
mUpdateRect.SetEmpty();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void* mozilla::plugins::PluginUtilsOSX::GetCGLayer(DrawPluginFunc aFunc,
|
||||
void* aPluginInstance,
|
||||
double aContentsScaleFactor) {
|
||||
CGBridgeLayer *bridgeLayer = [[CGBridgeLayer alloc] init];
|
||||
|
||||
// We need to make bridgeLayer behave properly when its superlayer changes
|
||||
// size (in nsCARenderer::SetBounds()).
|
||||
bridgeLayer.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
|
||||
bridgeLayer.needsDisplayOnBoundsChange = YES;
|
||||
NSNull *nullValue = [NSNull null];
|
||||
NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
nullValue, @"bounds",
|
||||
nullValue, @"contents",
|
||||
nullValue, @"contentsRect",
|
||||
nullValue, @"position",
|
||||
nil];
|
||||
[bridgeLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
|
||||
|
||||
// For reasons that aren't clear (perhaps one or more OS bugs), we can only
|
||||
// use full HiDPI resolution here if the tree is built with the 10.7 SDK or
|
||||
// up. If we build with the 10.6 SDK, changing the contentsScale property
|
||||
// of bridgeLayer (even to the same value) causes it to stop working (go
|
||||
// blank). This doesn't happen with objects that are members of the CALayer
|
||||
// class (as opposed to one of its subclasses).
|
||||
#if defined(MAC_OS_X_VERSION_10_7) && \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if ([bridgeLayer respondsToSelector:@selector(setContentsScale:)]) {
|
||||
bridgeLayer.contentsScale = aContentsScaleFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
[bridgeLayer setDrawFunc:aFunc
|
||||
pluginInstance:aPluginInstance];
|
||||
return bridgeLayer;
|
||||
}
|
||||
|
||||
void mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(void *cgLayer) {
|
||||
CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)cgLayer;
|
||||
[bridgeLayer release];
|
||||
}
|
||||
|
||||
void mozilla::plugins::PluginUtilsOSX::Repaint(void *caLayer, nsIntRect aRect) {
|
||||
CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)caLayer;
|
||||
[CATransaction begin];
|
||||
[bridgeLayer updateRect:aRect];
|
||||
[bridgeLayer setNeedsDisplay];
|
||||
[bridgeLayer displayIfNeeded];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
@interface EventProcessor : NSObject {
|
||||
RemoteProcessEvents aRemoteEvents;
|
||||
void *aPluginModule;
|
||||
}
|
||||
- (void)setRemoteEvents:(RemoteProcessEvents) remoteEvents pluginModule:(void*) pluginModule;
|
||||
- (void)onTick;
|
||||
@end
|
||||
|
||||
@implementation EventProcessor
|
||||
- (void) onTick
|
||||
{
|
||||
aRemoteEvents(aPluginModule);
|
||||
}
|
||||
|
||||
- (void)setRemoteEvents:(RemoteProcessEvents) remoteEvents pluginModule:(void*) pluginModule
|
||||
{
|
||||
aRemoteEvents = remoteEvents;
|
||||
aPluginModule = pluginModule;
|
||||
}
|
||||
@end
|
||||
|
||||
#define EVENT_PROCESS_DELAY 0.05 // 50 ms
|
||||
|
||||
NPError mozilla::plugins::PluginUtilsOSX::ShowCocoaContextMenu(void* aMenu, int aX, int aY, void* pluginModule, RemoteProcessEvents remoteEvent)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
// Set the native cursor to the OS default (an arrow) before displaying the
|
||||
// context menu. Otherwise (if the plugin has changed the cursor) it may
|
||||
// stay as the plugin has set it -- which means it may be invisible. We
|
||||
// need to do this because we display the context menu without making the
|
||||
// plugin process the foreground process. If we did, the cursor would
|
||||
// change to an arrow cursor automatically -- as it does in Chrome.
|
||||
[[NSCursor arrowCursor] set];
|
||||
|
||||
EventProcessor* eventProcessor = nullptr;
|
||||
NSTimer *eventTimer = nullptr;
|
||||
if (pluginModule) {
|
||||
// Create a timer to process browser events while waiting
|
||||
// on the menu. This prevents the browser from hanging
|
||||
// during the lifetime of the menu.
|
||||
eventProcessor = [[EventProcessor alloc] init];
|
||||
[eventProcessor setRemoteEvents:remoteEvent pluginModule:pluginModule];
|
||||
eventTimer = [NSTimer timerWithTimeInterval:EVENT_PROCESS_DELAY
|
||||
target:eventProcessor selector:@selector(onTick)
|
||||
userInfo:nil repeats:TRUE];
|
||||
// Use NSEventTrackingRunLoopMode otherwise the timer will
|
||||
// not fire during the right click menu.
|
||||
[[NSRunLoop currentRunLoop] addTimer:eventTimer
|
||||
forMode:NSEventTrackingRunLoopMode];
|
||||
}
|
||||
|
||||
NSMenu* nsmenu = reinterpret_cast<NSMenu*>(aMenu);
|
||||
NSPoint screen_point = ::NSMakePoint(aX, aY);
|
||||
|
||||
[nsmenu popUpMenuPositioningItem:nil atLocation:screen_point inView:nil];
|
||||
|
||||
if (pluginModule) {
|
||||
[eventTimer invalidate];
|
||||
[eventProcessor release];
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NPERR_GENERIC_ERROR);
|
||||
}
|
||||
|
||||
void mozilla::plugins::PluginUtilsOSX::InvokeNativeEventLoop()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
::CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, true);
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
|
||||
#define UNDOCUMENTED_SESSION_CONSTANT ((int)-2)
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
namespace PluginUtilsOSX {
|
||||
static void *sApplicationASN = NULL;
|
||||
static void *sApplicationInfoItem = NULL;
|
||||
} // namespace PluginUtilsOSX
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
bool mozilla::plugins::PluginUtilsOSX::SetProcessName(const char* aProcessName) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
if (!aProcessName || strcmp(aProcessName, "") == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NSString *currentName = [[[NSBundle mainBundle] localizedInfoDictionary]
|
||||
objectForKey:(NSString *)kCFBundleNameKey];
|
||||
|
||||
char formattedName[1024];
|
||||
SprintfLiteral(formattedName, "%s %s", [currentName UTF8String], aProcessName);
|
||||
|
||||
aProcessName = formattedName;
|
||||
|
||||
// This function is based on Chrome/Webkit's and relies on potentially dangerous SPI.
|
||||
typedef CFTypeRef (*LSGetASNType)();
|
||||
typedef OSStatus (*LSSetInformationItemType)(int, CFTypeRef,
|
||||
CFStringRef,
|
||||
CFStringRef,
|
||||
CFDictionaryRef*);
|
||||
|
||||
CFBundleRef launchServices = ::CFBundleGetBundleWithIdentifier(
|
||||
CFSTR("com.apple.LaunchServices"));
|
||||
if (!launchServices) {
|
||||
NS_WARNING("Failed to set process name: Could not open LaunchServices bundle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sApplicationASN) {
|
||||
sApplicationASN = ::CFBundleGetFunctionPointerForName(launchServices,
|
||||
CFSTR("_LSGetCurrentApplicationASN"));
|
||||
}
|
||||
|
||||
LSGetASNType getASNFunc = reinterpret_cast<LSGetASNType>
|
||||
(sApplicationASN);
|
||||
|
||||
if (!sApplicationInfoItem) {
|
||||
sApplicationInfoItem = ::CFBundleGetFunctionPointerForName(launchServices,
|
||||
CFSTR("_LSSetApplicationInformationItem"));
|
||||
}
|
||||
|
||||
LSSetInformationItemType setInformationItemFunc
|
||||
= reinterpret_cast<LSSetInformationItemType>
|
||||
(sApplicationInfoItem);
|
||||
|
||||
void * displayNameKeyAddr = ::CFBundleGetDataPointerForName(launchServices,
|
||||
CFSTR("_kLSDisplayNameKey"));
|
||||
|
||||
CFStringRef displayNameKey = nil;
|
||||
if (displayNameKeyAddr) {
|
||||
displayNameKey = reinterpret_cast<CFStringRef>(*(CFStringRef*)displayNameKeyAddr);
|
||||
}
|
||||
|
||||
// Rename will fail without this
|
||||
ProcessSerialNumber psn;
|
||||
if (::GetCurrentProcess(&psn) != noErr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CFTypeRef currentAsn = getASNFunc();
|
||||
|
||||
if (!getASNFunc || !setInformationItemFunc ||
|
||||
!displayNameKey || !currentAsn) {
|
||||
NS_WARNING("Failed to set process name: Accessing launchServices failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
CFStringRef processName = ::CFStringCreateWithCString(nil,
|
||||
aProcessName,
|
||||
kCFStringEncodingASCII);
|
||||
if (!processName) {
|
||||
NS_WARNING("Failed to set process name: Could not create CFStringRef");
|
||||
return false;
|
||||
}
|
||||
|
||||
OSErr err = setInformationItemFunc(UNDOCUMENTED_SESSION_CONSTANT, currentAsn,
|
||||
displayNameKey, processName,
|
||||
nil); // Optional out param
|
||||
::CFRelease(processName);
|
||||
if (err != noErr) {
|
||||
NS_WARNING("Failed to set process name: LSSetInformationItemType err");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
namespace PluginUtilsOSX {
|
||||
|
||||
size_t nsDoubleBufferCARenderer::GetFrontSurfaceWidth() {
|
||||
if (!HasFrontSurface()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mFrontSurface->GetWidth();
|
||||
}
|
||||
|
||||
size_t nsDoubleBufferCARenderer::GetFrontSurfaceHeight() {
|
||||
if (!HasFrontSurface()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mFrontSurface->GetHeight();
|
||||
}
|
||||
|
||||
double nsDoubleBufferCARenderer::GetFrontSurfaceContentsScaleFactor() {
|
||||
if (!HasFrontSurface()) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return mFrontSurface->GetContentsScaleFactor();
|
||||
}
|
||||
|
||||
size_t nsDoubleBufferCARenderer::GetBackSurfaceWidth() {
|
||||
if (!HasBackSurface()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mBackSurface->GetWidth();
|
||||
}
|
||||
|
||||
size_t nsDoubleBufferCARenderer::GetBackSurfaceHeight() {
|
||||
if (!HasBackSurface()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mBackSurface->GetHeight();
|
||||
}
|
||||
|
||||
double nsDoubleBufferCARenderer::GetBackSurfaceContentsScaleFactor() {
|
||||
if (!HasBackSurface()) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return mBackSurface->GetContentsScaleFactor();
|
||||
}
|
||||
|
||||
IOSurfaceID nsDoubleBufferCARenderer::GetFrontSurfaceID() {
|
||||
if (!HasFrontSurface()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mFrontSurface->GetIOSurfaceID();
|
||||
}
|
||||
|
||||
bool nsDoubleBufferCARenderer::HasBackSurface() {
|
||||
return !!mBackSurface;
|
||||
}
|
||||
|
||||
bool nsDoubleBufferCARenderer::HasFrontSurface() {
|
||||
return !!mFrontSurface;
|
||||
}
|
||||
|
||||
bool nsDoubleBufferCARenderer::HasCALayer() {
|
||||
return !!mCALayer;
|
||||
}
|
||||
|
||||
void nsDoubleBufferCARenderer::SetCALayer(void *aCALayer) {
|
||||
mCALayer = aCALayer;
|
||||
}
|
||||
|
||||
bool nsDoubleBufferCARenderer::InitFrontSurface(size_t aWidth, size_t aHeight,
|
||||
double aContentsScaleFactor,
|
||||
AllowOfflineRendererEnum aAllowOfflineRenderer) {
|
||||
if (!mCALayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mContentsScaleFactor = aContentsScaleFactor;
|
||||
mFrontSurface = MacIOSurface::CreateIOSurface(aWidth, aHeight, mContentsScaleFactor);
|
||||
if (!mFrontSurface) {
|
||||
mCARenderer = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mCARenderer) {
|
||||
mCARenderer = new nsCARenderer();
|
||||
if (!mCARenderer) {
|
||||
mFrontSurface = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
mCARenderer->AttachIOSurface(mFrontSurface);
|
||||
|
||||
nsresult result = mCARenderer->SetupRenderer(mCALayer,
|
||||
mFrontSurface->GetWidth(),
|
||||
mFrontSurface->GetHeight(),
|
||||
mContentsScaleFactor,
|
||||
aAllowOfflineRenderer);
|
||||
|
||||
if (result != NS_OK) {
|
||||
mCARenderer = nullptr;
|
||||
mFrontSurface = nullptr;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
mCARenderer->AttachIOSurface(mFrontSurface);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void nsDoubleBufferCARenderer::Render() {
|
||||
if (!HasFrontSurface() || !mCARenderer) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCARenderer->Render(GetFrontSurfaceWidth(), GetFrontSurfaceHeight(),
|
||||
mContentsScaleFactor, nullptr);
|
||||
}
|
||||
|
||||
void nsDoubleBufferCARenderer::SwapSurfaces() {
|
||||
RefPtr<MacIOSurface> prevFrontSurface = mFrontSurface;
|
||||
mFrontSurface = mBackSurface;
|
||||
mBackSurface = prevFrontSurface;
|
||||
|
||||
if (mFrontSurface) {
|
||||
mCARenderer->AttachIOSurface(mFrontSurface);
|
||||
}
|
||||
}
|
||||
|
||||
void nsDoubleBufferCARenderer::ClearFrontSurface() {
|
||||
mFrontSurface = nullptr;
|
||||
if (!mFrontSurface && !mBackSurface) {
|
||||
mCARenderer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void nsDoubleBufferCARenderer::ClearBackSurface() {
|
||||
mBackSurface = nullptr;
|
||||
if (!mFrontSurface && !mBackSurface) {
|
||||
mCARenderer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace PluginUtilsOSX
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# 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/.
|
||||
|
||||
SharedLibrary('plugin_child_interpose')
|
||||
|
||||
SOURCES += [ "%s.mm" % (LIBRARY_NAME) ]
|
||||
|
||||
OS_LIBS += ['-framework Carbon']
|
||||
|
||||
DIST_INSTALL = True
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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/. */
|
||||
|
||||
// Use "dyld interposing" to hook methods imported from other libraries in the
|
||||
// plugin child process. The basic technique is described at
|
||||
// http://books.google.com/books?id=K8vUkpOXhN4C&pg=PA73&lpg=PA73&dq=__interpose&source=bl&ots=OJnnXZYpZC&sig=o7I3lXvoduUi13SrPfOON7o3do4&hl=en&ei=AoehS9brCYGQNrvsmeUM&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBsQ6AEwBQ#v=onepage&q=__interpose&f=false.
|
||||
// The idea of doing it for the plugin child process comes from Chromium code,
|
||||
// particularly from plugin_carbon_interpose_mac.cc
|
||||
// (http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/chrome/browser/plugin_carbon_interpose_mac.cc&q=nscursor&exact_package=chromium&d=1&l=168)
|
||||
// and from PluginProcessHost::Init() in plugin_process_host.cc
|
||||
// (http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/content/browser/plugin_process_host.cc&q=nscursor&exact_package=chromium&d=1&l=222).
|
||||
|
||||
// These hooks are needed to make certain OS calls work from the child process
|
||||
// (a background process) that would normally only work when called in the
|
||||
// parent process (the foreground process). They allow us to serialize
|
||||
// information from the child process to the parent process, so that the same
|
||||
// (or equivalent) calls can be made from the parent process.
|
||||
|
||||
// This file lives in a seperate module (libplugin_child_interpose.dylib),
|
||||
// which will get loaded by the OS before any other modules when the plugin
|
||||
// child process is launched (from GeckoChildProcessHost::
|
||||
// PerformAsyncLaunchInternal()). For this reason it shouldn't link in other
|
||||
// browser modules when loaded. Instead it should use dlsym() to load
|
||||
// pointers to the methods it wants to call in other modules.
|
||||
|
||||
#if !defined(__LP64__)
|
||||
|
||||
#include <dlfcn.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
// The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
|
||||
// QuickDraw APIs defined in it are still present) -- so we need to supply the
|
||||
// relevant parts of its contents here. It's likely that Apple will eventually
|
||||
// remove the APIs themselves (probably in OS X 10.8), so we need to make them
|
||||
// weak imports, and test for their presence before using them.
|
||||
#if !defined(__QUICKDRAWAPI__)
|
||||
|
||||
struct Cursor;
|
||||
extern "C" void SetCursor(const Cursor * crsr) __attribute__((weak_import));
|
||||
|
||||
#endif /* __QUICKDRAWAPI__ */
|
||||
|
||||
BOOL (*OnSetThemeCursorPtr) (ThemeCursor) = NULL;
|
||||
BOOL (*OnSetCursorPtr) (const Cursor*) = NULL;
|
||||
BOOL (*OnHideCursorPtr) () = NULL;
|
||||
BOOL (*OnShowCursorPtr) () = NULL;
|
||||
|
||||
static BOOL loadXULPtrs()
|
||||
{
|
||||
if (!OnSetThemeCursorPtr) {
|
||||
// mac_plugin_interposing_child_OnSetThemeCursor(ThemeCursor cursor) is in
|
||||
// PluginInterposeOSX.mm
|
||||
OnSetThemeCursorPtr = (BOOL(*)(ThemeCursor))
|
||||
dlsym(RTLD_DEFAULT, "mac_plugin_interposing_child_OnSetThemeCursor");
|
||||
}
|
||||
if (!OnSetCursorPtr) {
|
||||
// mac_plugin_interposing_child_OnSetCursor(const Cursor* cursor) is in
|
||||
// PluginInterposeOSX.mm
|
||||
OnSetCursorPtr = (BOOL(*)(const Cursor*))
|
||||
dlsym(RTLD_DEFAULT, "mac_plugin_interposing_child_OnSetCursor");
|
||||
}
|
||||
if (!OnHideCursorPtr) {
|
||||
// mac_plugin_interposing_child_OnHideCursor() is in PluginInterposeOSX.mm
|
||||
OnHideCursorPtr = (BOOL(*)())
|
||||
dlsym(RTLD_DEFAULT, "mac_plugin_interposing_child_OnHideCursor");
|
||||
}
|
||||
if (!OnShowCursorPtr) {
|
||||
// mac_plugin_interposing_child_OnShowCursor() is in PluginInterposeOSX.mm
|
||||
OnShowCursorPtr = (BOOL(*)())
|
||||
dlsym(RTLD_DEFAULT, "mac_plugin_interposing_child_OnShowCursor");
|
||||
}
|
||||
return (OnSetCursorPtr && OnSetThemeCursorPtr && OnHideCursorPtr && OnShowCursorPtr);
|
||||
}
|
||||
|
||||
static OSStatus MacPluginChildSetThemeCursor(ThemeCursor cursor)
|
||||
{
|
||||
if (loadXULPtrs()) {
|
||||
OnSetThemeCursorPtr(cursor);
|
||||
}
|
||||
return ::SetThemeCursor(cursor);
|
||||
}
|
||||
|
||||
static void MacPluginChildSetCursor(const Cursor* cursor)
|
||||
{
|
||||
if (::SetCursor) {
|
||||
if (loadXULPtrs()) {
|
||||
OnSetCursorPtr(cursor);
|
||||
}
|
||||
::SetCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static CGError MacPluginChildCGDisplayHideCursor(CGDirectDisplayID display)
|
||||
{
|
||||
if (loadXULPtrs()) {
|
||||
OnHideCursorPtr();
|
||||
}
|
||||
return ::CGDisplayHideCursor(display);
|
||||
}
|
||||
|
||||
static CGError MacPluginChildCGDisplayShowCursor(CGDirectDisplayID display)
|
||||
{
|
||||
if (loadXULPtrs()) {
|
||||
OnShowCursorPtr();
|
||||
}
|
||||
return ::CGDisplayShowCursor(display);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
struct interpose_substitution {
|
||||
const void* replacement;
|
||||
const void* original;
|
||||
};
|
||||
|
||||
#define INTERPOSE_FUNCTION(function) \
|
||||
{ reinterpret_cast<const void*>(MacPluginChild##function), \
|
||||
reinterpret_cast<const void*>(function) }
|
||||
|
||||
__attribute__((used)) static const interpose_substitution substitutions[]
|
||||
__attribute__((section("__DATA, __interpose"))) = {
|
||||
INTERPOSE_FUNCTION(SetThemeCursor),
|
||||
INTERPOSE_FUNCTION(CGDisplayHideCursor),
|
||||
INTERPOSE_FUNCTION(CGDisplayShowCursor),
|
||||
// SetCursor() and other QuickDraw APIs will probably be removed in OS X
|
||||
// 10.8. But this will make 'SetCursor' NULL, which will just stop the OS
|
||||
// from interposing it (tested using an INTERPOSE_FUNCTION_BROKEN macro
|
||||
// that just sets the second address of each tuple to NULL).
|
||||
INTERPOSE_FUNCTION(SetCursor),
|
||||
};
|
||||
|
||||
#endif // !__LP64__
|
||||
|
|
@ -3,9 +3,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'] == 'cocoa':
|
||||
DIRS += ['interpose']
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'PluginLibrary.h',
|
||||
]
|
||||
|
|
@ -16,7 +13,6 @@ EXPORTS.mozilla.plugins += [
|
|||
'BrowserStreamParent.h',
|
||||
'ChildAsyncCall.h',
|
||||
'ChildTimer.h',
|
||||
'NPEventOSX.h',
|
||||
'NPEventUnix.h',
|
||||
'NPEventWindows.h',
|
||||
'PluginAsyncSurrogate.h',
|
||||
|
|
@ -36,7 +32,6 @@ EXPORTS.mozilla.plugins += [
|
|||
'PluginScriptableObjectUtils.h',
|
||||
'PluginStreamChild.h',
|
||||
'PluginStreamParent.h',
|
||||
'PluginUtilsOSX.h',
|
||||
'PluginWidgetChild.h',
|
||||
'PluginWidgetParent.h',
|
||||
'StreamNotifyChild.h',
|
||||
|
|
@ -58,11 +53,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
|
|||
'hangui',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
EXPORTS.mozilla.plugins += [
|
||||
'PluginInterposeOSX.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'BrowserStreamChild.cpp',
|
||||
'BrowserStreamParent.cpp',
|
||||
|
|
@ -86,12 +76,6 @@ SOURCES += [
|
|||
'PluginWidgetParent.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
SOURCES += [
|
||||
'PluginInterposeOSX.mm',
|
||||
'PluginUtilsOSX.mm',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
SOURCES += [
|
||||
'D3D11SurfaceHolder.cpp',
|
||||
|
|
|
|||
|
|
@ -29,10 +29,6 @@
|
|||
#include <linux/fadvise.h>
|
||||
#endif // defined(XP_LINUX)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include "copyfile.h"
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include <windows.h>
|
||||
#include <accctrl.h>
|
||||
|
|
@ -131,22 +127,6 @@ struct Paths {
|
|||
nsString winStartMenuProgsDir;
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
/**
|
||||
* The user's Library directory.
|
||||
*/
|
||||
nsString macUserLibDir;
|
||||
/**
|
||||
* The Application directory, that stores applications installed in the
|
||||
* system.
|
||||
*/
|
||||
nsString macLocalApplicationsDir;
|
||||
/**
|
||||
* The user's trash directory.
|
||||
*/
|
||||
nsString macTrashDir;
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
Paths()
|
||||
{
|
||||
libDir.SetIsVoid(true);
|
||||
|
|
@ -161,12 +141,6 @@ struct Paths {
|
|||
winAppDataDir.SetIsVoid(true);
|
||||
winStartMenuProgsDir.SetIsVoid(true);
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
macUserLibDir.SetIsVoid(true);
|
||||
macLocalApplicationsDir.SetIsVoid(true);
|
||||
macTrashDir.SetIsVoid(true);
|
||||
#endif // defined(XP_MACOSX)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -311,12 +285,6 @@ nsresult InitOSFileConstants()
|
|||
GetPathToSpecialDir(NS_WIN_PROGRAMS_DIR, paths->winStartMenuProgsDir);
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
GetPathToSpecialDir(NS_MAC_USER_LIB_DIR, paths->macUserLibDir);
|
||||
GetPathToSpecialDir(NS_OSX_LOCAL_APPLICATIONS_DIR, paths->macLocalApplicationsDir);
|
||||
GetPathToSpecialDir(NS_MAC_TRASH_DIR, paths->macTrashDir);
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
gPaths = paths.forget();
|
||||
|
||||
// Get the umask from the system-info service.
|
||||
|
|
@ -972,20 +940,12 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
|||
// Note that we don't actually provide the full path, only the name of the
|
||||
// library, which is sufficient to link to the library using js-ctypes.
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// Under MacOS X, for some reason, libxul is called simply "XUL",
|
||||
// and we need to provide the full path.
|
||||
nsAutoString libxul;
|
||||
libxul.Append(gPaths->libDir);
|
||||
libxul.AppendLiteral("/XUL");
|
||||
#else
|
||||
// On other platforms, libxul is a library "xul" with regular
|
||||
// On all supported platforms, libxul is a library "xul" with regular
|
||||
// library prefix/suffix.
|
||||
nsAutoString libxul;
|
||||
libxul.AppendLiteral(DLL_PREFIX);
|
||||
libxul.AppendLiteral("xul");
|
||||
libxul.AppendLiteral(DLL_SUFFIX);
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
if (!SetStringProperty(cx, objPath, "libxul", libxul)) {
|
||||
return false;
|
||||
|
|
@ -1033,20 +993,6 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
|||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
if (!SetStringProperty(cx, objPath, "macUserLibDir", gPaths->macUserLibDir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetStringProperty(cx, objPath, "macLocalApplicationsDir", gPaths->macLocalApplicationsDir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetStringProperty(cx, objPath, "macTrashDir", gPaths->macTrashDir)) {
|
||||
return false;
|
||||
}
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
// sqlite3 is always a shared lib
|
||||
nsAutoString libsqlite3;
|
||||
libsqlite3.AppendLiteral(DLL_PREFIX);
|
||||
|
|
|
|||
|
|
@ -167,13 +167,8 @@ nsXBLPrototypeHandler::InitAccessKeys()
|
|||
return;
|
||||
}
|
||||
|
||||
// Compiled-in defaults, in case we can't get the pref --
|
||||
// mac doesn't have menu shortcuts, other platforms use alt.
|
||||
#ifdef XP_MACOSX
|
||||
kMenuAccessKey = 0;
|
||||
#else
|
||||
// Compiled-in defaults, in case we can't get the pref
|
||||
kMenuAccessKey = nsIDOMKeyEvent::DOM_VK_ALT;
|
||||
#endif
|
||||
|
||||
// Get the menu access key value from prefs, overriding the default:
|
||||
kMenuAccessKey =
|
||||
|
|
|
|||
|
|
@ -523,18 +523,6 @@ nsXULElement::IsFocusableInternal(int32_t *aTabIndex, bool aWithMouse)
|
|||
// elements are not focusable by default
|
||||
bool shouldFocus = false;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// on Mac, mouse interactions only focus the element if it's a list,
|
||||
// or if it's a remote target, since the remote target must handle
|
||||
// the focus.
|
||||
if (aWithMouse &&
|
||||
IsNonList(mNodeInfo) &&
|
||||
!EventStateManager::IsRemoteTarget(this))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl = do_QueryObject(this);
|
||||
if (xulControl) {
|
||||
// a disabled element cannot be focused and is not part of the tab order
|
||||
|
|
|
|||
|
|
@ -1481,11 +1481,6 @@ public:
|
|||
static already_AddRefed<DrawTarget> CreateDrawTargetWithSkCanvas(SkCanvas* aCanvas);
|
||||
#endif
|
||||
|
||||
#ifdef XP_DARWIN
|
||||
static already_AddRefed<GlyphRenderingOptions>
|
||||
CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
static already_AddRefed<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,6 @@
|
|||
#include "NativeFontResourceGDI.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_DARWIN
|
||||
#include "ScaledFontMac.h"
|
||||
#include "NativeFontResourceMac.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include "ScaledFontFontconfig.h"
|
||||
#endif
|
||||
|
|
@ -265,15 +260,6 @@ Factory::CheckSurfaceSize(const IntSize &sz,
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// CoreGraphics is limited to images < 32K in *height*,
|
||||
// so clamp all surfaces on the Mac to that height
|
||||
if (sz.height > SHRT_MAX) {
|
||||
gfxDebug() << "Surface size too large (exceeds CoreGraphics limit)!";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// assuming 4 bytes per pixel, make sure the allocation size
|
||||
// doesn't overflow a int32_t either
|
||||
CheckedInt<int32_t> stride = GetAlignedStride<16>(sz.width, 4);
|
||||
|
|
@ -481,12 +467,6 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef XP_DARWIN
|
||||
case NativeFontType::MAC_FONT_FACE:
|
||||
{
|
||||
return MakeAndAddRef<ScaledFontMac>(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE)
|
||||
case NativeFontType::CAIRO_FONT_FACE:
|
||||
{
|
||||
|
|
@ -524,8 +504,6 @@ Factory::CreateNativeFontResource(uint8_t *aData, uint32_t aSize,
|
|||
return NativeFontResourceGDI::Create(aData, aSize,
|
||||
/* aNeedsCairo = */ true);
|
||||
}
|
||||
#elif XP_DARWIN
|
||||
return NativeFontResourceMac::Create(aData, aSize);
|
||||
#else
|
||||
gfxWarning() << "Unable to create cairo scaled font from truetype data";
|
||||
return nullptr;
|
||||
|
|
@ -802,14 +780,6 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData,
|
|||
return newSurf.forget();
|
||||
}
|
||||
|
||||
#ifdef XP_DARWIN
|
||||
already_AddRefed<GlyphRenderingOptions>
|
||||
Factory::CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor)
|
||||
{
|
||||
return MakeAndAddRef<GlyphRenderingOptionsCG>(aFontSmoothingBackgroundColor);
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<DataSourceSurface>
|
||||
Factory::CreateDataSourceSurface(const IntSize &aSize,
|
||||
SurfaceFormat aFormat,
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ public:
|
|||
// XXX - temporarily disabled, see bug 1209039
|
||||
//
|
||||
// // Call this from the thread itself because of Mac.
|
||||
//#ifdef XP_MACOSX
|
||||
// pthread_setname_np(aName);
|
||||
//#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
//#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
// pthread_set_name_np(mThread, aName);
|
||||
//#elif defined(__NetBSD__)
|
||||
// pthread_setname_np(mThread, "%s", (void*)aName);
|
||||
|
|
|
|||
|
|
@ -1,615 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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 "MacIOSurface.h"
|
||||
#include <OpenGL/gl.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
#include <dlfcn.h>
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "GLConsts.h"
|
||||
|
||||
using namespace mozilla;
|
||||
// IOSurface signatures
|
||||
#define IOSURFACE_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/IOSurface.framework/IOSurface"
|
||||
#define OPENGL_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/OpenGL.framework/OpenGL"
|
||||
#define COREGRAPHICS_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/" \
|
||||
"CoreGraphics.framework/CoreGraphics"
|
||||
#define COREVIDEO_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/" \
|
||||
"CoreVideo.framework/CoreVideo"
|
||||
|
||||
#define GET_CONST(const_name) \
|
||||
((CFStringRef*) dlsym(sIOSurfaceFramework, const_name))
|
||||
#define GET_IOSYM(dest,sym_name) \
|
||||
(typeof(dest)) dlsym(sIOSurfaceFramework, sym_name)
|
||||
#define GET_CGLSYM(dest,sym_name) \
|
||||
(typeof(dest)) dlsym(sOpenGLFramework, sym_name)
|
||||
#define GET_CGSYM(dest,sym_name) \
|
||||
(typeof(dest)) dlsym(sCoreGraphicsFramework, sym_name)
|
||||
#define GET_CVSYM(dest, sym_name) \
|
||||
(typeof(dest)) dlsym(sCoreVideoFramework, sym_name)
|
||||
|
||||
MacIOSurfaceLib::LibraryUnloader MacIOSurfaceLib::sLibraryUnloader;
|
||||
bool MacIOSurfaceLib::isLoaded = false;
|
||||
void* MacIOSurfaceLib::sIOSurfaceFramework;
|
||||
void* MacIOSurfaceLib::sOpenGLFramework;
|
||||
void* MacIOSurfaceLib::sCoreGraphicsFramework;
|
||||
void* MacIOSurfaceLib::sCoreVideoFramework;
|
||||
IOSurfaceCreateFunc MacIOSurfaceLib::sCreate;
|
||||
IOSurfaceGetIDFunc MacIOSurfaceLib::sGetID;
|
||||
IOSurfaceLookupFunc MacIOSurfaceLib::sLookup;
|
||||
IOSurfaceGetBaseAddressFunc MacIOSurfaceLib::sGetBaseAddress;
|
||||
IOSurfaceGetBaseAddressOfPlaneFunc MacIOSurfaceLib::sGetBaseAddressOfPlane;
|
||||
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sWidth;
|
||||
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sHeight;
|
||||
IOSurfaceSizeTFunc MacIOSurfaceLib::sPlaneCount;
|
||||
IOSurfaceSizePlaneTFunc MacIOSurfaceLib::sBytesPerRow;
|
||||
IOSurfaceGetPropertyMaximumFunc MacIOSurfaceLib::sGetPropertyMaximum;
|
||||
IOSurfaceVoidFunc MacIOSurfaceLib::sIncrementUseCount;
|
||||
IOSurfaceVoidFunc MacIOSurfaceLib::sDecrementUseCount;
|
||||
IOSurfaceLockFunc MacIOSurfaceLib::sLock;
|
||||
IOSurfaceUnlockFunc MacIOSurfaceLib::sUnlock;
|
||||
CGLTexImageIOSurface2DFunc MacIOSurfaceLib::sTexImage;
|
||||
IOSurfaceContextCreateFunc MacIOSurfaceLib::sIOSurfaceContextCreate;
|
||||
IOSurfaceContextCreateImageFunc MacIOSurfaceLib::sIOSurfaceContextCreateImage;
|
||||
IOSurfaceContextGetSurfaceFunc MacIOSurfaceLib::sIOSurfaceContextGetSurface;
|
||||
CVPixelBufferGetIOSurfaceFunc MacIOSurfaceLib::sCVPixelBufferGetIOSurface;
|
||||
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
|
||||
IOSurfacePixelFormatFunc MacIOSurfaceLib::sPixelFormat;
|
||||
|
||||
CFStringRef MacIOSurfaceLib::kPropWidth;
|
||||
CFStringRef MacIOSurfaceLib::kPropHeight;
|
||||
CFStringRef MacIOSurfaceLib::kPropBytesPerElem;
|
||||
CFStringRef MacIOSurfaceLib::kPropBytesPerRow;
|
||||
CFStringRef MacIOSurfaceLib::kPropIsGlobal;
|
||||
|
||||
bool MacIOSurfaceLib::isInit() {
|
||||
// Guard against trying to reload the library
|
||||
// if it is not available.
|
||||
if (!isLoaded)
|
||||
LoadLibrary();
|
||||
MOZ_ASSERT(sIOSurfaceFramework);
|
||||
return sIOSurfaceFramework;
|
||||
}
|
||||
|
||||
IOSurfacePtr MacIOSurfaceLib::IOSurfaceCreate(CFDictionaryRef properties) {
|
||||
return sCreate(properties);
|
||||
}
|
||||
|
||||
IOSurfacePtr MacIOSurfaceLib::IOSurfaceLookup(IOSurfaceID aIOSurfaceID) {
|
||||
return sLookup(aIOSurfaceID);
|
||||
}
|
||||
|
||||
IOSurfaceID MacIOSurfaceLib::IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr) {
|
||||
return sGetID(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
void* MacIOSurfaceLib::IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr) {
|
||||
return sGetBaseAddress(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
void* MacIOSurfaceLib::IOSurfaceGetBaseAddressOfPlane(IOSurfacePtr aIOSurfacePtr,
|
||||
size_t planeIndex) {
|
||||
return sGetBaseAddressOfPlane(aIOSurfacePtr, planeIndex);
|
||||
}
|
||||
|
||||
size_t MacIOSurfaceLib::IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr) {
|
||||
return sPlaneCount(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr, size_t plane) {
|
||||
return sWidth(aIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr, size_t plane) {
|
||||
return sHeight(aIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr, size_t plane) {
|
||||
return sBytesPerRow(aIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(CFStringRef property) {
|
||||
return sGetPropertyMaximum(property);
|
||||
}
|
||||
|
||||
OSType MacIOSurfaceLib::IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr) {
|
||||
return sPixelFormat(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
IOReturn MacIOSurfaceLib::IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
|
||||
uint32_t options, uint32_t* seed) {
|
||||
return sLock(aIOSurfacePtr, options, seed);
|
||||
}
|
||||
|
||||
IOReturn MacIOSurfaceLib::IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
|
||||
uint32_t options, uint32_t *seed) {
|
||||
return sUnlock(aIOSurfacePtr, options, seed);
|
||||
}
|
||||
|
||||
void MacIOSurfaceLib::IOSurfaceIncrementUseCount(IOSurfacePtr aIOSurfacePtr) {
|
||||
sIncrementUseCount(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
void MacIOSurfaceLib::IOSurfaceDecrementUseCount(IOSurfacePtr aIOSurfacePtr) {
|
||||
sDecrementUseCount(aIOSurfacePtr);
|
||||
}
|
||||
|
||||
CGLError MacIOSurfaceLib::CGLTexImageIOSurface2D(CGLContextObj ctxt,
|
||||
GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
IOSurfacePtr ioSurface, GLuint plane) {
|
||||
return sTexImage(ctxt, target, internalFormat, width, height,
|
||||
format, type, ioSurface, plane);
|
||||
}
|
||||
|
||||
IOSurfacePtr MacIOSurfaceLib::CVPixelBufferGetIOSurface(CVPixelBufferRef aPixelBuffer) {
|
||||
return sCVPixelBufferGetIOSurface(aPixelBuffer);
|
||||
}
|
||||
|
||||
CGContextRef MacIOSurfaceLib::IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
|
||||
unsigned aWidth, unsigned aHeight,
|
||||
unsigned aBitsPerComponent, unsigned aBytes,
|
||||
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo) {
|
||||
if (!sIOSurfaceContextCreate)
|
||||
return nullptr;
|
||||
return sIOSurfaceContextCreate(aIOSurfacePtr, aWidth, aHeight, aBitsPerComponent, aBytes, aColorSpace, bitmapInfo);
|
||||
}
|
||||
|
||||
CGImageRef MacIOSurfaceLib::IOSurfaceContextCreateImage(CGContextRef aContext) {
|
||||
if (!sIOSurfaceContextCreateImage)
|
||||
return nullptr;
|
||||
return sIOSurfaceContextCreateImage(aContext);
|
||||
}
|
||||
|
||||
IOSurfacePtr MacIOSurfaceLib::IOSurfaceContextGetSurface(CGContextRef aContext) {
|
||||
if (!sIOSurfaceContextGetSurface)
|
||||
return nullptr;
|
||||
return sIOSurfaceContextGetSurface(aContext);
|
||||
}
|
||||
|
||||
CFStringRef MacIOSurfaceLib::GetIOConst(const char* symbole) {
|
||||
CFStringRef *address = (CFStringRef*)dlsym(sIOSurfaceFramework, symbole);
|
||||
if (!address)
|
||||
return nullptr;
|
||||
|
||||
return *address;
|
||||
}
|
||||
|
||||
void MacIOSurfaceLib::LoadLibrary() {
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
isLoaded = true;
|
||||
sIOSurfaceFramework = dlopen(IOSURFACE_FRAMEWORK_PATH,
|
||||
RTLD_LAZY | RTLD_LOCAL);
|
||||
sOpenGLFramework = dlopen(OPENGL_FRAMEWORK_PATH,
|
||||
RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
sCoreGraphicsFramework = dlopen(COREGRAPHICS_FRAMEWORK_PATH,
|
||||
RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
sCoreVideoFramework = dlopen(COREVIDEO_FRAMEWORK_PATH,
|
||||
RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (!sIOSurfaceFramework || !sOpenGLFramework || !sCoreGraphicsFramework ||
|
||||
!sCoreVideoFramework) {
|
||||
if (sIOSurfaceFramework)
|
||||
dlclose(sIOSurfaceFramework);
|
||||
if (sOpenGLFramework)
|
||||
dlclose(sOpenGLFramework);
|
||||
if (sCoreGraphicsFramework)
|
||||
dlclose(sCoreGraphicsFramework);
|
||||
if (sCoreVideoFramework)
|
||||
dlclose(sCoreVideoFramework);
|
||||
sIOSurfaceFramework = nullptr;
|
||||
sOpenGLFramework = nullptr;
|
||||
sCoreGraphicsFramework = nullptr;
|
||||
sCoreVideoFramework = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
kPropWidth = GetIOConst("kIOSurfaceWidth");
|
||||
kPropHeight = GetIOConst("kIOSurfaceHeight");
|
||||
kPropBytesPerElem = GetIOConst("kIOSurfaceBytesPerElement");
|
||||
kPropBytesPerRow = GetIOConst("kIOSurfaceBytesPerRow");
|
||||
kPropIsGlobal = GetIOConst("kIOSurfaceIsGlobal");
|
||||
sCreate = GET_IOSYM(sCreate, "IOSurfaceCreate");
|
||||
sGetID = GET_IOSYM(sGetID, "IOSurfaceGetID");
|
||||
sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidthOfPlane");
|
||||
sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeightOfPlane");
|
||||
sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRowOfPlane");
|
||||
sGetPropertyMaximum = GET_IOSYM(sGetPropertyMaximum, "IOSurfaceGetPropertyMaximum");
|
||||
sLookup = GET_IOSYM(sLookup, "IOSurfaceLookup");
|
||||
sLock = GET_IOSYM(sLock, "IOSurfaceLock");
|
||||
sUnlock = GET_IOSYM(sUnlock, "IOSurfaceUnlock");
|
||||
sIncrementUseCount =
|
||||
GET_IOSYM(sIncrementUseCount, "IOSurfaceIncrementUseCount");
|
||||
sDecrementUseCount =
|
||||
GET_IOSYM(sDecrementUseCount, "IOSurfaceDecrementUseCount");
|
||||
sGetBaseAddress = GET_IOSYM(sGetBaseAddress, "IOSurfaceGetBaseAddress");
|
||||
sGetBaseAddressOfPlane =
|
||||
GET_IOSYM(sGetBaseAddressOfPlane, "IOSurfaceGetBaseAddressOfPlane");
|
||||
sPlaneCount = GET_IOSYM(sPlaneCount, "IOSurfaceGetPlaneCount");
|
||||
sPixelFormat = GET_IOSYM(sPixelFormat, "IOSurfaceGetPixelFormat");
|
||||
|
||||
sTexImage = GET_CGLSYM(sTexImage, "CGLTexImageIOSurface2D");
|
||||
sCGContextGetTypePtr = (unsigned int (*)(CGContext*))dlsym(RTLD_DEFAULT, "CGContextGetType");
|
||||
|
||||
sCVPixelBufferGetIOSurface =
|
||||
GET_CVSYM(sCVPixelBufferGetIOSurface, "CVPixelBufferGetIOSurface");
|
||||
|
||||
// Optional symbols
|
||||
sIOSurfaceContextCreate = GET_CGSYM(sIOSurfaceContextCreate, "CGIOSurfaceContextCreate");
|
||||
sIOSurfaceContextCreateImage = GET_CGSYM(sIOSurfaceContextCreateImage, "CGIOSurfaceContextCreateImage");
|
||||
sIOSurfaceContextGetSurface = GET_CGSYM(sIOSurfaceContextGetSurface, "CGIOSurfaceContextGetSurface");
|
||||
|
||||
if (!sCreate || !sGetID || !sLookup || !sTexImage || !sGetBaseAddress ||
|
||||
!sGetBaseAddressOfPlane || !sPlaneCount ||
|
||||
!kPropWidth || !kPropHeight || !kPropBytesPerElem || !kPropIsGlobal ||
|
||||
!sLock || !sUnlock || !sIncrementUseCount || !sDecrementUseCount ||
|
||||
!sWidth || !sHeight || !kPropBytesPerRow ||
|
||||
!sBytesPerRow || !sGetPropertyMaximum || !sCVPixelBufferGetIOSurface) {
|
||||
CloseLibrary();
|
||||
}
|
||||
}
|
||||
|
||||
void MacIOSurfaceLib::CloseLibrary() {
|
||||
if (sIOSurfaceFramework) {
|
||||
dlclose(sIOSurfaceFramework);
|
||||
}
|
||||
if (sOpenGLFramework) {
|
||||
dlclose(sOpenGLFramework);
|
||||
}
|
||||
if (sCoreVideoFramework) {
|
||||
dlclose(sCoreVideoFramework);
|
||||
}
|
||||
sIOSurfaceFramework = nullptr;
|
||||
sOpenGLFramework = nullptr;
|
||||
sCoreVideoFramework = nullptr;
|
||||
}
|
||||
|
||||
MacIOSurface::MacIOSurface(const void* aIOSurfacePtr,
|
||||
double aContentsScaleFactor, bool aHasAlpha)
|
||||
: mIOSurfacePtr(aIOSurfacePtr)
|
||||
, mContentsScaleFactor(aContentsScaleFactor)
|
||||
, mHasAlpha(aHasAlpha)
|
||||
{
|
||||
CFRetain(mIOSurfacePtr);
|
||||
IncrementUseCount();
|
||||
}
|
||||
|
||||
MacIOSurface::~MacIOSurface() {
|
||||
DecrementUseCount();
|
||||
CFRelease(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight,
|
||||
double aContentsScaleFactor,
|
||||
bool aHasAlpha) {
|
||||
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
|
||||
return nullptr;
|
||||
|
||||
CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
|
||||
kCFAllocatorDefault, 4,
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
if (!props)
|
||||
return nullptr;
|
||||
|
||||
MOZ_ASSERT((size_t)aWidth <= GetMaxWidth());
|
||||
MOZ_ASSERT((size_t)aHeight <= GetMaxHeight());
|
||||
|
||||
int32_t bytesPerElem = 4;
|
||||
size_t intScaleFactor = ceil(aContentsScaleFactor);
|
||||
aWidth *= intScaleFactor;
|
||||
aHeight *= intScaleFactor;
|
||||
CFNumberRef cfWidth = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aWidth);
|
||||
CFNumberRef cfHeight = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aHeight);
|
||||
CFNumberRef cfBytesPerElem = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &bytesPerElem);
|
||||
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropWidth,
|
||||
cfWidth);
|
||||
::CFRelease(cfWidth);
|
||||
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropHeight,
|
||||
cfHeight);
|
||||
::CFRelease(cfHeight);
|
||||
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropBytesPerElem,
|
||||
cfBytesPerElem);
|
||||
::CFRelease(cfBytesPerElem);
|
||||
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropIsGlobal,
|
||||
kCFBooleanTrue);
|
||||
|
||||
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceCreate(props);
|
||||
::CFRelease(props);
|
||||
|
||||
if (!surfaceRef)
|
||||
return nullptr;
|
||||
|
||||
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
|
||||
if (!ioSurface) {
|
||||
::CFRelease(surfaceRef);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Release the IOSurface because MacIOSurface retained it
|
||||
CFRelease(surfaceRef);
|
||||
|
||||
return ioSurface.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID,
|
||||
double aContentsScaleFactor,
|
||||
bool aHasAlpha) {
|
||||
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
|
||||
return nullptr;
|
||||
|
||||
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
|
||||
if (!surfaceRef)
|
||||
return nullptr;
|
||||
|
||||
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
|
||||
if (!ioSurface) {
|
||||
::CFRelease(surfaceRef);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Release the IOSurface because MacIOSurface retained it
|
||||
CFRelease(surfaceRef);
|
||||
|
||||
return ioSurface.forget();
|
||||
}
|
||||
|
||||
IOSurfaceID MacIOSurface::GetIOSurfaceID() {
|
||||
return MacIOSurfaceLib::IOSurfaceGetID(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
void* MacIOSurface::GetBaseAddress() {
|
||||
return MacIOSurfaceLib::IOSurfaceGetBaseAddress(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex)
|
||||
{
|
||||
return MacIOSurfaceLib::IOSurfaceGetBaseAddressOfPlane(mIOSurfacePtr,
|
||||
aPlaneIndex);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetWidth(size_t plane) {
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
return GetDevicePixelWidth(plane) / intScaleFactor;
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetHeight(size_t plane) {
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
return GetDevicePixelHeight(plane) / intScaleFactor;
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetPlaneCount() {
|
||||
return MacIOSurfaceLib::IOSurfaceGetPlaneCount(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
/*static*/ size_t MacIOSurface::GetMaxWidth() {
|
||||
if (!MacIOSurfaceLib::isInit())
|
||||
return -1;
|
||||
return MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(MacIOSurfaceLib::kPropWidth);
|
||||
}
|
||||
|
||||
/*static*/ size_t MacIOSurface::GetMaxHeight() {
|
||||
if (!MacIOSurfaceLib::isInit())
|
||||
return -1;
|
||||
return MacIOSurfaceLib::IOSurfaceGetPropertyMaximum(MacIOSurfaceLib::kPropHeight);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetDevicePixelWidth(size_t plane) {
|
||||
return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetDevicePixelHeight(size_t plane) {
|
||||
return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
size_t MacIOSurface::GetBytesPerRow(size_t plane) {
|
||||
return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr, plane);
|
||||
}
|
||||
|
||||
OSType MacIOSurface::GetPixelFormat() {
|
||||
return MacIOSurfaceLib::IOSurfaceGetPixelFormat(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
void MacIOSurface::IncrementUseCount() {
|
||||
MacIOSurfaceLib::IOSurfaceIncrementUseCount(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
void MacIOSurface::DecrementUseCount() {
|
||||
MacIOSurfaceLib::IOSurfaceDecrementUseCount(mIOSurfacePtr);
|
||||
}
|
||||
|
||||
#define READ_ONLY 0x1
|
||||
void MacIOSurface::Lock(bool aReadOnly) {
|
||||
MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, aReadOnly ? READ_ONLY : 0, nullptr);
|
||||
}
|
||||
|
||||
void MacIOSurface::Unlock(bool aReadOnly) {
|
||||
MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, aReadOnly ? READ_ONLY : 0, nullptr);
|
||||
}
|
||||
|
||||
using mozilla::gfx::SourceSurface;
|
||||
using mozilla::gfx::IntSize;
|
||||
using mozilla::gfx::SurfaceFormat;
|
||||
|
||||
void
|
||||
MacIOSurfaceBufferDeallocator(void* aClosure)
|
||||
{
|
||||
MOZ_ASSERT(aClosure);
|
||||
|
||||
delete [] static_cast<unsigned char*>(aClosure);
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
MacIOSurface::GetAsSurface() {
|
||||
Lock();
|
||||
size_t bytesPerRow = GetBytesPerRow();
|
||||
size_t ioWidth = GetDevicePixelWidth();
|
||||
size_t ioHeight = GetDevicePixelHeight();
|
||||
|
||||
unsigned char* ioData = (unsigned char*)GetBaseAddress();
|
||||
unsigned char* dataCpy =
|
||||
new unsigned char[bytesPerRow * ioHeight / sizeof(unsigned char)];
|
||||
for (size_t i = 0; i < ioHeight; i++) {
|
||||
memcpy(dataCpy + i * bytesPerRow,
|
||||
ioData + i * bytesPerRow, ioWidth * 4);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
|
||||
SurfaceFormat format = HasAlpha() ? mozilla::gfx::SurfaceFormat::B8G8R8A8 :
|
||||
mozilla::gfx::SurfaceFormat::B8G8R8X8;
|
||||
|
||||
RefPtr<mozilla::gfx::DataSourceSurface> surf =
|
||||
mozilla::gfx::Factory::CreateWrappingDataSourceSurface(dataCpy,
|
||||
bytesPerRow,
|
||||
IntSize(ioWidth, ioHeight),
|
||||
format,
|
||||
&MacIOSurfaceBufferDeallocator,
|
||||
static_cast<void*>(dataCpy));
|
||||
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
SurfaceFormat
|
||||
MacIOSurface::GetFormat()
|
||||
{
|
||||
OSType pixelFormat = GetPixelFormat();
|
||||
if (pixelFormat == '420v') {
|
||||
return SurfaceFormat::NV12;
|
||||
} else if (pixelFormat == '2vuy') {
|
||||
return SurfaceFormat::YUV422;
|
||||
} else {
|
||||
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
||||
}
|
||||
}
|
||||
|
||||
SurfaceFormat
|
||||
MacIOSurface::GetReadFormat()
|
||||
{
|
||||
OSType pixelFormat = GetPixelFormat();
|
||||
if (pixelFormat == '420v') {
|
||||
return SurfaceFormat::NV12;
|
||||
} else if (pixelFormat == '2vuy') {
|
||||
return SurfaceFormat::R8G8B8X8;
|
||||
} else {
|
||||
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
|
||||
}
|
||||
}
|
||||
|
||||
CGLError
|
||||
MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx, size_t plane)
|
||||
{
|
||||
MOZ_ASSERT(plane >= 0);
|
||||
OSType pixelFormat = GetPixelFormat();
|
||||
|
||||
GLenum internalFormat;
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
if (pixelFormat == '420v') {
|
||||
MOZ_ASSERT(GetPlaneCount() == 2);
|
||||
MOZ_ASSERT(plane < 2);
|
||||
|
||||
if (plane == 0) {
|
||||
internalFormat = format = GL_LUMINANCE;
|
||||
} else {
|
||||
internalFormat = format = GL_LUMINANCE_ALPHA;
|
||||
}
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
} else if (pixelFormat == '2vuy') {
|
||||
MOZ_ASSERT(plane == 0);
|
||||
|
||||
internalFormat = GL_RGB;
|
||||
format = LOCAL_GL_YCBCR_422_APPLE;
|
||||
type = GL_UNSIGNED_SHORT_8_8_APPLE;
|
||||
} else {
|
||||
MOZ_ASSERT(plane == 0);
|
||||
|
||||
internalFormat = HasAlpha() ? GL_RGBA : GL_RGB;
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
CGLError temp = MacIOSurfaceLib::CGLTexImageIOSurface2D(ctx,
|
||||
GL_TEXTURE_RECTANGLE_ARB,
|
||||
internalFormat,
|
||||
GetDevicePixelWidth(plane),
|
||||
GetDevicePixelHeight(plane),
|
||||
format,
|
||||
type,
|
||||
mIOSurfacePtr, plane);
|
||||
return temp;
|
||||
}
|
||||
|
||||
static
|
||||
CGColorSpaceRef CreateSystemColorSpace() {
|
||||
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
|
||||
if (!cspace) {
|
||||
cspace = ::CGColorSpaceCreateDeviceRGB();
|
||||
}
|
||||
return cspace;
|
||||
}
|
||||
|
||||
CGContextRef MacIOSurface::CreateIOSurfaceContext() {
|
||||
CGColorSpaceRef cspace = CreateSystemColorSpace();
|
||||
CGContextRef ref = MacIOSurfaceLib::IOSurfaceContextCreate(mIOSurfacePtr,
|
||||
GetDevicePixelWidth(),
|
||||
GetDevicePixelHeight(),
|
||||
8, 32, cspace, 0x2002);
|
||||
::CGColorSpaceRelease(cspace);
|
||||
return ref;
|
||||
}
|
||||
|
||||
CGImageRef MacIOSurface::CreateImageFromIOSurfaceContext(CGContextRef aContext) {
|
||||
if (!MacIOSurfaceLib::isInit())
|
||||
return nullptr;
|
||||
|
||||
return MacIOSurfaceLib::IOSurfaceContextCreateImage(aContext);
|
||||
}
|
||||
|
||||
already_AddRefed<MacIOSurface> MacIOSurface::IOSurfaceContextGetSurface(CGContextRef aContext,
|
||||
double aContentsScaleFactor,
|
||||
bool aHasAlpha) {
|
||||
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
|
||||
return nullptr;
|
||||
|
||||
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceContextGetSurface(aContext);
|
||||
if (!surfaceRef)
|
||||
return nullptr;
|
||||
|
||||
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
|
||||
if (!ioSurface) {
|
||||
::CFRelease(surfaceRef);
|
||||
return nullptr;
|
||||
}
|
||||
return ioSurface.forget();
|
||||
}
|
||||
|
||||
|
||||
CGContextType GetContextType(CGContextRef ref)
|
||||
{
|
||||
if (!MacIOSurfaceLib::isInit() || !MacIOSurfaceLib::sCGContextGetTypePtr)
|
||||
return CG_CONTEXT_TYPE_UNKNOWN;
|
||||
|
||||
unsigned int type = MacIOSurfaceLib::sCGContextGetTypePtr(ref);
|
||||
if (type == CG_CONTEXT_TYPE_BITMAP) {
|
||||
return CG_CONTEXT_TYPE_BITMAP;
|
||||
} else if (type == CG_CONTEXT_TYPE_IOSURFACE) {
|
||||
return CG_CONTEXT_TYPE_IOSURFACE;
|
||||
} else {
|
||||
return CG_CONTEXT_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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 MacIOSurface_h__
|
||||
#define MacIOSurface_h__
|
||||
#ifdef XP_DARWIN
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
#include <CoreVideo/CoreVideo.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
struct _CGLContextObject;
|
||||
|
||||
typedef _CGLContextObject* CGLContextObj;
|
||||
typedef struct CGContext* CGContextRef;
|
||||
typedef struct CGImage* CGImageRef;
|
||||
typedef uint32_t IOSurfaceID;
|
||||
|
||||
#ifdef XP_IOS
|
||||
typedef kern_return_t IOReturn;
|
||||
typedef int CGLError;
|
||||
#endif
|
||||
|
||||
typedef CFTypeRef IOSurfacePtr;
|
||||
typedef IOSurfacePtr (*IOSurfaceCreateFunc) (CFDictionaryRef properties);
|
||||
typedef IOSurfacePtr (*IOSurfaceLookupFunc) (uint32_t io_surface_id);
|
||||
typedef IOSurfaceID (*IOSurfaceGetIDFunc)(IOSurfacePtr io_surface);
|
||||
typedef void (*IOSurfaceVoidFunc)(IOSurfacePtr io_surface);
|
||||
typedef IOReturn (*IOSurfaceLockFunc)(IOSurfacePtr io_surface, uint32_t options,
|
||||
uint32_t *seed);
|
||||
typedef IOReturn (*IOSurfaceUnlockFunc)(IOSurfacePtr io_surface,
|
||||
uint32_t options, uint32_t *seed);
|
||||
typedef void* (*IOSurfaceGetBaseAddressFunc)(IOSurfacePtr io_surface);
|
||||
typedef void* (*IOSurfaceGetBaseAddressOfPlaneFunc)(IOSurfacePtr io_surface,
|
||||
size_t planeIndex);
|
||||
typedef size_t (*IOSurfaceSizeTFunc)(IOSurfacePtr io_surface);
|
||||
typedef size_t (*IOSurfaceSizePlaneTFunc)(IOSurfacePtr io_surface, size_t plane);
|
||||
typedef size_t (*IOSurfaceGetPropertyMaximumFunc) (CFStringRef property);
|
||||
typedef CGLError (*CGLTexImageIOSurface2DFunc) (CGLContextObj ctxt,
|
||||
GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
IOSurfacePtr ioSurface, GLuint plane);
|
||||
typedef CGContextRef (*IOSurfaceContextCreateFunc)(CFTypeRef io_surface,
|
||||
unsigned width, unsigned height,
|
||||
unsigned bitsPerComponent, unsigned bytes,
|
||||
CGColorSpaceRef colorSpace, CGBitmapInfo bitmapInfo);
|
||||
typedef CGImageRef (*IOSurfaceContextCreateImageFunc)(CGContextRef ref);
|
||||
typedef IOSurfacePtr (*IOSurfaceContextGetSurfaceFunc)(CGContextRef ref);
|
||||
|
||||
typedef IOSurfacePtr (*CVPixelBufferGetIOSurfaceFunc)(
|
||||
CVPixelBufferRef pixelBuffer);
|
||||
|
||||
typedef OSType (*IOSurfacePixelFormatFunc)(IOSurfacePtr io_surface);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#import <OpenGL/OpenGL.h>
|
||||
#else
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#endif
|
||||
|
||||
#include "2D.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/RefCounted.h"
|
||||
|
||||
enum CGContextType {
|
||||
CG_CONTEXT_TYPE_UNKNOWN = 0,
|
||||
// These are found by inspection, it's possible they could be changed
|
||||
CG_CONTEXT_TYPE_BITMAP = 4,
|
||||
CG_CONTEXT_TYPE_IOSURFACE = 8
|
||||
};
|
||||
|
||||
CGContextType GetContextType(CGContextRef ref);
|
||||
|
||||
class MacIOSurface final : public mozilla::external::AtomicRefCounted<MacIOSurface> {
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(MacIOSurface)
|
||||
typedef mozilla::gfx::SourceSurface SourceSurface;
|
||||
|
||||
// The usage count of the IOSurface is increased by 1 during the lifetime
|
||||
// of the MacIOSurface instance.
|
||||
// MacIOSurface holds a reference to the corresponding IOSurface.
|
||||
|
||||
static already_AddRefed<MacIOSurface> CreateIOSurface(int aWidth, int aHeight,
|
||||
double aContentsScaleFactor = 1.0,
|
||||
bool aHasAlpha = true);
|
||||
static void ReleaseIOSurface(MacIOSurface *aIOSurface);
|
||||
static already_AddRefed<MacIOSurface> LookupSurface(IOSurfaceID aSurfaceID,
|
||||
double aContentsScaleFactor = 1.0,
|
||||
bool aHasAlpha = true);
|
||||
|
||||
explicit MacIOSurface(const void *aIOSurfacePtr,
|
||||
double aContentsScaleFactor = 1.0,
|
||||
bool aHasAlpha = true);
|
||||
~MacIOSurface();
|
||||
IOSurfaceID GetIOSurfaceID();
|
||||
void *GetBaseAddress();
|
||||
void *GetBaseAddressOfPlane(size_t planeIndex);
|
||||
size_t GetPlaneCount();
|
||||
OSType GetPixelFormat();
|
||||
// GetWidth() and GetHeight() return values in "display pixels". A
|
||||
// "display pixel" is the smallest fully addressable part of a display.
|
||||
// But in HiDPI modes each "display pixel" corresponds to more than one
|
||||
// device pixel. Use GetDevicePixel**() to get device pixels.
|
||||
size_t GetWidth(size_t plane = 0);
|
||||
size_t GetHeight(size_t plane = 0);
|
||||
double GetContentsScaleFactor() { return mContentsScaleFactor; }
|
||||
size_t GetDevicePixelWidth(size_t plane = 0);
|
||||
size_t GetDevicePixelHeight(size_t plane = 0);
|
||||
size_t GetBytesPerRow(size_t plane = 0);
|
||||
void Lock(bool aReadOnly = true);
|
||||
void Unlock(bool aReadOnly = true);
|
||||
void IncrementUseCount();
|
||||
void DecrementUseCount();
|
||||
bool HasAlpha() { return mHasAlpha; }
|
||||
mozilla::gfx::SurfaceFormat GetFormat();
|
||||
mozilla::gfx::SurfaceFormat GetReadFormat();
|
||||
|
||||
// We would like to forward declare NSOpenGLContext, but it is an @interface
|
||||
// and this file is also used from c++, so we use a void *.
|
||||
CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt, size_t plane = 0);
|
||||
already_AddRefed<SourceSurface> GetAsSurface();
|
||||
CGContextRef CreateIOSurfaceContext();
|
||||
|
||||
// FIXME This doesn't really belong here
|
||||
static CGImageRef CreateImageFromIOSurfaceContext(CGContextRef aContext);
|
||||
static already_AddRefed<MacIOSurface> IOSurfaceContextGetSurface(CGContextRef aContext,
|
||||
double aContentsScaleFactor = 1.0,
|
||||
bool aHasAlpha = true);
|
||||
static size_t GetMaxWidth();
|
||||
static size_t GetMaxHeight();
|
||||
|
||||
private:
|
||||
friend class nsCARenderer;
|
||||
const void* mIOSurfacePtr;
|
||||
double mContentsScaleFactor;
|
||||
bool mHasAlpha;
|
||||
};
|
||||
|
||||
class MacIOSurfaceLib {
|
||||
public:
|
||||
MacIOSurfaceLib() = delete;
|
||||
static void *sIOSurfaceFramework;
|
||||
static void *sOpenGLFramework;
|
||||
static void *sCoreGraphicsFramework;
|
||||
static void *sCoreVideoFramework;
|
||||
static bool isLoaded;
|
||||
static IOSurfaceCreateFunc sCreate;
|
||||
static IOSurfaceGetIDFunc sGetID;
|
||||
static IOSurfaceLookupFunc sLookup;
|
||||
static IOSurfaceGetBaseAddressFunc sGetBaseAddress;
|
||||
static IOSurfaceGetBaseAddressOfPlaneFunc sGetBaseAddressOfPlane;
|
||||
static IOSurfaceSizeTFunc sPlaneCount;
|
||||
static IOSurfaceLockFunc sLock;
|
||||
static IOSurfaceUnlockFunc sUnlock;
|
||||
static IOSurfaceVoidFunc sIncrementUseCount;
|
||||
static IOSurfaceVoidFunc sDecrementUseCount;
|
||||
static IOSurfaceSizePlaneTFunc sWidth;
|
||||
static IOSurfaceSizePlaneTFunc sHeight;
|
||||
static IOSurfaceSizePlaneTFunc sBytesPerRow;
|
||||
static IOSurfaceGetPropertyMaximumFunc sGetPropertyMaximum;
|
||||
static CGLTexImageIOSurface2DFunc sTexImage;
|
||||
static IOSurfaceContextCreateFunc sIOSurfaceContextCreate;
|
||||
static IOSurfaceContextCreateImageFunc sIOSurfaceContextCreateImage;
|
||||
static IOSurfaceContextGetSurfaceFunc sIOSurfaceContextGetSurface;
|
||||
static CVPixelBufferGetIOSurfaceFunc sCVPixelBufferGetIOSurface;
|
||||
static IOSurfacePixelFormatFunc sPixelFormat;
|
||||
static CFStringRef kPropWidth;
|
||||
static CFStringRef kPropHeight;
|
||||
static CFStringRef kPropBytesPerElem;
|
||||
static CFStringRef kPropBytesPerRow;
|
||||
static CFStringRef kPropIsGlobal;
|
||||
|
||||
static bool isInit();
|
||||
static CFStringRef GetIOConst(const char* symbole);
|
||||
static IOSurfacePtr IOSurfaceCreate(CFDictionaryRef properties);
|
||||
static IOSurfacePtr IOSurfaceLookup(IOSurfaceID aIOSurfaceID);
|
||||
static IOSurfaceID IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr);
|
||||
static void* IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr);
|
||||
static void* IOSurfaceGetBaseAddressOfPlane(IOSurfacePtr aIOSurfacePtr,
|
||||
size_t aPlaneIndex);
|
||||
static size_t IOSurfaceGetPlaneCount(IOSurfacePtr aIOSurfacePtr);
|
||||
static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr, size_t plane);
|
||||
static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr, size_t plane);
|
||||
static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr, size_t plane);
|
||||
static size_t IOSurfaceGetPropertyMaximum(CFStringRef property);
|
||||
static IOReturn IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
|
||||
uint32_t options, uint32_t *seed);
|
||||
static IOReturn IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
|
||||
uint32_t options, uint32_t *seed);
|
||||
static void IOSurfaceIncrementUseCount(IOSurfacePtr aIOSurfacePtr);
|
||||
static void IOSurfaceDecrementUseCount(IOSurfacePtr aIOSurfacePtr);
|
||||
static CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt,
|
||||
GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
IOSurfacePtr ioSurface, GLuint plane);
|
||||
static CGContextRef IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
|
||||
unsigned aWidth, unsigned aHeight,
|
||||
unsigned aBitsPerCompoent, unsigned aBytes,
|
||||
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo);
|
||||
static CGImageRef IOSurfaceContextCreateImage(CGContextRef ref);
|
||||
static IOSurfacePtr IOSurfaceContextGetSurface(CGContextRef ref);
|
||||
static IOSurfacePtr CVPixelBufferGetIOSurface(CVPixelBufferRef apixelBuffer);
|
||||
static OSType IOSurfaceGetPixelFormat(IOSurfacePtr aIOSurfacePtr);
|
||||
static unsigned int (*sCGContextGetTypePtr) (CGContextRef);
|
||||
static void LoadLibrary();
|
||||
static void CloseLibrary();
|
||||
|
||||
// Static deconstructor
|
||||
static class LibraryUnloader {
|
||||
public:
|
||||
~LibraryUnloader() {
|
||||
CloseLibrary();
|
||||
}
|
||||
} sLibraryUnloader;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; 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 "NativeFontResourceMac.h"
|
||||
#include "Types.h"
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_UIKIT
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
/* static */
|
||||
already_AddRefed<NativeFontResourceMac>
|
||||
NativeFontResourceMac::Create(uint8_t *aFontData, uint32_t aDataLength)
|
||||
{
|
||||
// copy font data
|
||||
CFDataRef data = CFDataCreate(kCFAllocatorDefault, aFontData, aDataLength);
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create a provider
|
||||
CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
|
||||
|
||||
// release our reference to the CFData, provider keeps it alive
|
||||
CFRelease(data);
|
||||
|
||||
// create the font object
|
||||
CGFontRef fontRef = CGFontCreateWithDataProvider(provider);
|
||||
|
||||
// release our reference, font will keep it alive as long as needed
|
||||
CGDataProviderRelease(provider);
|
||||
|
||||
if (!fontRef) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// passes ownership of fontRef to the NativeFontResourceMac instance
|
||||
RefPtr<NativeFontResourceMac> fontResource =
|
||||
new NativeFontResourceMac(fontRef);
|
||||
|
||||
return fontResource.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
NativeFontResourceMac::CreateScaledFont(uint32_t aIndex, Float aGlyphSize,
|
||||
const uint8_t* aInstanceData, uint32_t aInstanceDataLength)
|
||||
{
|
||||
RefPtr<ScaledFontBase> scaledFont = new ScaledFontMac(mFontRef, aGlyphSize);
|
||||
|
||||
if (!scaledFont->PopulateCairoScaledFont()) {
|
||||
gfxWarning() << "Unable to create cairo scaled Mac font.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
} // gfx
|
||||
} // mozilla
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; 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/. */
|
||||
|
||||
#ifndef mozilla_gfx_NativeFontResourceMac_h
|
||||
#define mozilla_gfx_NativeFontResourceMac_h
|
||||
|
||||
#include "2D.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "ScaledFontMac.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class NativeFontResourceMac final : public NativeFontResource
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceMac)
|
||||
|
||||
static already_AddRefed<NativeFontResourceMac>
|
||||
Create(uint8_t *aFontData, uint32_t aDataLength);
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
CreateScaledFont(uint32_t aIndex, Float aGlyphSize,
|
||||
const uint8_t* aInstanceData, uint32_t aInstanceDataLength) final;
|
||||
|
||||
~NativeFontResourceMac()
|
||||
{
|
||||
CFRelease(mFontRef);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit NativeFontResourceMac(CGFontRef aFontRef) : mFontRef(aFontRef) {}
|
||||
|
||||
CGFontRef mFontRef;
|
||||
};
|
||||
|
||||
} // gfx
|
||||
} // mozilla
|
||||
|
||||
#endif // mozilla_gfx_NativeFontResourceMac_h
|
||||
|
|
@ -1,435 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; 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 "PathCG.h"
|
||||
#include <math.h>
|
||||
#include "Logging.h"
|
||||
#include "PathHelpers.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
static inline Rect
|
||||
CGRectToRect(CGRect rect)
|
||||
{
|
||||
return Rect(rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.size.width,
|
||||
rect.size.height);
|
||||
}
|
||||
|
||||
static inline Point
|
||||
CGPointToPoint(CGPoint point)
|
||||
{
|
||||
return Point(point.x, point.y);
|
||||
}
|
||||
|
||||
static inline void
|
||||
SetStrokeOptions(CGContextRef cg, const StrokeOptions &aStrokeOptions)
|
||||
{
|
||||
switch (aStrokeOptions.mLineCap)
|
||||
{
|
||||
case CapStyle::BUTT:
|
||||
CGContextSetLineCap(cg, kCGLineCapButt);
|
||||
break;
|
||||
case CapStyle::ROUND:
|
||||
CGContextSetLineCap(cg, kCGLineCapRound);
|
||||
break;
|
||||
case CapStyle::SQUARE:
|
||||
CGContextSetLineCap(cg, kCGLineCapSquare);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (aStrokeOptions.mLineJoin)
|
||||
{
|
||||
case JoinStyle::BEVEL:
|
||||
CGContextSetLineJoin(cg, kCGLineJoinBevel);
|
||||
break;
|
||||
case JoinStyle::ROUND:
|
||||
CGContextSetLineJoin(cg, kCGLineJoinRound);
|
||||
break;
|
||||
case JoinStyle::MITER:
|
||||
case JoinStyle::MITER_OR_BEVEL:
|
||||
CGContextSetLineJoin(cg, kCGLineJoinMiter);
|
||||
break;
|
||||
}
|
||||
|
||||
CGContextSetLineWidth(cg, aStrokeOptions.mLineWidth);
|
||||
CGContextSetMiterLimit(cg, aStrokeOptions.mMiterLimit);
|
||||
|
||||
// XXX: rename mDashLength to dashLength
|
||||
if (aStrokeOptions.mDashLength > 0) {
|
||||
// we use a regular array instead of a std::vector here because we don't want to leak the <vector> include
|
||||
CGFloat *dashes = new CGFloat[aStrokeOptions.mDashLength];
|
||||
for (size_t i=0; i<aStrokeOptions.mDashLength; i++) {
|
||||
dashes[i] = aStrokeOptions.mDashPattern[i];
|
||||
}
|
||||
CGContextSetLineDash(cg, aStrokeOptions.mDashOffset, dashes, aStrokeOptions.mDashLength);
|
||||
delete[] dashes;
|
||||
}
|
||||
}
|
||||
|
||||
static inline CGAffineTransform
|
||||
GfxMatrixToCGAffineTransform(const Matrix &m)
|
||||
{
|
||||
CGAffineTransform t;
|
||||
t.a = m._11;
|
||||
t.b = m._12;
|
||||
t.c = m._21;
|
||||
t.d = m._22;
|
||||
t.tx = m._31;
|
||||
t.ty = m._32;
|
||||
return t;
|
||||
}
|
||||
|
||||
PathBuilderCG::~PathBuilderCG()
|
||||
{
|
||||
CGPathRelease(mCGPath);
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::MoveTo(const Point &aPoint)
|
||||
{
|
||||
if (!aPoint.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
CGPathMoveToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::LineTo(const Point &aPoint)
|
||||
{
|
||||
if (!aPoint.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CGPathIsEmpty(mCGPath))
|
||||
MoveTo(aPoint);
|
||||
else
|
||||
CGPathAddLineToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::BezierTo(const Point &aCP1,
|
||||
const Point &aCP2,
|
||||
const Point &aCP3)
|
||||
{
|
||||
if (!aCP1.IsFinite() || !aCP2.IsFinite() || !aCP3.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CGPathIsEmpty(mCGPath))
|
||||
MoveTo(aCP1);
|
||||
CGPathAddCurveToPoint(mCGPath, nullptr,
|
||||
aCP1.x, aCP1.y,
|
||||
aCP2.x, aCP2.y,
|
||||
aCP3.x, aCP3.y);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::QuadraticBezierTo(const Point &aCP1,
|
||||
const Point &aCP2)
|
||||
{
|
||||
if (!aCP1.IsFinite() || !aCP2.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CGPathIsEmpty(mCGPath))
|
||||
MoveTo(aCP1);
|
||||
CGPathAddQuadCurveToPoint(mCGPath, nullptr,
|
||||
aCP1.x, aCP1.y,
|
||||
aCP2.x, aCP2.y);
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::Close()
|
||||
{
|
||||
if (!CGPathIsEmpty(mCGPath))
|
||||
CGPathCloseSubpath(mCGPath);
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
|
||||
Float aEndAngle, bool aAntiClockwise)
|
||||
{
|
||||
if (!aOrigin.IsFinite() || !IsFinite(aRadius) ||
|
||||
!IsFinite(aStartAngle) || !IsFinite(aEndAngle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disabled for now due to a CG bug when using CGPathAddArc with stroke
|
||||
// dashing and rotation transforms that are multiples of 90 degrees. See:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=949661#c8
|
||||
#if 0
|
||||
// Core Graphic's initial coordinate system is y-axis up, whereas Moz2D's is
|
||||
// y-axis down. Core Graphics therefore considers "clockwise" to mean "sweep
|
||||
// in the direction of decreasing angle" whereas Moz2D considers it to mean
|
||||
// "sweep in the direction of increasing angle". In other words if this
|
||||
// Moz2D method is instructed to sweep anti-clockwise we need to tell
|
||||
// CGPathAddArc to sweep clockwise, and vice versa. Hence why we pass the
|
||||
// value of aAntiClockwise directly to CGPathAddArc's "clockwise" bool
|
||||
// parameter.
|
||||
CGPathAddArc(mCGPath, nullptr,
|
||||
aOrigin.x, aOrigin.y,
|
||||
aRadius,
|
||||
aStartAngle,
|
||||
aEndAngle,
|
||||
aAntiClockwise);
|
||||
#endif
|
||||
ArcToBezier(this, aOrigin, Size(aRadius, aRadius), aStartAngle, aEndAngle,
|
||||
aAntiClockwise);
|
||||
}
|
||||
|
||||
Point
|
||||
PathBuilderCG::CurrentPoint() const
|
||||
{
|
||||
Point ret;
|
||||
if (!CGPathIsEmpty(mCGPath)) {
|
||||
CGPoint pt = CGPathGetCurrentPoint(mCGPath);
|
||||
ret.MoveTo(pt.x, pt.y);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
PathBuilderCG::EnsureActive(const Point &aPoint)
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<Path>
|
||||
PathBuilderCG::Finish()
|
||||
{
|
||||
return MakeAndAddRef<PathCG>(mCGPath, mFillRule);
|
||||
}
|
||||
|
||||
already_AddRefed<PathBuilder>
|
||||
PathCG::CopyToBuilder(FillRule aFillRule) const
|
||||
{
|
||||
CGMutablePathRef path = CGPathCreateMutableCopy(mPath);
|
||||
return MakeAndAddRef<PathBuilderCG>(path, aFillRule);
|
||||
}
|
||||
|
||||
|
||||
|
||||
already_AddRefed<PathBuilder>
|
||||
PathCG::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
|
||||
{
|
||||
// 10.7 adds CGPathCreateMutableCopyByTransformingPath it might be faster than doing
|
||||
// this by hand
|
||||
|
||||
struct TransformApplier {
|
||||
CGMutablePathRef path;
|
||||
CGAffineTransform transform;
|
||||
static void
|
||||
TranformCGPathApplierFunc(void *vinfo, const CGPathElement *element)
|
||||
{
|
||||
TransformApplier *info = reinterpret_cast<TransformApplier*>(vinfo);
|
||||
switch (element->type) {
|
||||
case kCGPathElementMoveToPoint:
|
||||
{
|
||||
CGPoint pt = element->points[0];
|
||||
CGPathMoveToPoint(info->path, &info->transform, pt.x, pt.y);
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddLineToPoint:
|
||||
{
|
||||
CGPoint pt = element->points[0];
|
||||
CGPathAddLineToPoint(info->path, &info->transform, pt.x, pt.y);
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddQuadCurveToPoint:
|
||||
{
|
||||
CGPoint cpt = element->points[0];
|
||||
CGPoint pt = element->points[1];
|
||||
CGPathAddQuadCurveToPoint(info->path, &info->transform, cpt.x, cpt.y, pt.x, pt.y);
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddCurveToPoint:
|
||||
{
|
||||
CGPoint cpt1 = element->points[0];
|
||||
CGPoint cpt2 = element->points[1];
|
||||
CGPoint pt = element->points[2];
|
||||
CGPathAddCurveToPoint(info->path, &info->transform, cpt1.x, cpt1.y, cpt2.x, cpt2.y, pt.x, pt.y);
|
||||
break;
|
||||
}
|
||||
case kCGPathElementCloseSubpath:
|
||||
{
|
||||
CGPathCloseSubpath(info->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TransformApplier ta;
|
||||
ta.path = CGPathCreateMutable();
|
||||
ta.transform = GfxMatrixToCGAffineTransform(aTransform);
|
||||
|
||||
CGPathApply(mPath, &ta, TransformApplier::TranformCGPathApplierFunc);
|
||||
return MakeAndAddRef<PathBuilderCG>(ta.path, aFillRule);
|
||||
}
|
||||
|
||||
static void
|
||||
StreamPathToSinkApplierFunc(void *vinfo, const CGPathElement *element)
|
||||
{
|
||||
PathSink *sink = reinterpret_cast<PathSink*>(vinfo);
|
||||
switch (element->type) {
|
||||
case kCGPathElementMoveToPoint:
|
||||
{
|
||||
CGPoint pt = element->points[0];
|
||||
sink->MoveTo(CGPointToPoint(pt));
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddLineToPoint:
|
||||
{
|
||||
CGPoint pt = element->points[0];
|
||||
sink->LineTo(CGPointToPoint(pt));
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddQuadCurveToPoint:
|
||||
{
|
||||
CGPoint cpt = element->points[0];
|
||||
CGPoint pt = element->points[1];
|
||||
sink->QuadraticBezierTo(CGPointToPoint(cpt),
|
||||
CGPointToPoint(pt));
|
||||
break;
|
||||
}
|
||||
case kCGPathElementAddCurveToPoint:
|
||||
{
|
||||
CGPoint cpt1 = element->points[0];
|
||||
CGPoint cpt2 = element->points[1];
|
||||
CGPoint pt = element->points[2];
|
||||
sink->BezierTo(CGPointToPoint(cpt1),
|
||||
CGPointToPoint(cpt2),
|
||||
CGPointToPoint(pt));
|
||||
break;
|
||||
}
|
||||
case kCGPathElementCloseSubpath:
|
||||
{
|
||||
sink->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PathCG::StreamToSink(PathSink *aSink) const
|
||||
{
|
||||
CGPathApply(mPath, aSink, StreamPathToSinkApplierFunc);
|
||||
}
|
||||
|
||||
bool
|
||||
PathCG::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
|
||||
{
|
||||
Matrix inverse = aTransform;
|
||||
inverse.Invert();
|
||||
Point transformedPoint = inverse.TransformPoint(aPoint);
|
||||
// We could probably drop the input transform and just transform the point at the caller?
|
||||
CGPoint point = {transformedPoint.x, transformedPoint.y};
|
||||
|
||||
// The transform parameter of CGPathContainsPoint doesn't seem to work properly on OS X 10.5
|
||||
// so we transform aPoint ourselves.
|
||||
return CGPathContainsPoint(mPath, nullptr, point, mFillRule == FillRule::FILL_EVEN_ODD);
|
||||
}
|
||||
|
||||
static size_t
|
||||
PutBytesNull(void *info, const void *buffer, size_t count)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
/* The idea of a scratch context comes from WebKit */
|
||||
static CGContextRef
|
||||
CreateScratchContext()
|
||||
{
|
||||
CGDataConsumerCallbacks callbacks = {PutBytesNull, nullptr};
|
||||
CGDataConsumerRef consumer = CGDataConsumerCreate(nullptr, &callbacks);
|
||||
CGContextRef cg = CGPDFContextCreate(consumer, nullptr, nullptr);
|
||||
CGDataConsumerRelease(consumer);
|
||||
return cg;
|
||||
}
|
||||
|
||||
static CGContextRef
|
||||
ScratchContext()
|
||||
{
|
||||
static CGContextRef cg = CreateScratchContext();
|
||||
return cg;
|
||||
}
|
||||
|
||||
bool
|
||||
PathCG::StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
|
||||
const Point &aPoint,
|
||||
const Matrix &aTransform) const
|
||||
{
|
||||
Matrix inverse = aTransform;
|
||||
inverse.Invert();
|
||||
Point transformedPoint = inverse.TransformPoint(aPoint);
|
||||
// We could probably drop the input transform and just transform the point at the caller?
|
||||
CGPoint point = {transformedPoint.x, transformedPoint.y};
|
||||
|
||||
CGContextRef cg = ScratchContext();
|
||||
|
||||
CGContextSaveGState(cg);
|
||||
|
||||
CGContextBeginPath(cg);
|
||||
CGContextAddPath(cg, mPath);
|
||||
|
||||
SetStrokeOptions(cg, aStrokeOptions);
|
||||
|
||||
CGContextReplacePathWithStrokedPath(cg);
|
||||
CGContextRestoreGState(cg);
|
||||
|
||||
CGPathRef sPath = CGContextCopyPath(cg);
|
||||
bool inStroke = CGPathContainsPoint(sPath, nullptr, point, false);
|
||||
CGPathRelease(sPath);
|
||||
|
||||
return inStroke;
|
||||
}
|
||||
|
||||
//XXX: what should these functions return for an empty path?
|
||||
// currently they return CGRectNull {inf,inf, 0, 0}
|
||||
Rect
|
||||
PathCG::GetBounds(const Matrix &aTransform) const
|
||||
{
|
||||
//XXX: are these bounds tight enough
|
||||
Rect bounds = CGRectToRect(CGPathGetBoundingBox(mPath));
|
||||
|
||||
//XXX: currently this returns the bounds of the transformed bounds
|
||||
// this is strictly looser than the bounds of the transformed path
|
||||
return aTransform.TransformBounds(bounds);
|
||||
}
|
||||
|
||||
Rect
|
||||
PathCG::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
||||
const Matrix &aTransform) const
|
||||
{
|
||||
// 10.7 has CGPathCreateCopyByStrokingPath which we could use
|
||||
// instead of this scratch context business
|
||||
CGContextRef cg = ScratchContext();
|
||||
|
||||
CGContextSaveGState(cg);
|
||||
|
||||
CGContextBeginPath(cg);
|
||||
CGContextAddPath(cg, mPath);
|
||||
|
||||
SetStrokeOptions(cg, aStrokeOptions);
|
||||
|
||||
CGContextReplacePathWithStrokedPath(cg);
|
||||
Rect bounds = CGRectToRect(CGContextGetPathBoundingBox(cg));
|
||||
|
||||
CGContextRestoreGState(cg);
|
||||
|
||||
if (!bounds.IsFinite()) {
|
||||
return Rect();
|
||||
}
|
||||
|
||||
return aTransform.TransformBounds(bounds);
|
||||
}
|
||||
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
} // namespace mozilla
|
||||
114
gfx/2d/PathCG.h
114
gfx/2d/PathCG.h
|
|
@ -1,114 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; 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/. */
|
||||
|
||||
#ifndef MOZILLA_GFX_PATHCG_H_
|
||||
#define MOZILLA_GFX_PATHCG_H_
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#else
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#endif
|
||||
|
||||
#include "2D.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class PathCG;
|
||||
|
||||
class PathBuilderCG : public PathBuilder
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCG)
|
||||
// absorbs a reference of aPath
|
||||
PathBuilderCG(CGMutablePathRef aPath, FillRule aFillRule)
|
||||
: mFillRule(aFillRule)
|
||||
{
|
||||
mCGPath = aPath;
|
||||
}
|
||||
|
||||
explicit PathBuilderCG(FillRule aFillRule)
|
||||
: mFillRule(aFillRule)
|
||||
{
|
||||
mCGPath = CGPathCreateMutable();
|
||||
}
|
||||
|
||||
virtual ~PathBuilderCG();
|
||||
|
||||
virtual void MoveTo(const Point &aPoint);
|
||||
virtual void LineTo(const Point &aPoint);
|
||||
virtual void BezierTo(const Point &aCP1,
|
||||
const Point &aCP2,
|
||||
const Point &aCP3);
|
||||
virtual void QuadraticBezierTo(const Point &aCP1,
|
||||
const Point &aCP2);
|
||||
virtual void Close();
|
||||
virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
|
||||
Float aEndAngle, bool aAntiClockwise = false);
|
||||
virtual Point CurrentPoint() const;
|
||||
|
||||
virtual already_AddRefed<Path> Finish();
|
||||
|
||||
virtual BackendType GetBackendType() const { return BackendType::SKIA; }
|
||||
|
||||
private:
|
||||
friend class PathCG;
|
||||
friend class ScaledFontMac;
|
||||
|
||||
void EnsureActive(const Point &aPoint);
|
||||
|
||||
CGMutablePathRef mCGPath;
|
||||
Point mCurrentPoint;
|
||||
Point mBeginPoint;
|
||||
FillRule mFillRule;
|
||||
};
|
||||
|
||||
class PathCG : public Path
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCG)
|
||||
PathCG(CGMutablePathRef aPath, FillRule aFillRule)
|
||||
: mPath(aPath)
|
||||
, mFillRule(aFillRule)
|
||||
{
|
||||
CGPathRetain(mPath);
|
||||
}
|
||||
virtual ~PathCG() { CGPathRelease(mPath); }
|
||||
|
||||
// Paths will always return BackendType::COREGRAPHICS, but note that they
|
||||
// are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
|
||||
virtual BackendType GetBackendType() const { return BackendType::SKIA; }
|
||||
|
||||
virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const;
|
||||
virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
|
||||
FillRule aFillRule) const;
|
||||
|
||||
virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
|
||||
virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
|
||||
const Point &aPoint,
|
||||
const Matrix &aTransform) const;
|
||||
virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
|
||||
virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
||||
const Matrix &aTransform = Matrix()) const;
|
||||
|
||||
virtual void StreamToSink(PathSink *aSink) const;
|
||||
|
||||
virtual FillRule GetFillRule() const { return mFillRule; }
|
||||
|
||||
CGMutablePathRef GetPath() const { return mPath; }
|
||||
|
||||
private:
|
||||
friend class DrawTargetCG;
|
||||
|
||||
CGMutablePathRef mPath;
|
||||
Point mEndPoint;
|
||||
FillRule mFillRule;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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 nsCoreAnimationSupport_h__
|
||||
#define nsCoreAnimationSupport_h__
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
#import <OpenGL/OpenGL.h>
|
||||
#import <OpenGL/gl.h>
|
||||
#import "ApplicationServices/ApplicationServices.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "nsError.h"
|
||||
|
||||
// Get the system color space.
|
||||
CGColorSpaceRef CreateSystemColorSpace();
|
||||
|
||||
// Manages a CARenderer
|
||||
struct _CGLContextObject;
|
||||
|
||||
enum AllowOfflineRendererEnum { ALLOW_OFFLINE_RENDERER, DISALLOW_OFFLINE_RENDERER };
|
||||
|
||||
class nsCARenderer : public mozilla::RefCounted<nsCARenderer> {
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(nsCARenderer)
|
||||
nsCARenderer() : mCARenderer(nullptr), mWrapperCALayer(nullptr), mFBOTexture(0),
|
||||
mOpenGLContext(nullptr), mCGImage(nullptr), mCGData(nullptr),
|
||||
mIOSurface(nullptr), mFBO(0), mIOTexture(0),
|
||||
mUnsupportedWidth(UINT32_MAX), mUnsupportedHeight(UINT32_MAX),
|
||||
mAllowOfflineRenderer(DISALLOW_OFFLINE_RENDERER),
|
||||
mContentsScaleFactor(1.0) {}
|
||||
~nsCARenderer();
|
||||
// aWidth and aHeight are in "display pixels". A "display pixel" is the
|
||||
// smallest fully addressable part of a display. But in HiDPI modes each
|
||||
// "display pixel" corresponds to more than one device pixel. Multiply
|
||||
// display pixels by aContentsScaleFactor to get device pixels.
|
||||
nsresult SetupRenderer(void* aCALayer, int aWidth, int aHeight,
|
||||
double aContentsScaleFactor,
|
||||
AllowOfflineRendererEnum aAllowOfflineRenderer);
|
||||
// aWidth and aHeight are in "display pixels". Multiply by
|
||||
// aContentsScaleFactor to get device pixels.
|
||||
nsresult Render(int aWidth, int aHeight,
|
||||
double aContentsScaleFactor,
|
||||
CGImageRef *aOutCAImage);
|
||||
bool isInit() { return mCARenderer != nullptr; }
|
||||
/*
|
||||
* Render the CALayer to an IOSurface. If no IOSurface
|
||||
* is attached then an internal pixel buffer will be
|
||||
* used.
|
||||
*/
|
||||
void AttachIOSurface(MacIOSurface *aSurface);
|
||||
IOSurfaceID GetIOSurfaceID();
|
||||
// aX, aY, aWidth and aHeight are in "display pixels". Multiply by
|
||||
// surf->GetContentsScaleFactor() to get device pixels.
|
||||
static nsresult DrawSurfaceToCGContext(CGContextRef aContext,
|
||||
MacIOSurface *surf,
|
||||
CGColorSpaceRef aColorSpace,
|
||||
int aX, int aY,
|
||||
size_t aWidth, size_t aHeight);
|
||||
|
||||
// Remove & Add the layer without destroying
|
||||
// the renderer for fast back buffer swapping.
|
||||
void DetachCALayer();
|
||||
void AttachCALayer(void *aCALayer);
|
||||
#ifdef DEBUG
|
||||
static void SaveToDisk(MacIOSurface *surf);
|
||||
#endif
|
||||
private:
|
||||
// aWidth and aHeight are in "display pixels". Multiply by
|
||||
// mContentsScaleFactor to get device pixels.
|
||||
void SetBounds(int aWidth, int aHeight);
|
||||
// aWidth and aHeight are in "display pixels". Multiply by
|
||||
// mContentsScaleFactor to get device pixels.
|
||||
void SetViewport(int aWidth, int aHeight);
|
||||
void Destroy();
|
||||
|
||||
void *mCARenderer;
|
||||
void *mWrapperCALayer;
|
||||
GLuint mFBOTexture;
|
||||
_CGLContextObject *mOpenGLContext;
|
||||
CGImageRef mCGImage;
|
||||
void *mCGData;
|
||||
RefPtr<MacIOSurface> mIOSurface;
|
||||
uint32_t mFBO;
|
||||
uint32_t mIOTexture;
|
||||
int mUnsupportedWidth;
|
||||
int mUnsupportedHeight;
|
||||
AllowOfflineRendererEnum mAllowOfflineRenderer;
|
||||
double mContentsScaleFactor;
|
||||
};
|
||||
|
||||
#endif // XP_MACOSX
|
||||
#endif // nsCoreAnimationSupport_h__
|
||||
|
||||
|
|
@ -1,625 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim:set ts=2 sts=2 sw=2 et cin:
|
||||
/* 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 "QuartzSupport.h"
|
||||
#include "nsDebug.h"
|
||||
#include "MacIOSurface.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <AppKit/NSOpenGL.h>
|
||||
#include <dlfcn.h>
|
||||
#include "GLDefs.h"
|
||||
|
||||
#define IOSURFACE_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/IOSurface.framework/IOSurface"
|
||||
#define OPENGL_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/OpenGL.framework/OpenGL"
|
||||
#define COREGRAPHICS_FRAMEWORK_PATH \
|
||||
"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/CoreGraphics"
|
||||
|
||||
@interface CALayer (ContentsScale)
|
||||
- (double)contentsScale;
|
||||
- (void)setContentsScale:(double)scale;
|
||||
@end
|
||||
|
||||
|
||||
CGColorSpaceRef CreateSystemColorSpace() {
|
||||
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
|
||||
if (!cspace) {
|
||||
cspace = ::CGColorSpaceCreateDeviceRGB();
|
||||
}
|
||||
return cspace;
|
||||
}
|
||||
|
||||
nsCARenderer::~nsCARenderer() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void cgdata_release_callback(void *aCGData, const void *data, size_t size) {
|
||||
if (aCGData) {
|
||||
free(aCGData);
|
||||
}
|
||||
}
|
||||
|
||||
void nsCARenderer::Destroy() {
|
||||
if (mCARenderer) {
|
||||
CARenderer* caRenderer = (CARenderer*)mCARenderer;
|
||||
// Bug 556453:
|
||||
// Explicitly remove the layer from the renderer
|
||||
// otherwise it does not always happen right away.
|
||||
caRenderer.layer = nullptr;
|
||||
[caRenderer release];
|
||||
}
|
||||
if (mWrapperCALayer) {
|
||||
CALayer* wrapperLayer = (CALayer*)mWrapperCALayer;
|
||||
[wrapperLayer release];
|
||||
}
|
||||
if (mOpenGLContext) {
|
||||
if (mFBO || mIOTexture || mFBOTexture) {
|
||||
// Release these resources with the context that allocated them
|
||||
CGLContextObj oldContext = ::CGLGetCurrentContext();
|
||||
::CGLSetCurrentContext(mOpenGLContext);
|
||||
|
||||
if (mFBOTexture) {
|
||||
::glDeleteTextures(1, &mFBOTexture);
|
||||
}
|
||||
if (mIOTexture) {
|
||||
::glDeleteTextures(1, &mIOTexture);
|
||||
}
|
||||
if (mFBO) {
|
||||
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
::glDeleteFramebuffersEXT(1, &mFBO);
|
||||
}
|
||||
|
||||
if (oldContext)
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
}
|
||||
::CGLDestroyContext((CGLContextObj)mOpenGLContext);
|
||||
}
|
||||
if (mCGImage) {
|
||||
::CGImageRelease(mCGImage);
|
||||
}
|
||||
// mCGData is deallocated by cgdata_release_callback
|
||||
|
||||
mCARenderer = nil;
|
||||
mWrapperCALayer = nil;
|
||||
mFBOTexture = 0;
|
||||
mOpenGLContext = nullptr;
|
||||
mCGImage = nullptr;
|
||||
mIOSurface = nullptr;
|
||||
mFBO = 0;
|
||||
mIOTexture = 0;
|
||||
}
|
||||
|
||||
nsresult nsCARenderer::SetupRenderer(void *aCALayer, int aWidth, int aHeight,
|
||||
double aContentsScaleFactor,
|
||||
AllowOfflineRendererEnum aAllowOfflineRenderer) {
|
||||
mAllowOfflineRenderer = aAllowOfflineRenderer;
|
||||
|
||||
if (aWidth == 0 || aHeight == 0 || aContentsScaleFactor <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aWidth == mUnsupportedWidth &&
|
||||
aHeight == mUnsupportedHeight) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
CGLPixelFormatAttribute attributes[] = {
|
||||
kCGLPFAAccelerated,
|
||||
kCGLPFADepthSize, (CGLPixelFormatAttribute)24,
|
||||
kCGLPFAAllowOfflineRenderers,
|
||||
(CGLPixelFormatAttribute)0
|
||||
};
|
||||
|
||||
if (mAllowOfflineRenderer == DISALLOW_OFFLINE_RENDERER) {
|
||||
attributes[3] = (CGLPixelFormatAttribute)0;
|
||||
}
|
||||
|
||||
GLint screen;
|
||||
CGLPixelFormatObj format;
|
||||
if (::CGLChoosePixelFormat(attributes, &format, &screen) != kCGLNoError) {
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (::CGLCreateContext(format, nullptr, &mOpenGLContext) != kCGLNoError) {
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
::CGLDestroyPixelFormat(format);
|
||||
|
||||
CARenderer* caRenderer = [[CARenderer rendererWithCGLContext:mOpenGLContext
|
||||
options:nil] retain];
|
||||
if (caRenderer == nil) {
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
CALayer* wrapperCALayer = [[CALayer layer] retain];
|
||||
if (wrapperCALayer == nil) {
|
||||
[caRenderer release];
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mCARenderer = caRenderer;
|
||||
mWrapperCALayer = wrapperCALayer;
|
||||
caRenderer.layer = wrapperCALayer;
|
||||
[wrapperCALayer addSublayer:(CALayer*)aCALayer];
|
||||
mContentsScaleFactor = aContentsScaleFactor;
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
SetBounds(aWidth, aHeight);
|
||||
|
||||
// We target rendering to a CGImage if no shared IOSurface are given.
|
||||
if (!mIOSurface) {
|
||||
mCGData = malloc(aWidth*intScaleFactor*aHeight*4*intScaleFactor);
|
||||
if (!mCGData) {
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
memset(mCGData, 0, aWidth*intScaleFactor*aHeight*4*intScaleFactor);
|
||||
|
||||
CGDataProviderRef dataProvider = nullptr;
|
||||
dataProvider = ::CGDataProviderCreateWithData(mCGData,
|
||||
mCGData, aHeight*intScaleFactor*aWidth*4*intScaleFactor,
|
||||
cgdata_release_callback);
|
||||
if (!dataProvider) {
|
||||
cgdata_release_callback(mCGData, mCGData,
|
||||
aHeight*intScaleFactor*aWidth*4*intScaleFactor);
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
CGColorSpaceRef colorSpace = CreateSystemColorSpace();
|
||||
|
||||
mCGImage = ::CGImageCreate(aWidth * intScaleFactor, aHeight * intScaleFactor,
|
||||
8, 32, aWidth * intScaleFactor * 4, colorSpace,
|
||||
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
|
||||
dataProvider, nullptr, true, kCGRenderingIntentDefault);
|
||||
|
||||
::CGDataProviderRelease(dataProvider);
|
||||
::CGColorSpaceRelease(colorSpace);
|
||||
if (!mCGImage) {
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
CGLContextObj oldContext = ::CGLGetCurrentContext();
|
||||
::CGLSetCurrentContext(mOpenGLContext);
|
||||
|
||||
if (mIOSurface) {
|
||||
// Create the IOSurface mapped texture.
|
||||
::glGenTextures(1, &mIOTexture);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, mIOTexture);
|
||||
::glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
::glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
MacIOSurfaceLib::CGLTexImageIOSurface2D(mOpenGLContext, GL_TEXTURE_RECTANGLE_ARB,
|
||||
GL_RGBA, aWidth * intScaleFactor,
|
||||
aHeight * intScaleFactor,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
mIOSurface->mIOSurfacePtr, 0);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
} else {
|
||||
::glGenTextures(1, &mFBOTexture);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, mFBOTexture);
|
||||
::glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
::glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
}
|
||||
|
||||
// Create the fbo
|
||||
::glGenFramebuffersEXT(1, &mFBO);
|
||||
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
|
||||
if (mIOSurface) {
|
||||
::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_RECTANGLE_ARB, mIOTexture, 0);
|
||||
} else {
|
||||
::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_RECTANGLE_ARB, mFBOTexture, 0);
|
||||
}
|
||||
|
||||
|
||||
// Make sure that the Framebuffer configuration is supported on the client machine
|
||||
GLenum fboStatus;
|
||||
fboStatus = ::glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (fboStatus != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
NS_ERROR("FBO not supported");
|
||||
if (oldContext)
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
SetViewport(aWidth, aHeight);
|
||||
|
||||
GLenum result = ::glGetError();
|
||||
if (result != GL_NO_ERROR) {
|
||||
NS_ERROR("Unexpected OpenGL Error");
|
||||
mUnsupportedWidth = aWidth;
|
||||
mUnsupportedHeight = aHeight;
|
||||
Destroy();
|
||||
if (oldContext)
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (oldContext)
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsCARenderer::SetBounds(int aWidth, int aHeight) {
|
||||
CARenderer* caRenderer = (CARenderer*)mCARenderer;
|
||||
CALayer* wrapperLayer = (CALayer*)mWrapperCALayer;
|
||||
NSArray* sublayers = [wrapperLayer sublayers];
|
||||
CALayer* pluginLayer = (CALayer*) [sublayers objectAtIndex:0];
|
||||
|
||||
// Create a transaction and disable animations
|
||||
// to make the position update instant.
|
||||
[CATransaction begin];
|
||||
NSMutableDictionary *newActions =
|
||||
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNull null], @"onOrderIn",
|
||||
[NSNull null], @"onOrderOut",
|
||||
[NSNull null], @"sublayers",
|
||||
[NSNull null], @"contents",
|
||||
[NSNull null], @"position",
|
||||
[NSNull null], @"bounds",
|
||||
nil];
|
||||
wrapperLayer.actions = newActions;
|
||||
[newActions release];
|
||||
|
||||
// If we're in HiDPI mode, mContentsScaleFactor will (presumably) be 2.0.
|
||||
// For some reason, to make things work properly in HiDPI mode we need to
|
||||
// make caRenderer's 'bounds' and 'layer' different sizes -- to set 'bounds'
|
||||
// to the size of 'layer's backing store. And to avoid this possibly
|
||||
// confusing the plugin, we need to hide it's effects from the plugin by
|
||||
// making pluginLayer (usually the CALayer* provided by the plugin) a
|
||||
// sublayer of our own wrapperLayer (see bug 829284).
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
[CATransaction setValue: [NSNumber numberWithFloat:0.0f] forKey: kCATransactionAnimationDuration];
|
||||
[CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
|
||||
[wrapperLayer setBounds:CGRectMake(0, 0, aWidth, aHeight)];
|
||||
[wrapperLayer setPosition:CGPointMake(aWidth/2.0, aHeight/2.0)];
|
||||
[pluginLayer setBounds:CGRectMake(0, 0, aWidth, aHeight)];
|
||||
[pluginLayer setFrame:CGRectMake(0, 0, aWidth, aHeight)];
|
||||
caRenderer.bounds = CGRectMake(0, 0, aWidth * intScaleFactor, aHeight * intScaleFactor);
|
||||
if (mContentsScaleFactor != 1.0) {
|
||||
CGAffineTransform affineTransform = [wrapperLayer affineTransform];
|
||||
affineTransform.a = mContentsScaleFactor;
|
||||
affineTransform.d = mContentsScaleFactor;
|
||||
affineTransform.tx = ((double)aWidth)/mContentsScaleFactor;
|
||||
affineTransform.ty = ((double)aHeight)/mContentsScaleFactor;
|
||||
[wrapperLayer setAffineTransform:affineTransform];
|
||||
} else {
|
||||
// These settings are the default values. But they might have been
|
||||
// changed as above if we were previously running in a HiDPI mode
|
||||
// (i.e. if we just switched from that to a non-HiDPI mode).
|
||||
[wrapperLayer setAffineTransform:CGAffineTransformIdentity];
|
||||
}
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
void nsCARenderer::SetViewport(int aWidth, int aHeight) {
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
aWidth *= intScaleFactor;
|
||||
aHeight *= intScaleFactor;
|
||||
|
||||
::glViewport(0.0, 0.0, aWidth, aHeight);
|
||||
::glMatrixMode(GL_PROJECTION);
|
||||
::glLoadIdentity();
|
||||
::glOrtho (0.0, aWidth, 0.0, aHeight, -1, 1);
|
||||
|
||||
// Render upside down to speed up CGContextDrawImage
|
||||
::glTranslatef(0.0f, aHeight, 0.0);
|
||||
::glScalef(1.0, -1.0, 1.0);
|
||||
}
|
||||
|
||||
void nsCARenderer::AttachIOSurface(MacIOSurface *aSurface) {
|
||||
if (mIOSurface &&
|
||||
aSurface->GetIOSurfaceID() == mIOSurface->GetIOSurfaceID()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mIOSurface = aSurface;
|
||||
|
||||
// Update the framebuffer and viewport
|
||||
if (mCARenderer) {
|
||||
CARenderer* caRenderer = (CARenderer*)mCARenderer;
|
||||
size_t intScaleFactor = ceil(mContentsScaleFactor);
|
||||
int width = caRenderer.bounds.size.width / intScaleFactor;
|
||||
int height = caRenderer.bounds.size.height / intScaleFactor;
|
||||
|
||||
CGLContextObj oldContext = ::CGLGetCurrentContext();
|
||||
::CGLSetCurrentContext(mOpenGLContext);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, mIOTexture);
|
||||
MacIOSurfaceLib::CGLTexImageIOSurface2D(mOpenGLContext, GL_TEXTURE_RECTANGLE_ARB,
|
||||
GL_RGBA, mIOSurface->GetDevicePixelWidth(),
|
||||
mIOSurface->GetDevicePixelHeight(),
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
mIOSurface->mIOSurfacePtr, 0);
|
||||
::glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
|
||||
// Rebind the FBO to make it live
|
||||
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
|
||||
|
||||
if (static_cast<int>(mIOSurface->GetWidth()) != width ||
|
||||
static_cast<int>(mIOSurface->GetHeight()) != height) {
|
||||
width = mIOSurface->GetWidth();
|
||||
height = mIOSurface->GetHeight();
|
||||
SetBounds(width, height);
|
||||
SetViewport(width, height);
|
||||
}
|
||||
|
||||
if (oldContext) {
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IOSurfaceID nsCARenderer::GetIOSurfaceID() {
|
||||
if (!mIOSurface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mIOSurface->GetIOSurfaceID();
|
||||
}
|
||||
|
||||
nsresult nsCARenderer::Render(int aWidth, int aHeight,
|
||||
double aContentsScaleFactor,
|
||||
CGImageRef *aOutCGImage) {
|
||||
if (!aOutCGImage && !mIOSurface) {
|
||||
NS_ERROR("No target destination for rendering");
|
||||
} else if (aOutCGImage) {
|
||||
// We are expected to return a CGImageRef, we will set
|
||||
// it to nullptr in case we fail before the image is ready.
|
||||
*aOutCGImage = nullptr;
|
||||
}
|
||||
|
||||
if (aWidth == 0 || aHeight == 0 || aContentsScaleFactor <= 0)
|
||||
return NS_OK;
|
||||
|
||||
if (!mCARenderer || !mWrapperCALayer) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
CARenderer* caRenderer = (CARenderer*)mCARenderer;
|
||||
CALayer* wrapperLayer = (CALayer*)mWrapperCALayer;
|
||||
size_t intScaleFactor = ceil(aContentsScaleFactor);
|
||||
int renderer_width = caRenderer.bounds.size.width / intScaleFactor;
|
||||
int renderer_height = caRenderer.bounds.size.height / intScaleFactor;
|
||||
|
||||
if (renderer_width != aWidth || renderer_height != aHeight ||
|
||||
mContentsScaleFactor != aContentsScaleFactor) {
|
||||
// XXX: This should be optimized to not rescale the buffer
|
||||
// if we are resizing down.
|
||||
// caLayer may be the CALayer* provided by the plugin, so we need to
|
||||
// preserve it across the call to Destroy().
|
||||
NSArray* sublayers = [wrapperLayer sublayers];
|
||||
CALayer* caLayer = (CALayer*) [sublayers objectAtIndex:0];
|
||||
// mIOSurface is set by AttachIOSurface(), not by SetupRenderer(). So
|
||||
// since it may have been set by a prior call to AttachIOSurface(), we
|
||||
// need to preserve it across the call to Destroy().
|
||||
RefPtr<MacIOSurface> ioSurface = mIOSurface;
|
||||
Destroy();
|
||||
mIOSurface = ioSurface;
|
||||
if (SetupRenderer(caLayer, aWidth, aHeight, aContentsScaleFactor,
|
||||
mAllowOfflineRenderer) != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
caRenderer = (CARenderer*)mCARenderer;
|
||||
}
|
||||
|
||||
CGLContextObj oldContext = ::CGLGetCurrentContext();
|
||||
::CGLSetCurrentContext(mOpenGLContext);
|
||||
if (!mIOSurface) {
|
||||
// If no shared IOSurface is given render to our own
|
||||
// texture for readback.
|
||||
::glGenTextures(1, &mFBOTexture);
|
||||
}
|
||||
|
||||
GLenum result = ::glGetError();
|
||||
if (result != GL_NO_ERROR) {
|
||||
NS_ERROR("Unexpected OpenGL Error");
|
||||
Destroy();
|
||||
if (oldContext)
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
::glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
::glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
[CATransaction commit];
|
||||
double caTime = ::CACurrentMediaTime();
|
||||
[caRenderer beginFrameAtTime:caTime timeStamp:nullptr];
|
||||
[caRenderer addUpdateRect:CGRectMake(0,0, aWidth * intScaleFactor,
|
||||
aHeight * intScaleFactor)];
|
||||
[caRenderer render];
|
||||
[caRenderer endFrame];
|
||||
|
||||
// Read the data back either to the IOSurface or mCGImage.
|
||||
if (mIOSurface) {
|
||||
::glFlush();
|
||||
} else {
|
||||
::glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
::glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
::glPixelStorei(GL_PACK_SKIP_ROWS, 0);
|
||||
::glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
|
||||
::glReadPixels(0.0f, 0.0f, aWidth * intScaleFactor,
|
||||
aHeight * intScaleFactor,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE,
|
||||
mCGData);
|
||||
|
||||
*aOutCGImage = mCGImage;
|
||||
}
|
||||
|
||||
if (oldContext) {
|
||||
::CGLSetCurrentContext(oldContext);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsCARenderer::DrawSurfaceToCGContext(CGContextRef aContext,
|
||||
MacIOSurface *surf,
|
||||
CGColorSpaceRef aColorSpace,
|
||||
int aX, int aY,
|
||||
size_t aWidth, size_t aHeight) {
|
||||
surf->Lock();
|
||||
size_t bytesPerRow = surf->GetBytesPerRow();
|
||||
size_t ioWidth = surf->GetWidth();
|
||||
size_t ioHeight = surf->GetHeight();
|
||||
|
||||
// We get rendering glitches if we use a width/height that falls
|
||||
// outside of the IOSurface.
|
||||
if (aWidth + aX > ioWidth)
|
||||
aWidth = ioWidth - aX;
|
||||
if (aHeight + aY > ioHeight)
|
||||
aHeight = ioHeight - aY;
|
||||
|
||||
if (aX < 0 || static_cast<size_t>(aX) >= ioWidth ||
|
||||
aY < 0 || static_cast<size_t>(aY) >= ioHeight) {
|
||||
surf->Unlock();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void* ioData = surf->GetBaseAddress();
|
||||
double scaleFactor = surf->GetContentsScaleFactor();
|
||||
size_t intScaleFactor = ceil(surf->GetContentsScaleFactor());
|
||||
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
|
||||
ioData, ioHeight*intScaleFactor*(bytesPerRow)*4,
|
||||
nullptr); //No release callback
|
||||
if (!dataProvider) {
|
||||
surf->Unlock();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
CGImageRef cgImage = ::CGImageCreate(ioWidth * intScaleFactor,
|
||||
ioHeight * intScaleFactor, 8, 32, bytesPerRow, aColorSpace,
|
||||
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
|
||||
dataProvider, nullptr, true, kCGRenderingIntentDefault);
|
||||
::CGDataProviderRelease(dataProvider);
|
||||
if (!cgImage) {
|
||||
surf->Unlock();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
CGImageRef subImage = ::CGImageCreateWithImageInRect(cgImage,
|
||||
::CGRectMake(aX * scaleFactor,
|
||||
aY * scaleFactor,
|
||||
aWidth * scaleFactor,
|
||||
aHeight * scaleFactor));
|
||||
if (!subImage) {
|
||||
::CGImageRelease(cgImage);
|
||||
surf->Unlock();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
::CGContextScaleCTM(aContext, 1.0f, -1.0f);
|
||||
::CGContextDrawImage(aContext,
|
||||
CGRectMake(aX * scaleFactor,
|
||||
(-(CGFloat)aY - (CGFloat)aHeight) * scaleFactor,
|
||||
aWidth * scaleFactor,
|
||||
aHeight * scaleFactor),
|
||||
subImage);
|
||||
|
||||
::CGImageRelease(subImage);
|
||||
::CGImageRelease(cgImage);
|
||||
surf->Unlock();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsCARenderer::DetachCALayer() {
|
||||
CALayer* wrapperLayer = (CALayer*)mWrapperCALayer;
|
||||
NSArray* sublayers = [wrapperLayer sublayers];
|
||||
CALayer* oldLayer = (CALayer*) [sublayers objectAtIndex:0];
|
||||
[oldLayer removeFromSuperlayer];
|
||||
}
|
||||
|
||||
void nsCARenderer::AttachCALayer(void *aCALayer) {
|
||||
CALayer* wrapperLayer = (CALayer*)mWrapperCALayer;
|
||||
NSArray* sublayers = [wrapperLayer sublayers];
|
||||
CALayer* oldLayer = (CALayer*) [sublayers objectAtIndex:0];
|
||||
[oldLayer removeFromSuperlayer];
|
||||
[wrapperLayer addSublayer:(CALayer*)aCALayer];
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
int sSaveToDiskSequence = 0;
|
||||
void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
|
||||
surf->Lock();
|
||||
size_t bytesPerRow = surf->GetBytesPerRow();
|
||||
size_t ioWidth = surf->GetWidth();
|
||||
size_t ioHeight = surf->GetHeight();
|
||||
void* ioData = surf->GetBaseAddress();
|
||||
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
|
||||
ioData, ioHeight*(bytesPerRow)*4,
|
||||
nullptr); //No release callback
|
||||
if (!dataProvider) {
|
||||
surf->Unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
CGColorSpaceRef colorSpace = CreateSystemColorSpace();
|
||||
CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
|
||||
colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
|
||||
dataProvider, nullptr, true, kCGRenderingIntentDefault);
|
||||
::CGDataProviderRelease(dataProvider);
|
||||
::CGColorSpaceRelease(colorSpace);
|
||||
if (!cgImage) {
|
||||
surf->Unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
char cstr[1000];
|
||||
SprintfLiteral(cstr, "file:///Users/benoitgirard/debug/iosurface_%i.png", ++sSaveToDiskSequence);
|
||||
|
||||
CFStringRef cfStr = ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingMacRoman);
|
||||
|
||||
printf("Exporting: %s\n", cstr);
|
||||
CFURLRef url = ::CFURLCreateWithString( nullptr, cfStr, nullptr);
|
||||
::CFRelease(cfStr);
|
||||
|
||||
CFStringRef type = kUTTypePNG;
|
||||
size_t count = 1;
|
||||
CFDictionaryRef options = nullptr;
|
||||
CGImageDestinationRef dest = ::CGImageDestinationCreateWithURL(url, type, count, options);
|
||||
::CFRelease(url);
|
||||
|
||||
::CGImageDestinationAddImage(dest, cgImage, nullptr);
|
||||
|
||||
::CGImageDestinationFinalize(dest);
|
||||
::CFRelease(dest);
|
||||
::CGImageRelease(cgImage);
|
||||
|
||||
surf->Unlock();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -9,10 +9,6 @@
|
|||
#include "Logging.h"
|
||||
#include "mozilla/Move.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
|
|
@ -61,9 +57,6 @@ struct NameRecord
|
|||
enum ENameDecoder : int
|
||||
{
|
||||
eNameDecoderUTF16,
|
||||
#if defined(XP_MACOSX)
|
||||
eNameDecoderMacRoman,
|
||||
#endif
|
||||
eNameDecoderNone
|
||||
};
|
||||
|
||||
|
|
@ -128,19 +121,6 @@ IsUTF16Encoding(const NameRecord *aNameRecord)
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
static bool
|
||||
IsMacRomanEncoding(const NameRecord *aNameRecord)
|
||||
{
|
||||
if (aNameRecord->platformID == PLATFORM_ID_MAC &&
|
||||
aNameRecord->encodingID == ENCODING_ID_MAC_ROMAN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static NameRecordMatchers*
|
||||
CreateCanonicalMatchers(const BigEndianUint16& aNameID)
|
||||
{
|
||||
|
|
@ -149,37 +129,6 @@ CreateCanonicalMatchers(const BigEndianUint16& aNameID)
|
|||
// records and Mac platform records.
|
||||
NameRecordMatchers *matchers = new NameRecordMatchers();
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// First, look for the English name.
|
||||
if (!matchers->append(
|
||||
[=](const NameRecord *aNameRecord) {
|
||||
if (aNameRecord->nameID == aNameID &&
|
||||
aNameRecord->languageID == LANG_ID_MAC_ENGLISH &&
|
||||
aNameRecord->platformID == PLATFORM_ID_MAC &&
|
||||
IsMacRomanEncoding(aNameRecord)) {
|
||||
return eNameDecoderMacRoman;
|
||||
} else {
|
||||
return eNameDecoderNone;
|
||||
}
|
||||
})) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// Second, look for all languages.
|
||||
if (!matchers->append(
|
||||
[=](const NameRecord *aNameRecord) {
|
||||
if (aNameRecord->nameID == aNameID &&
|
||||
aNameRecord->platformID == PLATFORM_ID_MAC &&
|
||||
IsMacRomanEncoding(aNameRecord)) {
|
||||
return eNameDecoderMacRoman;
|
||||
} else {
|
||||
return eNameDecoderNone;
|
||||
}
|
||||
})) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
#endif /* defined(XP_MACOSX) */
|
||||
|
||||
// First, look for the English name (this will normally succeed).
|
||||
if (!matchers->append(
|
||||
[=](const NameRecord *aNameRecord) {
|
||||
|
|
@ -273,10 +222,6 @@ SFNTNameTable::ReadU16Name(const NameRecordMatchers& aMatchers,
|
|||
switch (aMatchers[i](record)) {
|
||||
case eNameDecoderUTF16:
|
||||
return ReadU16NameFromU16Record(record, aU16Name);
|
||||
#if defined(XP_MACOSX)
|
||||
case eNameDecoderMacRoman:
|
||||
return ReadU16NameFromMacRomanRecord(record, aU16Name);
|
||||
#endif
|
||||
case eNameDecoderNone:
|
||||
break;
|
||||
default:
|
||||
|
|
@ -311,46 +256,5 @@ SFNTNameTable::ReadU16NameFromU16Record(const NameRecord *aNameRecord,
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
bool
|
||||
SFNTNameTable::ReadU16NameFromMacRomanRecord(const NameRecord *aNameRecord,
|
||||
mozilla::u16string& aU16Name)
|
||||
{
|
||||
uint32_t offset = aNameRecord->offset;
|
||||
uint32_t length = aNameRecord->length;
|
||||
if (mStringDataLength < offset + length) {
|
||||
gfxWarning() << "Name data too short to contain name string.";
|
||||
return false;
|
||||
}
|
||||
if (length > INT_MAX) {
|
||||
gfxWarning() << "Name record too long to decode.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// pointer to the Mac Roman encoded string in the name record
|
||||
const uint8_t *encodedStr = mStringData + offset;
|
||||
|
||||
CFStringRef cfString;
|
||||
cfString = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, encodedStr,
|
||||
length, kCFStringEncodingMacRoman,
|
||||
false, kCFAllocatorNull);
|
||||
|
||||
// length (in UTF-16 code pairs) of the decoded string
|
||||
CFIndex decodedLength = CFStringGetLength(cfString);
|
||||
|
||||
// temporary buffer
|
||||
UniquePtr<UniChar[]> u16Buffer = MakeUnique<UniChar[]>(decodedLength);
|
||||
|
||||
CFStringGetCharacters(cfString, CFRangeMake(0, decodedLength),
|
||||
u16Buffer.get());
|
||||
|
||||
CFRelease(cfString);
|
||||
|
||||
aU16Name.assign(reinterpret_cast<char16_t*>(u16Buffer.get()), decodedLength);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // gfx
|
||||
} // mozilla
|
||||
|
|
|
|||
|
|
@ -55,11 +55,6 @@ private:
|
|||
bool ReadU16NameFromU16Record(const NameRecord *aNameRecord,
|
||||
mozilla::u16string& aU16Name);
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
bool ReadU16NameFromMacRomanRecord(const NameRecord *aNameRecord,
|
||||
mozilla::u16string& aU16Name);
|
||||
#endif
|
||||
|
||||
const NameRecord *mFirstRecord;
|
||||
const NameRecord *mEndOfRecords;
|
||||
const uint8_t *mStringData;
|
||||
|
|
|
|||
|
|
@ -1,247 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; 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 "ScaledFontMac.h"
|
||||
#ifdef USE_SKIA
|
||||
#include "PathSkia.h"
|
||||
#include "skia/include/core/SkPaint.h"
|
||||
#include "skia/include/core/SkPath.h"
|
||||
#include "skia/include/ports/SkTypeface_mac.h"
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <dlfcn.h>
|
||||
#ifdef MOZ_WIDGET_UIKIT
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
// prototype for private API
|
||||
extern "C" {
|
||||
CGPathRef CGFontGetGlyphPath(CGFontRef fontRef, CGAffineTransform *textTransform, int unknown, CGGlyph glyph);
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#include "cairo-quartz.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
ScaledFontMac::CTFontDrawGlyphsFuncT* ScaledFontMac::CTFontDrawGlyphsPtr = nullptr;
|
||||
bool ScaledFontMac::sSymbolLookupDone = false;
|
||||
|
||||
ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize)
|
||||
: ScaledFontBase(aSize)
|
||||
{
|
||||
if (!sSymbolLookupDone) {
|
||||
CTFontDrawGlyphsPtr =
|
||||
(CTFontDrawGlyphsFuncT*)dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs");
|
||||
sSymbolLookupDone = true;
|
||||
}
|
||||
|
||||
// XXX: should we be taking a reference
|
||||
mFont = CGFontRetain(aFont);
|
||||
if (CTFontDrawGlyphsPtr != nullptr) {
|
||||
// only create mCTFont if we're going to be using the CTFontDrawGlyphs API
|
||||
mCTFont = CTFontCreateWithGraphicsFont(aFont, aSize, nullptr, nullptr);
|
||||
} else {
|
||||
mCTFont = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ScaledFontMac::~ScaledFontMac()
|
||||
{
|
||||
if (mCTFont) {
|
||||
CFRelease(mCTFont);
|
||||
}
|
||||
CGFontRelease(mFont);
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA
|
||||
SkTypeface* ScaledFontMac::GetSkTypeface()
|
||||
{
|
||||
if (!mTypeface) {
|
||||
if (mCTFont) {
|
||||
mTypeface = SkCreateTypefaceFromCTFont(mCTFont);
|
||||
} else {
|
||||
CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, nullptr, nullptr);
|
||||
mTypeface = SkCreateTypefaceFromCTFont(fontFace);
|
||||
CFRelease(fontFace);
|
||||
}
|
||||
}
|
||||
return mTypeface;
|
||||
}
|
||||
#endif
|
||||
|
||||
// private API here are the public options on OS X
|
||||
// CTFontCreatePathForGlyph
|
||||
// ATSUGlyphGetCubicPaths
|
||||
// we've used this in cairo sucessfully for some time.
|
||||
// Note: cairo dlsyms it. We could do that but maybe it's
|
||||
// safe just to use?
|
||||
|
||||
already_AddRefed<Path>
|
||||
ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
|
||||
{
|
||||
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
CalcTableChecksum(const uint32_t *tableStart, uint32_t length, bool skipChecksumAdjust = false)
|
||||
{
|
||||
uint32_t sum = 0L;
|
||||
const uint32_t *table = tableStart;
|
||||
const uint32_t *end = table+((length+3) & ~3) / sizeof(uint32_t);
|
||||
while (table < end) {
|
||||
if (skipChecksumAdjust && (table - tableStart) == 2) {
|
||||
table++;
|
||||
} else {
|
||||
sum += CFSwapInt32BigToHost(*table++);
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
struct TableRecord {
|
||||
uint32_t tag;
|
||||
uint32_t checkSum;
|
||||
uint32_t offset;
|
||||
uint32_t length;
|
||||
CFDataRef data;
|
||||
};
|
||||
|
||||
int maxPow2LessThan(int a)
|
||||
{
|
||||
int x = 1;
|
||||
int shift = 0;
|
||||
while ((x<<(shift+1)) < a) {
|
||||
shift++;
|
||||
}
|
||||
return shift;
|
||||
}
|
||||
|
||||
struct writeBuf
|
||||
{
|
||||
explicit writeBuf(int size)
|
||||
{
|
||||
this->data = new unsigned char [size];
|
||||
this->offset = 0;
|
||||
}
|
||||
~writeBuf() {
|
||||
delete this->data;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void writeElement(T a)
|
||||
{
|
||||
*reinterpret_cast<T*>(&this->data[this->offset]) = a;
|
||||
this->offset += sizeof(T);
|
||||
}
|
||||
|
||||
void writeMem(const void *data, unsigned long length)
|
||||
{
|
||||
memcpy(&this->data[this->offset], data, length);
|
||||
this->offset += length;
|
||||
}
|
||||
|
||||
void align()
|
||||
{
|
||||
while (this->offset & 3) {
|
||||
this->data[this->offset] = 0;
|
||||
this->offset++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *data;
|
||||
int offset;
|
||||
};
|
||||
|
||||
bool
|
||||
ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
|
||||
{
|
||||
// We'll reconstruct a TTF font from the tables we can get from the CGFont
|
||||
CFArrayRef tags = CGFontCopyTableTags(mFont);
|
||||
CFIndex count = CFArrayGetCount(tags);
|
||||
|
||||
TableRecord *records = new TableRecord[count];
|
||||
uint32_t offset = 0;
|
||||
offset += sizeof(uint32_t)*3;
|
||||
offset += sizeof(uint32_t)*4*count;
|
||||
bool CFF = false;
|
||||
for (CFIndex i = 0; i<count; i++) {
|
||||
uint32_t tag = (uint32_t)(uintptr_t)CFArrayGetValueAtIndex(tags, i);
|
||||
if (tag == 0x43464620) // 'CFF '
|
||||
CFF = true;
|
||||
CFDataRef data = CGFontCopyTableForTag(mFont, tag);
|
||||
records[i].tag = tag;
|
||||
records[i].offset = offset;
|
||||
records[i].data = data;
|
||||
records[i].length = CFDataGetLength(data);
|
||||
bool skipChecksumAdjust = (tag == 0x68656164); // 'head'
|
||||
records[i].checkSum = CalcTableChecksum(reinterpret_cast<const uint32_t*>(CFDataGetBytePtr(data)),
|
||||
records[i].length, skipChecksumAdjust);
|
||||
offset += records[i].length;
|
||||
// 32 bit align the tables
|
||||
offset = (offset + 3) & ~3;
|
||||
}
|
||||
CFRelease(tags);
|
||||
|
||||
struct writeBuf buf(offset);
|
||||
// write header/offset table
|
||||
if (CFF) {
|
||||
buf.writeElement(CFSwapInt32HostToBig(0x4f54544f));
|
||||
} else {
|
||||
buf.writeElement(CFSwapInt32HostToBig(0x00010000));
|
||||
}
|
||||
buf.writeElement(CFSwapInt16HostToBig(count));
|
||||
buf.writeElement(CFSwapInt16HostToBig((1<<maxPow2LessThan(count))*16));
|
||||
buf.writeElement(CFSwapInt16HostToBig(maxPow2LessThan(count)));
|
||||
buf.writeElement(CFSwapInt16HostToBig(count*16-((1<<maxPow2LessThan(count))*16)));
|
||||
|
||||
// write table record entries
|
||||
for (CFIndex i = 0; i<count; i++) {
|
||||
buf.writeElement(CFSwapInt32HostToBig(records[i].tag));
|
||||
buf.writeElement(CFSwapInt32HostToBig(records[i].checkSum));
|
||||
buf.writeElement(CFSwapInt32HostToBig(records[i].offset));
|
||||
buf.writeElement(CFSwapInt32HostToBig(records[i].length));
|
||||
}
|
||||
|
||||
// write tables
|
||||
int checkSumAdjustmentOffset = 0;
|
||||
for (CFIndex i = 0; i<count; i++) {
|
||||
if (records[i].tag == 0x68656164) {
|
||||
checkSumAdjustmentOffset = buf.offset + 2*4;
|
||||
}
|
||||
buf.writeMem(CFDataGetBytePtr(records[i].data), CFDataGetLength(records[i].data));
|
||||
buf.align();
|
||||
CFRelease(records[i].data);
|
||||
}
|
||||
delete[] records;
|
||||
|
||||
// clear the checksumAdjust field before checksumming the whole font
|
||||
memset(&buf.data[checkSumAdjustmentOffset], 0, sizeof(uint32_t));
|
||||
uint32_t fontChecksum = CFSwapInt32HostToBig(0xb1b0afba - CalcTableChecksum(reinterpret_cast<const uint32_t*>(buf.data), offset));
|
||||
// set checkSumAdjust to the computed checksum
|
||||
memcpy(&buf.data[checkSumAdjustmentOffset], &fontChecksum, sizeof(fontChecksum));
|
||||
|
||||
// we always use an index of 0
|
||||
aDataCallback(buf.data, buf.offset, 0, mSize, aBaton);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_font_face_t*
|
||||
ScaledFontMac::GetCairoFontFace()
|
||||
{
|
||||
MOZ_ASSERT(mFont);
|
||||
return cairo_quartz_font_face_create_for_cgfont(mFont);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; 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/. */
|
||||
|
||||
#ifndef MOZILLA_GFX_SCALEDFONTMAC_H_
|
||||
#define MOZILLA_GFX_SCALEDFONTMAC_H_
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#else
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <CoreText/CoreText.h>
|
||||
#endif
|
||||
|
||||
#include "2D.h"
|
||||
|
||||
#include "ScaledFontBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class GlyphRenderingOptionsCG : public GlyphRenderingOptions
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsCG, override)
|
||||
|
||||
explicit GlyphRenderingOptionsCG(const Color &aFontSmoothingBackgroundColor)
|
||||
: mFontSmoothingBackgroundColor(aFontSmoothingBackgroundColor)
|
||||
{}
|
||||
|
||||
const Color &FontSmoothingBackgroundColor() const { return mFontSmoothingBackgroundColor; }
|
||||
|
||||
virtual FontType GetType() const override { return FontType::MAC; }
|
||||
|
||||
private:
|
||||
Color mFontSmoothingBackgroundColor;
|
||||
};
|
||||
|
||||
class ScaledFontMac : public ScaledFontBase
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontMac)
|
||||
ScaledFontMac(CGFontRef aFont, Float aSize);
|
||||
virtual ~ScaledFontMac();
|
||||
|
||||
virtual FontType GetType() const { return FontType::MAC; }
|
||||
#ifdef USE_SKIA
|
||||
virtual SkTypeface* GetSkTypeface();
|
||||
#endif
|
||||
virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
|
||||
virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton);
|
||||
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_font_face_t* GetCairoFontFace();
|
||||
#endif
|
||||
|
||||
private:
|
||||
friend class DrawTargetSkia;
|
||||
CGFontRef mFont;
|
||||
CTFontRef mCTFont; // only created if CTFontDrawGlyphs is available, otherwise null
|
||||
|
||||
typedef void (CTFontDrawGlyphsFuncT)(CTFontRef,
|
||||
const CGGlyph[], const CGPoint[],
|
||||
size_t, CGContextRef);
|
||||
|
||||
static bool sSymbolLookupDone;
|
||||
|
||||
public:
|
||||
// function pointer for CTFontDrawGlyphs, if available;
|
||||
// initialized the first time a ScaledFontMac is created,
|
||||
// so it will be valid by the time DrawTargetCG wants to use it
|
||||
static CTFontDrawGlyphsFuncT* CTFontDrawGlyphsPtr;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* MOZILLA_GFX_SCALEDFONTMAC_H_ */
|
||||
|
|
@ -58,16 +58,7 @@ EXPORTS.mozilla.gfx += [
|
|||
|
||||
EXPORTS.mozilla.gfx += ['ssse3-scaler.h']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
|
||||
EXPORTS.mozilla.gfx += [
|
||||
'MacIOSurface.h',
|
||||
]
|
||||
SOURCES += [
|
||||
'NativeFontResourceMac.cpp',
|
||||
'PathCG.cpp',
|
||||
'ScaledFontMac.cpp',
|
||||
]
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
SOURCES += [
|
||||
'DrawTargetD2D1.cpp',
|
||||
'ExtendInputEffectD2D1.cpp',
|
||||
|
|
@ -181,15 +172,6 @@ if CONFIG['CLANG_CXX']:
|
|||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
EXPORTS.mozilla.gfx += [
|
||||
'QuartzSupport.h',
|
||||
]
|
||||
SOURCES += [
|
||||
'MacIOSurface.cpp',
|
||||
'QuartzSupport.mm',
|
||||
]
|
||||
|
||||
if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
|
||||
SOURCES += ['BlurNEON.cpp']
|
||||
SOURCES['BlurNEON.cpp'].flags += CONFIG['NEON_FLAGS']
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@
|
|||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "MacIOSurfaceImage.h"
|
||||
#include "GLContextCGL.h"
|
||||
#endif
|
||||
|
||||
using mozilla::layers::PlanarYCbCrImage;
|
||||
using mozilla::layers::PlanarYCbCrData;
|
||||
|
||||
|
|
@ -186,34 +181,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
|
|||
} \n\
|
||||
";
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
const char kTexNV12PlanarBlit_FragShaderSource[] = "\
|
||||
#version 100 \n\
|
||||
#extension GL_ARB_texture_rectangle : require \n\
|
||||
#ifdef GL_ES \n\
|
||||
precision mediump float \n\
|
||||
#endif \n\
|
||||
varying vec2 vTexCoord; \n\
|
||||
uniform sampler2DRect uYTexture; \n\
|
||||
uniform sampler2DRect uCbCrTexture; \n\
|
||||
uniform vec2 uYTexScale; \n\
|
||||
uniform vec2 uCbCrTexScale; \n\
|
||||
void main() \n\
|
||||
{ \n\
|
||||
float y = texture2DRect(uYTexture, vTexCoord * uYTexScale).r; \n\
|
||||
float cb = texture2DRect(uCbCrTexture, vTexCoord * uCbCrTexScale).r; \n\
|
||||
float cr = texture2DRect(uCbCrTexture, vTexCoord * uCbCrTexScale).a; \n\
|
||||
y = (y - 0.06275) * 1.16438; \n\
|
||||
cb = cb - 0.50196; \n\
|
||||
cr = cr - 0.50196; \n\
|
||||
gl_FragColor.r = y + cr * 1.59603; \n\
|
||||
gl_FragColor.g = y - 0.81297 * cr - 0.39176 * cb; \n\
|
||||
gl_FragColor.b = y + cb * 2.01723; \n\
|
||||
gl_FragColor.a = 1.0; \n\
|
||||
} \n\
|
||||
";
|
||||
#endif
|
||||
|
||||
bool success = false;
|
||||
|
||||
GLuint* programPtr;
|
||||
|
|
@ -236,13 +203,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
|
|||
fragShaderPtr = &mTexYUVPlanarBlit_FragShader;
|
||||
fragShaderSource = kTexYUVPlanarBlit_FragShaderSource;
|
||||
break;
|
||||
#ifdef XP_MACOSX
|
||||
case ConvertMacIOSurfaceImage:
|
||||
programPtr = &mTexNV12PlanarBlit_Program;
|
||||
fragShaderPtr = &mTexNV12PlanarBlit_FragShader;
|
||||
fragShaderSource = kTexNV12PlanarBlit_FragShaderSource;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -393,24 +353,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
|
|||
mGL->fUniform1i(texCr, Channel_Cr);
|
||||
break;
|
||||
}
|
||||
case ConvertMacIOSurfaceImage: {
|
||||
#ifdef XP_MACOSX
|
||||
GLint texY = mGL->fGetUniformLocation(program, "uYTexture");
|
||||
GLint texCbCr = mGL->fGetUniformLocation(program, "uCbCrTexture");
|
||||
mYTexScaleLoc = mGL->fGetUniformLocation(program, "uYTexScale");
|
||||
mCbCrTexScaleLoc= mGL->fGetUniformLocation(program, "uCbCrTexScale");
|
||||
|
||||
DebugOnly<bool> hasUniformLocations = texY != -1 &&
|
||||
texCbCr != -1 &&
|
||||
mYTexScaleLoc != -1 &&
|
||||
mCbCrTexScaleLoc != -1;
|
||||
MOZ_ASSERT(hasUniformLocations, "uniforms not found");
|
||||
|
||||
mGL->fUniform1i(texY, Channel_Y);
|
||||
mGL->fUniform1i(texCbCr, Channel_Cb);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -678,47 +620,6 @@ GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
bool
|
||||
GLBlitHelper::BlitMacIOSurfaceImage(layers::MacIOSurfaceImage* ioImage)
|
||||
{
|
||||
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
|
||||
MacIOSurface* surf = ioImage->GetSurface();
|
||||
|
||||
GLint oldTex[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
mGL->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
|
||||
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, &oldTex[i]);
|
||||
}
|
||||
|
||||
GLuint textures[2];
|
||||
mGL->fGenTextures(2, textures);
|
||||
|
||||
mGL->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
mGL->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textures[0]);
|
||||
mGL->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
mGL->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
surf->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(mGL)->GetCGLContext(), 0);
|
||||
mGL->fUniform2f(mYTexScaleLoc, surf->GetWidth(0), surf->GetHeight(0));
|
||||
|
||||
mGL->fActiveTexture(LOCAL_GL_TEXTURE1);
|
||||
mGL->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textures[1]);
|
||||
mGL->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
mGL->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
surf->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(mGL)->GetCGLContext(), 1);
|
||||
mGL->fUniform2f(mCbCrTexScaleLoc, surf->GetWidth(1), surf->GetHeight(1));
|
||||
|
||||
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
mGL->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
|
||||
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, oldTex[i]);
|
||||
}
|
||||
|
||||
mGL->fDeleteTextures(2, textures);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
|
||||
const gfx::IntSize& destSize,
|
||||
|
|
@ -736,13 +637,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
|
|||
srcOrigin = OriginPos::BottomLeft;
|
||||
break;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case ImageFormat::MAC_IOSURFACE:
|
||||
type = ConvertMacIOSurfaceImage;
|
||||
srcOrigin = OriginPos::TopLeft;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -768,11 +662,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case ConvertMacIOSurfaceImage:
|
||||
return BlitMacIOSurfaceImage(srcImage->AsMacIOSurfaceImage());
|
||||
#endif
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,6 @@ class GLBlitHelper final
|
|||
void BindAndUploadEGLImage(EGLImage image, GLuint target);
|
||||
|
||||
bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage);
|
||||
#ifdef XP_MACOSX
|
||||
bool BlitMacIOSurfaceImage(layers::MacIOSurfaceImage* ioImage);
|
||||
#endif
|
||||
|
||||
explicit GLBlitHelper(GLContext* gl);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@
|
|||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
#include "nsCocoaFeatures.h"
|
||||
#endif
|
||||
|
|
@ -877,18 +873,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
|
|||
// multisampling hardcodes blending with the default blendfunc, which breaks WebGL.
|
||||
MarkUnsupported(GLFeature::framebuffer_multisample);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// The Mac Nvidia driver, for versions up to and including 10.8,
|
||||
// don't seem to properly support this. See 814839
|
||||
// this has been fixed in Mac OS X 10.9. See 907946
|
||||
// and it also works in 10.8.3 and higher. See 1094338.
|
||||
if (Vendor() == gl::GLVendor::NVIDIA &&
|
||||
!nsCocoaFeatures::IsAtLeastVersion(10,8,3))
|
||||
{
|
||||
MarkUnsupported(GLFeature::depth_texture);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IsExtensionSupported(GLContext::ARB_pixel_buffer_object)) {
|
||||
|
|
@ -1009,25 +993,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
|
|||
raw_fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize);
|
||||
raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (mWorkAroundDriverBugs) {
|
||||
if (mVendor == GLVendor::Intel) {
|
||||
// see bug 737182 for 2D textures, bug 684882 for cube map textures.
|
||||
mMaxTextureSize = std::min(mMaxTextureSize, 4096);
|
||||
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 512);
|
||||
// for good measure, we align renderbuffers on what we do for 2D textures
|
||||
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
|
||||
mNeedsTextureSizeChecks = true;
|
||||
} else if (mVendor == GLVendor::NVIDIA) {
|
||||
// See bug 879656. 8192 fails, 8191 works.
|
||||
mMaxTextureSize = std::min(mMaxTextureSize, 8191);
|
||||
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 8191);
|
||||
|
||||
// Part of the bug 879656, but it also doesn't hurt the 877949
|
||||
mNeedsTextureSizeChecks = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_X11
|
||||
if (mWorkAroundDriverBugs) {
|
||||
if (mVendor == GLVendor::Nouveau) {
|
||||
|
|
@ -1800,20 +1765,6 @@ GLContext::InitExtensions()
|
|||
MarkExtensionUnsupported(ANGLE_texture_compression_dxt3);
|
||||
MarkExtensionUnsupported(ANGLE_texture_compression_dxt5);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Bug 1009642: On OSX Mavericks (10.9), the driver for Intel HD
|
||||
// 3000 appears to be buggy WRT updating sub-images of S3TC
|
||||
// textures with glCompressedTexSubImage2D. Works on Intel HD 4000
|
||||
// and Intel HD 5000/Iris that I tested.
|
||||
// Bug 1124996: Appears to be the same on OSX Yosemite (10.10)
|
||||
if (nsCocoaFeatures::macOSVersionMajor() == 10 &&
|
||||
nsCocoaFeatures::macOSVersionMinor() >= 9 &&
|
||||
Renderer() == GLRenderer::IntelHD3000)
|
||||
{
|
||||
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (shouldDumpExts) {
|
||||
|
|
@ -2828,35 +2779,6 @@ GLContext::fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum f
|
|||
}
|
||||
|
||||
AfterGLReadCall();
|
||||
|
||||
// Check if GL is giving back 1.0 alpha for
|
||||
// RGBA reads to RGBA images from no-alpha buffers.
|
||||
#ifdef XP_MACOSX
|
||||
if (WorkAroundDriverBugs() &&
|
||||
Vendor() == gl::GLVendor::NVIDIA &&
|
||||
format == LOCAL_GL_RGBA &&
|
||||
type == LOCAL_GL_UNSIGNED_BYTE &&
|
||||
!IsCoreProfile() &&
|
||||
width && height)
|
||||
{
|
||||
GLint alphaBits = 0;
|
||||
fGetIntegerv(LOCAL_GL_ALPHA_BITS, &alphaBits);
|
||||
if (!alphaBits) {
|
||||
const uint32_t alphaMask = 0xff000000;
|
||||
|
||||
uint32_t* itr = (uint32_t*)pixels;
|
||||
uint32_t testPixel = *itr;
|
||||
if ((testPixel & alphaMask) != alphaMask) {
|
||||
// We need to set the alpha channel to 1.0 manually.
|
||||
uint32_t* itrEnd = itr + width*height; // Stride is guaranteed to be width*4.
|
||||
|
||||
for (; itr != itrEnd; itr++) {
|
||||
*itr |= alphaMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -34,13 +34,6 @@ namespace gl {
|
|||
#define DEFAULT_IMPL WGL
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL
|
||||
#include "GLContextProviderImpl.h"
|
||||
#undef GL_CONTEXT_PROVIDER_NAME
|
||||
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_X11)
|
||||
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
|
||||
#include "GLContextProviderImpl.h"
|
||||
|
|
|
|||
|
|
@ -24,10 +24,6 @@
|
|||
#include "mozilla/gfx/DeviceManagerDx.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "SharedSurfaceIO.h"
|
||||
#endif
|
||||
|
||||
#ifdef GL_PROVIDER_GLX
|
||||
#include "GLXLibrary.h"
|
||||
#include "SharedSurfaceGLX.h"
|
||||
|
|
@ -84,9 +80,7 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
|
|||
if (!gfxPrefs::WebGLForceLayersReadback()) {
|
||||
switch (backend) {
|
||||
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
|
||||
#if defined(XP_MACOSX)
|
||||
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
|
||||
#elif defined(GL_PROVIDER_GLX)
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
if (sGLXLibrary.UseTextureFromPixmap())
|
||||
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
|
||||
#elif defined(MOZ_WIDGET_UIKIT)
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@
|
|||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "mozilla/gfx/QuartzSupport.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include <d3d10_1.h>
|
||||
|
|
|
|||
|
|
@ -166,9 +166,6 @@ protected:
|
|||
class GLImage;
|
||||
class EGLImageImage;
|
||||
class SharedRGBImage;
|
||||
#if defined(XP_MACOSX)
|
||||
class MacIOSurfaceImage;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A class representing a buffer of pixel data. The data can be in one
|
||||
|
|
@ -223,9 +220,6 @@ public:
|
|||
/* Access to derived classes. */
|
||||
virtual EGLImageImage* AsEGLImageImage() { return nullptr; }
|
||||
virtual GLImage* AsGLImage() { return nullptr; }
|
||||
#ifdef XP_MACOSX
|
||||
virtual MacIOSurfaceImage* AsMacIOSurfaceImage() { return nullptr; }
|
||||
#endif
|
||||
virtual PlanarYCbCrImage* AsPlanarYCbCrImage() { return nullptr; }
|
||||
|
||||
virtual NVImage* AsNVImage() { return nullptr; }
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue