merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2016-10-27 16:45:00 +02:00
commit 7d0f3d5865
177 changed files with 1556 additions and 8307 deletions

View File

@ -750,6 +750,12 @@
#endif
#endif
#if defined(MOZ_SANDBOX)
#if defined(XP_LINUX)
@BINPATH@/@DLL_PREFIX@mozsandbox@DLL_SUFFIX@
#endif
#endif
; for Solaris SPARC
#ifdef SOLARIS
bin/libfreebl_32fpu_3.so

View File

@ -37,14 +37,18 @@ define(function (require, exports, module) {
render: function () {
let grip = this.props.object;
return (
span({className: "objectBox"},
let date;
try {
date = span({className: "objectBox"},
this.getTitle(grip),
span({className: "Date"},
new Date(grip.preview.timestamp).toISOString()
)
)
);
);
} catch (e) {
date = span({className: "objectBox"}, "Invalid Date");
}
return date;
},
});

View File

@ -15,10 +15,19 @@ Test DateTime rep
<script src="head.js" type="application/javascript;version=1.8"></script>
<script type="application/javascript;version=1.8">
window.onload = Task.async(function* () {
try {
let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
let { DateTime } = browserRequire("devtools/client/shared/components/reps/date-time");
let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
let { DateTime } = browserRequire("devtools/client/shared/components/reps/date-time");
try {
testValid();
testInvalid();
} catch(e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
}
function testValid() {
let gripStub = {
"type": "object",
"class": "Date",
@ -38,11 +47,28 @@ window.onload = Task.async(function* () {
// Test rendering
const renderedComponent = renderComponent(DateTime.rep, { object: gripStub });
is(renderedComponent.textContent, "2016-03-30T21:17:24.859Z", "DateTime rep has expected text content");
} catch(e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
is(renderedComponent.textContent, "2016-03-30T21:17:24.859Z", "DateTime rep has expected text content for valid date");
}
function testInvalid() {
let gripStub = {
"type": "object",
"actor": "server1.conn0.child1/obj32",
"class": "Date",
"extensible": true,
"frozen": false,
"sealed": false,
"ownPropertyLength": 0,
"preview": {
"timestamp": {
"type": "NaN"
}
}
};
// Test rendering
const renderedComponent = renderComponent(DateTime.rep, { object: gripStub });
is(renderedComponent.textContent, "Invalid Date", "DateTime rep has expected text content for invalid date");
}
});
</script>

View File

@ -144,14 +144,15 @@ PostMessageEvent::Run()
Nullable<WindowProxyOrMessagePort> source;
source.SetValue().SetAsWindowProxy() = mSource ? mSource->AsOuter() : nullptr;
Sequence<OwningNonNull<MessagePort>> ports;
if (!TakeTransferredPortsAsSequence(ports)) {
return NS_ERROR_OUT_OF_MEMORY;
}
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
false /*non-bubbling */, false /*cancelable */,
messageData, mCallerOrigin,
EmptyString(), source,
Sequence<OwningNonNull<MessagePort>>());
nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
event->SetPorts(Move(ports));
EmptyString(), source, ports);
// We can't simply call dispatchEvent on the window because doing so ends
// up flipping the trusted bit on the event, and we don't want that to

View File

@ -1279,5 +1279,20 @@ StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
}
}
bool
StructuredCloneHolder::TakeTransferredPortsAsSequence(Sequence<OwningNonNull<mozilla::dom::MessagePort>>& aPorts)
{
nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
aPorts.Clear();
for (uint32_t i = 0, len = ports.Length(); i < len; ++i) {
if (!aPorts.AppendElement(ports[i].forget(), fallible)) {
return false;
}
}
return true;
}
} // dom namespace
} // mozilla namespace

View File

@ -9,6 +9,7 @@
#include "js/StructuredClone.h"
#include "mozilla/Move.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsISupports.h"
#include "nsTArray.h"
@ -207,6 +208,11 @@ public:
return Move(mTransferredPorts);
}
// This method uses TakeTransferredPorts() to populate a sequence of
// MessagePorts for WebIDL binding classes.
bool
TakeTransferredPortsAsSequence(Sequence<OwningNonNull<mozilla::dom::MessagePort>>& aPorts);
nsTArray<MessagePortIdentifier>& PortIdentifiers() const
{
MOZ_ASSERT(mSupportsTransferring);

View File

@ -175,18 +175,5 @@ MessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
aPorts = mPorts;
}
void
MessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
{
MOZ_ASSERT(mPorts.IsEmpty());
mPorts = Move(aPorts);
}
void
MessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
{
mPortSource = aPort;
}
} // namespace dom
} // namespace mozilla

View File

@ -49,16 +49,6 @@ public:
void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
// Non WebIDL methods
void SetSource(mozilla::dom::MessagePort* aPort);
void SetSource(nsPIDOMWindowInner* aWindow)
{
mWindowSource = aWindow;
}
static already_AddRefed<MessageEvent>
Constructor(const GlobalObject& aGlobal,
const nsAString& aType,

View File

@ -51,7 +51,6 @@
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/ContentProcessController.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/SharedBufferManagerChild.h"
#include "mozilla/layout/RenderFrameChild.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/plugins/PluginInstanceParent.h"
@ -1212,13 +1211,6 @@ ContentChild::RecvReinitRendering(Endpoint<PCompositorBridgeChild>&& aCompositor
return true;
}
PSharedBufferManagerChild*
ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess)
{
return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
}
PBackgroundChild*
ContentChild::AllocPBackgroundChild(Transport* aTransport,
ProcessId aOtherProcess)
@ -1421,7 +1413,11 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
NS_LITERAL_CSTRING("ContentSandboxEnabled"),
sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
#if defined(XP_LINUX) && !defined(OS_ANDROID)
SandboxInfo::Get().AnnotateCrashReport();
nsAutoCString flagsString;
flagsString.AppendInt(SandboxInfo::Get().AsInteger());
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
#endif /* XP_LINUX && !OS_ANDROID */
#endif /* MOZ_CRASHREPORTER */
#endif /* MOZ_CONTENT_SANDBOX */

View File

@ -173,10 +173,6 @@ public:
Endpoint<PImageBridgeChild>&& aImageBridge,
Endpoint<PVRManagerChild>&& aVRBridge) override;
PSharedBufferManagerChild*
AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) override;
PProcessHangMonitorChild*
AllocPProcessHangMonitorChild(Transport* aTransport,
ProcessId aOtherProcess) override;

View File

@ -84,7 +84,6 @@
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/LayerTreeOwnerTracker.h"
#include "mozilla/layers/SharedBufferManagerParent.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/media/MediaParent.h"
@ -2212,10 +2211,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
gpm->AddListener(this);
}
#ifdef MOZ_WIDGET_GONK
DebugOnly<bool> opened = PSharedBufferManager::Open(this);
MOZ_ASSERT(opened);
#endif
}
if (gAppData) {
@ -2845,13 +2840,6 @@ ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
return mHangMonitorActor;
}
PSharedBufferManagerParent*
ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess)
{
return SharedBufferManagerParent::Create(aTransport, aOtherProcess);
}
bool
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp, bool* aIsForBrowser)

View File

@ -67,7 +67,6 @@ class PJavaScriptParent;
} // namespace jsipc
namespace layers {
class PSharedBufferManagerParent;
struct TextureFactoryIdentifier;
} // namespace layers
@ -702,10 +701,6 @@ private:
AllocPGMPServiceParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) override;
PSharedBufferManagerParent*
AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranport,
base::ProcessId aOtherProcess) override;
PBackgroundParent*
AllocPBackgroundParent(Transport* aTransport, ProcessId aOtherProcess)
override;

View File

@ -41,7 +41,6 @@ include protocol PSendStream;
include protocol POfflineCacheUpdate;
include protocol PRenderFrame;
include protocol PScreenManager;
include protocol PSharedBufferManager;
include protocol PSpeechSynthesis;
include protocol PStorage;
include protocol PTestShell;
@ -343,7 +342,6 @@ nested(upto inside_cpow) sync protocol PContent
parent spawns PPluginModule;
parent opens PProcessHangMonitor;
parent opens PSharedBufferManager;
parent opens PGMPService;
child opens PBackground;

View File

@ -316,7 +316,7 @@ HangMonitorChild::InterruptCallback()
if (forcePaint) {
RefPtr<TabChild> tabChild = TabChild::FindTabChild(forcePaintTab);
if (tabChild) {
JS::AutoAssertOnGC nogc(mContext);
JS::AutoAssertNoGC nogc(mContext);
JS::AutoAssertOnBarrier nobarrier(mContext);
tabChild->ForcePaint(forcePaintEpoch);
}

View File

@ -120,6 +120,11 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_TARGET'] == 'Darwin':
'mozsandbox',
]
if CONFIG['MOZ_CONTENT_SANDBOX'] and CONFIG['OS_ARCH'] == 'Linux':
USE_LIBS += [
'mozsandbox',
]
LOCAL_INCLUDES += [
'/caps',
'/chrome',

View File

@ -329,10 +329,6 @@ GonkBufferData::GetPlatformMediaData()
mTextureClientRecycleHandler->WaitforRecycle()
->Then(mGonkPlatformLayer->GetTaskQueue(), __func__,
[self] () {
// Waiting for texture to be freed.
if (self->mTextureClientRecycleHandler) {
self->mTextureClientRecycleHandler->GetTextureClient()->WaitForBufferOwnership();
}
self->mPromise.ResolveIfExists(self, __func__);
},
[self] () {

View File

@ -134,16 +134,19 @@ private:
RefPtr<MessageEvent> event =
new MessageEvent(eventTarget, nullptr, nullptr);
Sequence<OwningNonNull<MessagePort>> ports;
if (!mData->TakeTransferredPortsAsSequence(ports)) {
return NS_ERROR_OUT_OF_MEMORY;
}
Nullable<WindowProxyOrMessagePort> source;
source.SetValue().SetAsMessagePort() = mPort;
event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
false /* non-bubbling */,
false /* cancelable */, value, EmptyString(),
EmptyString(), nullptr,
Sequence<OwningNonNull<MessagePort>>());
EmptyString(), source, ports);
event->SetTrusted(true);
event->SetSource(mPort);
nsTArray<RefPtr<MessagePort>> ports = mData->TakeTransferredPorts();
event->SetPorts(Move(ports));
bool dummy;
mPort->DispatchEvent(static_cast<dom::Event*>(event.get()), &dummy);

View File

@ -15,7 +15,6 @@ interface ServiceWorkerMessageEvent : Event {
/**
* Custom data associated with this event.
*/
[GetterThrows]
readonly attribute any data;
/**

View File

@ -410,7 +410,6 @@ WEBIDL_FILES = [
'ServiceWorker.webidl',
'ServiceWorkerContainer.webidl',
'ServiceWorkerGlobalScope.webidl',
'ServiceWorkerMessageEvent.webidl',
'ServiceWorkerRegistration.webidl',
'SettingChangeNotification.webidl',
'SettingsManager.webidl',
@ -771,6 +770,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'ProgressEvent.webidl',
'RecordErrorEvent.webidl',
'ScrollViewChangeEvent.webidl',
'ServiceWorkerMessageEvent.webidl',
'StyleRuleChangeEvent.webidl',
'StyleSheetApplicableStateChangeEvent.webidl',
'StyleSheetChangeEvent.webidl',

View File

@ -165,12 +165,14 @@ private:
init.mSource.SetValue().SetAsServiceWorker() = serviceWorker;
}
if (!TakeTransferredPortsAsSequence(init.mPorts)) {
return NS_ERROR_OUT_OF_MEMORY;
}
RefPtr<ServiceWorkerMessageEvent> event =
ServiceWorkerMessageEvent::Constructor(aTargetContainer,
NS_LITERAL_STRING("message"), init, rv);
nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
event->SetPorts(Move(ports));
NS_LITERAL_STRING("message"),
init);
event->SetTrusted(true);
bool status = false;

View File

@ -1252,25 +1252,6 @@ ExtendableMessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
aPorts = mPorts;
}
void
ExtendableMessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
{
MOZ_ASSERT(mPorts.IsEmpty());
mPorts = Move(aPorts);
}
void
ExtendableMessageEvent::SetSource(ServiceWorkerClient* aClient)
{
mClient = aClient;
}
void
ExtendableMessageEvent::SetSource(ServiceWorker* aServiceWorker)
{
mServiceWorker = aServiceWorker;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(ExtendableMessageEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ExtendableMessageEvent, Event)

View File

@ -308,12 +308,6 @@ public:
}
void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
void SetSource(ServiceWorkerClient* aClient);
void SetSource(ServiceWorker* aServiceWorker);
};
END_WORKERS_NAMESPACE

View File

@ -1,166 +0,0 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "mozilla/dom/ServiceWorkerMessageEvent.h"
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/HoldDropJSObjects.h"
#include "jsapi.h"
#include "ServiceWorker.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(ServiceWorkerMessageEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
tmp->mData.setUndefined();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorker)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessagePort)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorker)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessagePort)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mData)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerMessageEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
NS_IMPL_ADDREF_INHERITED(ServiceWorkerMessageEvent, Event)
NS_IMPL_RELEASE_INHERITED(ServiceWorkerMessageEvent, Event)
ServiceWorkerMessageEvent::ServiceWorkerMessageEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
: Event(aOwner, aPresContext, aEvent)
, mData(JS::UndefinedValue())
{
mozilla::HoldJSObjects(this);
}
ServiceWorkerMessageEvent::~ServiceWorkerMessageEvent()
{
mData.setUndefined();
DropJSObjects(this);
}
JSObject*
ServiceWorkerMessageEvent::WrapObjectInternal(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return mozilla::dom::ServiceWorkerMessageEventBinding::Wrap(aCx, this, aGivenProto);
}
void
ServiceWorkerMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
ErrorResult& aRv) const
{
aData.set(mData);
if (!JS_WrapValue(aCx, aData)) {
aRv.Throw(NS_ERROR_FAILURE);
}
}
void
ServiceWorkerMessageEvent::GetOrigin(nsAString& aOrigin) const
{
aOrigin = mOrigin;
}
void
ServiceWorkerMessageEvent::GetLastEventId(nsAString& aLastEventId) const
{
aLastEventId = mLastEventId;
}
void
ServiceWorkerMessageEvent::GetSource(Nullable<OwningServiceWorkerOrMessagePort>& aValue) const
{
if (mServiceWorker) {
aValue.SetValue().SetAsServiceWorker() = mServiceWorker;
} else if (mMessagePort) {
aValue.SetValue().SetAsMessagePort() = mMessagePort;
}
}
void
ServiceWorkerMessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
{
mMessagePort = aPort;
}
void
ServiceWorkerMessageEvent::SetSource(workers::ServiceWorker* aServiceWorker)
{
mServiceWorker = aServiceWorker;
}
void
ServiceWorkerMessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
{
aPorts = mPorts;
}
void
ServiceWorkerMessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
{
MOZ_ASSERT(mPorts.IsEmpty());
mPorts = Move(aPorts);
}
/* static */ already_AddRefed<ServiceWorkerMessageEvent>
ServiceWorkerMessageEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const ServiceWorkerMessageEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
return Constructor(t, aType, aParam, aRv);
}
/* static */ already_AddRefed<ServiceWorkerMessageEvent>
ServiceWorkerMessageEvent::Constructor(EventTarget* aEventTarget,
const nsAString& aType,
const ServiceWorkerMessageEventInit& aParam,
ErrorResult& aRv)
{
RefPtr<ServiceWorkerMessageEvent> event =
new ServiceWorkerMessageEvent(aEventTarget, nullptr, nullptr);
event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
bool trusted = event->Init(aEventTarget);
event->SetTrusted(trusted);
event->mData = aParam.mData;
event->mOrigin = aParam.mOrigin;
event->mLastEventId = aParam.mLastEventId;
if (!aParam.mSource.IsNull()) {
if (aParam.mSource.Value().IsServiceWorker()) {
event->mServiceWorker = aParam.mSource.Value().GetAsServiceWorker();
} else if (aParam.mSource.Value().IsMessagePort()) {
event->mMessagePort = aParam.mSource.Value().GetAsMessagePort();
}
}
event->mPorts.AppendElements(aParam.mPorts);
return event.forget();
}
} // namespace dom
} // namespace mozilla

View File

@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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_serviceworkermessageevent_h__
#define mozilla_dom_serviceworkermessageevent_h__
#include "mozilla/dom/Event.h"
namespace mozilla {
namespace dom {
struct ServiceWorkerMessageEventInit;
class MessagePort;
class OwningServiceWorkerOrMessagePort;
namespace workers {
class ServiceWorker;
}
class ServiceWorkerMessageEvent final : public Event
{
public:
ServiceWorkerMessageEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ServiceWorkerMessageEvent, Event)
// Forward to base class
NS_FORWARD_TO_EVENT
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
ErrorResult& aRv) const;
void GetOrigin(nsAString& aOrigin) const;
void GetLastEventId(nsAString& aLastEventId) const;
void GetSource(Nullable<OwningServiceWorkerOrMessagePort>& aValue) const;
void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
void SetSource(mozilla::dom::MessagePort* aPort);
void SetSource(workers::ServiceWorker* aServiceWorker);
void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
static already_AddRefed<ServiceWorkerMessageEvent>
Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const ServiceWorkerMessageEventInit& aEventInit,
ErrorResult& aRv);
static already_AddRefed<ServiceWorkerMessageEvent>
Constructor(EventTarget* aEventTarget,
const nsAString& aType,
const ServiceWorkerMessageEventInit& aEventInit,
ErrorResult& aRv);
protected:
~ServiceWorkerMessageEvent();
private:
JS::Heap<JS::Value> mData;
nsString mOrigin;
nsString mLastEventId;
RefPtr<workers::ServiceWorker> mServiceWorker;
RefPtr<MessagePort> mMessagePort;
nsTArray<RefPtr<MessagePort>> mPorts;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_workers_serviceworkermessageevent_h__ */

View File

@ -683,7 +683,10 @@ public:
return false;
}
nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
Sequence<OwningNonNull<MessagePort>> ports;
if (!TakeTransferredPortsAsSequence(ports)) {
return false;
}
nsCOMPtr<nsIDOMEvent> domEvent;
RefPtr<ExtendableMessageEvent> extendableEvent;
@ -699,6 +702,8 @@ public:
init.mCancelable = false;
init.mData = messageData;
init.mPorts = ports;
init.mSource.SetValue().SetAsClient() = client;
ErrorResult rv;
extendableEvent = ExtendableMessageEvent::Constructor(
@ -707,8 +712,6 @@ public:
rv.SuppressException();
return false;
}
extendableEvent->SetSource(client);
extendableEvent->SetPorts(Move(ports));
domEvent = do_QueryObject(extendableEvent);
} else {
@ -721,8 +724,7 @@ public:
EmptyString(),
EmptyString(),
nullptr,
Sequence<OwningNonNull<MessagePort>>());
event->SetPorts(Move(ports));
ports);
domEvent = do_QueryObject(event);
}
@ -6489,6 +6491,9 @@ WorkerPrivate::ConnectMessagePort(JSContext* aCx,
init.mBubbles = false;
init.mCancelable = false;
init.mSource.SetValue().SetAsMessagePort() = port;
if (!init.mPorts.AppendElement(port.forget(), fallible)) {
return false;
}
RefPtr<MessageEvent> event =
MessageEvent::Constructor(globalObject,
@ -6496,11 +6501,6 @@ WorkerPrivate::ConnectMessagePort(JSContext* aCx,
event->SetTrusted(true);
nsTArray<RefPtr<MessagePort>> ports;
ports.AppendElement(port);
event->SetPorts(Move(ports));
nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
nsEventStatus dummy = nsEventStatus_eIgnore;

View File

@ -10,7 +10,6 @@ EXPORTS.mozilla.dom += [
'ServiceWorkerCommon.h',
'ServiceWorkerContainer.h',
'ServiceWorkerEvents.h',
'ServiceWorkerMessageEvent.h',
'ServiceWorkerRegistrar.h',
'ServiceWorkerRegistration.h',
'WorkerLocation.h',
@ -66,7 +65,6 @@ UNIFIED_SOURCES += [
'ServiceWorkerManagerChild.cpp',
'ServiceWorkerManagerParent.cpp',
'ServiceWorkerManagerService.cpp',
'ServiceWorkerMessageEvent.cpp',
'ServiceWorkerPrivate.cpp',
'ServiceWorkerRegisterJob.cpp',
'ServiceWorkerRegistrar.cpp',

View File

@ -372,10 +372,7 @@ void RecordingFontUserDataDestroyFunc(void *aUserData)
RecordingFontUserData *userData =
static_cast<RecordingFontUserData*>(aUserData);
// TODO support font in b2g recordings
#ifndef MOZ_WIDGET_GONK
userData->recorder->RecordEvent(RecordedScaledFontDestruction(userData->refPtr));
#endif
delete userData;
}
@ -390,8 +387,6 @@ DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
EnsurePatternDependenciesStored(aPattern);
if (!aFont->GetUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()))) {
// TODO support font in b2g recordings
#ifndef MOZ_WIDGET_GONK
RecordedFontData fontData(aFont);
RecordedFontDetails fontDetails;
if (fontData.GetFontDetails(fontDetails)) {
@ -412,7 +407,6 @@ DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
gfxWarning() << "DrawTargetRecording::FillGlyphs failed to serialise ScaledFont";
}
}
#endif
RecordingFontUserData *userData = new RecordingFontUserData;
userData->refPtr = aFont;
userData->recorder = mRecorder;
@ -420,10 +414,7 @@ DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
&RecordingFontUserDataDestroyFunc);
}
// TODO support font in b2g recordings
#ifndef MOZ_WIDGET_GONK
mRecorder->RecordEvent(RecordedFillGlyphs(this, aFont, aPattern, aOptions, aBuffer.mGlyphs, aBuffer.mNumGlyphs));
#endif
mFinalDT->FillGlyphs(aFont, aBuffer, aPattern, aOptions, aRenderingOptions);
}

View File

@ -16,7 +16,7 @@
#endif
#include "mozilla/Tuple.h"
#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
#include "nsDebug.h"
#endif
#include "Point.h"
@ -140,7 +140,7 @@ struct BasicLogger
// in the appropriate places in that method.
static bool ShouldOutputMessage(int aLevel) {
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
return true;
#else
#if defined(MOZ_LOGGING)
@ -173,7 +173,7 @@ struct BasicLogger
// make the corresponding change in the ShouldOutputMessage method
// above.
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
printf_stderr("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
#else
#if defined(MOZ_LOGGING)

View File

@ -207,12 +207,12 @@ FINAL_LIBRARY = 'xul'
for var in ('USE_CAIRO', 'MOZ2D_HAS_MOZ_CAIRO'):
DEFINES[var] = True
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk'):
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
DEFINES['MOZ_ENABLE_FREETYPE'] = True
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk'):
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']

View File

@ -15,11 +15,6 @@
#include "mozilla/gfx/Matrix.h"
#include "mozilla/UniquePtr.h"
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#include "GLLibraryEGL.h"
#endif
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidSurfaceTexture.h"
#include "GLImages.h"
@ -152,7 +147,7 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
vTexCoord * uTexCoordMult); \n\
} \n\
";
#ifdef ANDROID /* MOZ_WIDGET_ANDROID || MOZ_WIDGET_GONK */
#ifdef ANDROID /* MOZ_WIDGET_ANDROID */
const char kTexExternalBlit_FragShaderSource[] = "\
#version 100 \n\
#extension GL_OES_EGL_image_external : require \n\
@ -684,38 +679,6 @@ GLBlitHelper::BindAndUploadEGLImage(EGLImage image, GLuint target)
mGL->fEGLImageTargetTexture2D(target, image);
}
#ifdef MOZ_WIDGET_GONK
bool
GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage)
{
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
EGLint attrs[] = {
LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
LOCAL_EGL_NONE, LOCAL_EGL_NONE
};
EGLImage image = sEGLLibrary.fCreateImage(sEGLLibrary.Display(),
EGL_NO_CONTEXT,
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
grallocImage->GetNativeBuffer(), attrs);
if (image == EGL_NO_IMAGE)
return false;
int oldBinding = 0;
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL_OES, &oldBinding);
BindAndUploadEGLImage(image, LOCAL_GL_TEXTURE_EXTERNAL_OES);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
sEGLLibrary.fDestroyImage(sEGLLibrary.Display(), image);
mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL_OES, oldBinding);
return true;
}
#endif
#ifdef MOZ_WIDGET_ANDROID
#define ATTACH_WAIT_MS 50
@ -873,13 +836,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
srcOrigin = OriginPos::TopLeft;
break;
#ifdef MOZ_WIDGET_GONK
case ImageFormat::GRALLOC_PLANAR_YCBCR:
type = ConvertGralloc;
srcOrigin = OriginPos::TopLeft;
break;
#endif
#ifdef MOZ_WIDGET_ANDROID
case ImageFormat::SURFACE_TEXTURE:
type = ConvertSurfaceTexture;
@ -915,11 +871,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
mGL->fViewport(0, 0, destSize.width, destSize.height);
switch (type) {
#ifdef MOZ_WIDGET_GONK
case ConvertGralloc:
return BlitGrallocImage(static_cast<layers::GrallocImage*>(srcImage));
#endif
case ConvertPlanarYCbCr: {
const auto saved = mGL->GetIntAs<GLint>(LOCAL_GL_UNPACK_ALIGNMENT);
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1);

View File

@ -107,9 +107,6 @@ class GLBlitHelper final
void BindAndUploadYUVTexture(Channel which, uint32_t width, uint32_t height, void* data, bool allocation);
void BindAndUploadEGLImage(EGLImage image, GLuint target);
#ifdef MOZ_WIDGET_GONK
bool BlitGrallocImage(layers::GrallocImage* grallocImage);
#endif
bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage);
#ifdef MOZ_WIDGET_ANDROID
// Blit onto the current FB.

View File

@ -16,12 +16,6 @@
#endif
#if defined(XP_UNIX)
#ifdef MOZ_WIDGET_GONK
#include "libdisplay/GonkDisplay.h"
#include "nsWindow.h"
#include "nsScreenManagerGonk.h"
#endif
#ifdef MOZ_WIDGET_ANDROID
#include <android/native_window.h>
#include <android/native_window_jni.h>
@ -30,13 +24,6 @@
#ifdef ANDROID
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#ifdef MOZ_WIDGET_GONK
#include "cutils/properties.h"
#include <ui/GraphicBuffer.h>
using namespace android;
#endif
#endif
#define GLES2_LIB "libGLESv2.so"
@ -237,17 +224,6 @@ GLContextEGL::~GLContextEGL()
sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
sEGLLibrary.UnsetCachedCurrentContext();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 17
if (!mIsOffscreen) {
// In ICS, SurfaceFlinger's DisplayHardware::fini() does not destroy the EGLSurface associated with the
// native framebuffer. Destroying it causes crashes in the ICS emulator
// EGL implementation, specifically because the egl_window_surface_t dtor
// calls nativeWindow->cancelBuffer and FramebufferNativeWindow does not initialize
// the cancelBuffer function pointer, see bug 986836
return;
}
#endif
mozilla::gl::DestroySurface(mSurface);
}
@ -437,12 +413,6 @@ GLContextEGL::SwapBuffers()
? mSurfaceOverride
: mSurface;
if (surface) {
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 17
if (!mIsOffscreen) {
// eglSwapBuffers() is called by hwcomposer.
return true;
}
#endif
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), surface);
} else {
return false;
@ -633,9 +603,6 @@ static const EGLint kEGLConfigAttribsRGBA32[] = {
LOCAL_EGL_GREEN_SIZE, 8,
LOCAL_EGL_BLUE_SIZE, 8,
LOCAL_EGL_ALPHA_SIZE, 8,
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
LOCAL_EGL_FRAMEBUFFER_TARGET_ANDROID, LOCAL_EGL_TRUE,
#endif
EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS
};
@ -667,29 +634,6 @@ CreateConfig(EGLConfig* aConfig, int32_t depth, nsIWidget* aWidget)
return false;
}
#ifdef MOZ_WIDGET_GONK
// On gonk, it's important to select a configuration with the
// the correct order as well as bits per channel.
// EGL_NATIVE_VISUAL_ID gives us the Android pixel format which
// is an enum that tells us both order and bits per channel.
// For example -
// HAL_PIXEL_FORMAT_RGBX_8888
// HAL_PIXEL_FORMAT_BGRA_8888
// HAL_PIXEL_FORMAT_RGB_565
nsWindow* window = static_cast<nsWindow*>(aWidget);
for (int j = 0; j < ncfg; ++j) {
EGLConfig config = configs[j];
EGLint format;
if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
LOCAL_EGL_NATIVE_VISUAL_ID, &format) &&
format == window->GetScreen()->GetSurfaceFormat())
{
*aConfig = config;
return true;
}
}
#endif
for (int j = 0; j < ncfg; ++j) {
EGLConfig config = configs[j];
EGLint r, g, b, a;

View File

@ -431,11 +431,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
Unused << GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0],
nullptr, nullptr, false);
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID,
"GFX: Couldn't find eglQueryStringImplementationANDROID");
#endif
InitClientExtensions();
const auto lookupFunction =

View File

@ -24,11 +24,6 @@
#include "mozilla/gfx/DeviceManagerDx.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "SharedSurfaceGralloc.h"
#include "nsXULAppAPI.h"
#endif
#ifdef XP_MACOSX
#include "SharedSurfaceIO.h"
#endif
@ -89,8 +84,6 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
#if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_GONK)
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, ipcChannel, flags);
#elif defined(GL_PROVIDER_GLX)
if (sGLXLibrary.UseTextureFromPixmap())
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);

View File

@ -1,294 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; 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/. */
#include "mozilla/Preferences.h"
#include "mozilla/UniquePtr.h"
#include "SharedSurfaceGralloc.h"
#include "GLContext.h"
#include "SharedSurface.h"
#include "GLLibraryEGL.h"
#include "mozilla/layers/GrallocTextureClient.h"
#include "mozilla/layers/ShadowLayers.h"
#include "ui/GraphicBuffer.h"
#include "../layers/ipc/ShadowLayers.h"
#include "ScopedGLHelpers.h"
#include "gfxPlatform.h"
#include "gfxPrefs.h"
#define DEBUG_GRALLOC
#ifdef DEBUG_GRALLOC
#define DEBUG_PRINT(...) do { printf_stderr(__VA_ARGS__); } while (0)
#else
#define DEBUG_PRINT(...) do { } while (0)
#endif
namespace mozilla {
namespace gl {
using namespace mozilla::layers;
using namespace android;
SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: SurfaceFactory(SharedSurfaceType::Gralloc, prodGL, caps, allocator, flags)
{
MOZ_ASSERT(mAllocator);
}
/*static*/ UniquePtr<SharedSurface_Gralloc>
SharedSurface_Gralloc::Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
layers::TextureFlags flags,
LayersIPCChannel* allocator)
{
GLLibraryEGL* egl = &sEGLLibrary;
MOZ_ASSERT(egl);
UniquePtr<SharedSurface_Gralloc> ret;
DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
if (!HasExtensions(egl, prodGL))
return Move(ret);
gfxContentType type = hasAlpha ? gfxContentType::COLOR_ALPHA
: gfxContentType::COLOR;
GrallocTextureData* texData = GrallocTextureData::CreateForGLRendering(
size, gfxPlatform::GetPlatform()->Optimal2DFormatForContent(type), allocator
);
if (!texData) {
return Move(ret);
}
RefPtr<TextureClient> grallocTC = new TextureClient(texData, flags, allocator);
sp<GraphicBuffer> buffer = texData->GetGraphicBuffer();
EGLDisplay display = egl->Display();
EGLClientBuffer clientBuffer = buffer->getNativeBuffer();
EGLint attrs[] = {
LOCAL_EGL_NONE, LOCAL_EGL_NONE
};
EGLImage image = egl->fCreateImage(display,
EGL_NO_CONTEXT,
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
clientBuffer, attrs);
if (!image) {
return Move(ret);
}
prodGL->MakeCurrent();
GLuint prodTex = 0;
prodGL->fGenTextures(1, &prodTex);
ScopedBindTexture autoTex(prodGL, prodTex);
prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
prodGL->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, image);
egl->fDestroyImage(display, image);
ret.reset( new SharedSurface_Gralloc(prodGL, size, hasAlpha, egl,
allocator, grallocTC,
prodTex) );
DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p,"
" GraphicBuffer %p.\n",
ret.get(), buffer.get());
return Move(ret);
}
SharedSurface_Gralloc::SharedSurface_Gralloc(GLContext* prodGL,
const gfx::IntSize& size,
bool hasAlpha,
GLLibraryEGL* egl,
layers::LayersIPCChannel* allocator,
layers::TextureClient* textureClient,
GLuint prodTex)
: SharedSurface(SharedSurfaceType::Gralloc,
AttachmentType::GLTexture,
prodGL,
size,
hasAlpha,
true)
, mEGL(egl)
, mSync(0)
, mAllocator(allocator)
, mTextureClient(textureClient)
, mProdTex(prodTex)
{
}
bool
SharedSurface_Gralloc::HasExtensions(GLLibraryEGL* egl, GLContext* gl)
{
return egl->HasKHRImageBase() &&
gl->IsExtensionSupported(GLContext::OES_EGL_image);
}
SharedSurface_Gralloc::~SharedSurface_Gralloc()
{
DEBUG_PRINT("[SharedSurface_Gralloc %p] destroyed\n", this);
if (!mGL || !mGL->MakeCurrent())
return;
mGL->fDeleteTextures(1, &mProdTex);
if (mSync) {
MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
mSync = 0;
}
}
void
SharedSurface_Gralloc::ProducerReleaseImpl()
{
if (mSync) {
MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
mSync = 0;
}
bool disableSyncFence = false;
// Disable sync fence on AdrenoTM200.
// AdrenoTM200's sync fence does not work correctly. See Bug 1022205.
if (mGL->Renderer() == GLRenderer::AdrenoTM200) {
disableSyncFence = true;
}
// When Android native fences are available, try
// them first since they're more likely to work.
// Android native fences are also likely to perform better.
if (!disableSyncFence &&
mEGL->IsExtensionSupported(GLLibraryEGL::ANDROID_native_fence_sync))
{
mGL->MakeCurrent();
EGLSync sync = mEGL->fCreateSync(mEGL->Display(),
LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID,
nullptr);
if (sync) {
mGL->fFlush();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
int fenceFd = mEGL->fDupNativeFenceFDANDROID(mEGL->Display(), sync);
if (fenceFd != -1) {
mEGL->fDestroySync(mEGL->Display(), sync);
mTextureClient->SetAcquireFenceHandle(FenceHandle(new FenceHandle::FdObj(fenceFd)));
} else {
mSync = sync;
}
#else
mSync = sync;
#endif
return;
}
}
if (!disableSyncFence &&
mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync))
{
mGL->MakeCurrent();
mSync = mEGL->fCreateSync(mEGL->Display(),
LOCAL_EGL_SYNC_FENCE,
nullptr);
if (mSync) {
mGL->fFlush();
return;
}
}
// We should be able to rely on genlock write locks/read locks.
// But they're broken on some configs, and even a glFinish doesn't
// work. glReadPixels seems to, though.
if (gfxPrefs::GrallocFenceWithReadPixels()) {
mGL->MakeCurrent();
UniquePtr<char[]> buf = MakeUnique<char[]>(4);
mGL->fReadPixels(0, 0, 1, 1, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, buf.get());
}
}
void
SharedSurface_Gralloc::WaitForBufferOwnership()
{
mTextureClient->WaitForBufferOwnership();
}
bool
SharedSurface_Gralloc::ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor)
{
mTextureClient->mWorkaroundAnnoyingSharedSurfaceOwnershipIssues = true;
return mTextureClient->ToSurfaceDescriptor(*out_descriptor);
}
bool
SharedSurface_Gralloc::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface)
{
MOZ_ASSERT(out_surface);
sp<GraphicBuffer> buffer = static_cast<GrallocTextureData*>(
mTextureClient->GetInternalData()
)->GetGraphicBuffer();
const uint8_t* grallocData = nullptr;
auto result = buffer->lock(
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_NEVER,
const_cast<void**>(reinterpret_cast<const void**>(&grallocData))
);
if (result == BAD_VALUE) {
return false;
}
gfx::DataSourceSurface::ScopedMap map(out_surface, gfx::DataSourceSurface::WRITE);
if (!map.IsMapped()) {
buffer->unlock();
return false;
}
uint32_t stride = buffer->getStride() * android::bytesPerPixel(buffer->getPixelFormat());
uint32_t height = buffer->getHeight();
uint32_t width = buffer->getWidth();
for (uint32_t i = 0; i < height; i++) {
memcpy(map.GetData() + i * map.GetStride(),
grallocData + i * stride, width * 4);
}
buffer->unlock();
android::PixelFormat srcFormat = buffer->getPixelFormat();
MOZ_ASSERT(srcFormat == PIXEL_FORMAT_RGBA_8888 ||
srcFormat == PIXEL_FORMAT_BGRA_8888 ||
srcFormat == PIXEL_FORMAT_RGBX_8888);
bool isSrcRGB = srcFormat == PIXEL_FORMAT_RGBA_8888 ||
srcFormat == PIXEL_FORMAT_RGBX_8888;
gfx::SurfaceFormat destFormat = out_surface->GetFormat();
MOZ_ASSERT(destFormat == gfx::SurfaceFormat::R8G8B8X8 ||
destFormat == gfx::SurfaceFormat::R8G8B8A8 ||
destFormat == gfx::SurfaceFormat::B8G8R8X8 ||
destFormat == gfx::SurfaceFormat::B8G8R8A8);
bool isDestRGB = destFormat == gfx::SurfaceFormat::R8G8B8X8 ||
destFormat == gfx::SurfaceFormat::R8G8B8A8;
if (isSrcRGB != isDestRGB) {
SwapRAndBComponents(out_surface);
}
return true;
}
} // namespace gl
} // namespace mozilla

View File

@ -1,104 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; 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/. */
#ifndef SHARED_SURFACE_GRALLOC_H_
#define SHARED_SURFACE_GRALLOC_H_
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "SharedSurface.h"
namespace mozilla {
namespace layers {
class LayersIPCChannel;
class TextureClient;
}
namespace gl {
class GLContext;
class GLLibraryEGL;
class SharedSurface_Gralloc
: public SharedSurface
{
public:
static UniquePtr<SharedSurface_Gralloc> Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
layers::TextureFlags flags,
layers::LayersIPCChannel* allocator);
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
return (SharedSurface_Gralloc*)surf;
}
protected:
GLLibraryEGL* const mEGL;
EGLSync mSync;
RefPtr<layers::LayersIPCChannel> mAllocator;
RefPtr<layers::TextureClient> mTextureClient;
const GLuint mProdTex;
SharedSurface_Gralloc(GLContext* prodGL,
const gfx::IntSize& size,
bool hasAlpha,
GLLibraryEGL* egl,
layers::LayersIPCChannel* allocator,
layers::TextureClient* textureClient,
GLuint prodTex);
static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl);
public:
virtual ~SharedSurface_Gralloc();
virtual void ProducerAcquireImpl() override {}
virtual void ProducerReleaseImpl() override;
virtual void WaitForBufferOwnership() override;
virtual void LockProdImpl() override {}
virtual void UnlockProdImpl() override {}
virtual GLuint ProdTexture() override {
return mProdTex;
}
layers::TextureClient* GetTextureClient() {
return mTextureClient;
}
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
virtual bool ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface) override;
};
class SurfaceFactory_Gralloc
: public SurfaceFactory
{
public:
SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
bool hasAlpha = mReadCaps.alpha;
UniquePtr<SharedSurface> ret;
if (mAllocator) {
ret = SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha,
mFlags, mAllocator);
}
return Move(ret);
}
};
} /* namespace gl */
} /* namespace mozilla */
#endif /* SHARED_SURFACE_GRALLOC_H_ */

View File

@ -19,8 +19,6 @@ elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
gl_provider = 'GLX'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
gl_provider = 'EGL'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
gl_provider = 'EGL'
if CONFIG['MOZ_GL_PROVIDER']:
gl_provider = CONFIG['MOZ_GL_PROVIDER']
@ -84,12 +82,6 @@ if CONFIG['MOZ_ENABLE_SKIA_GPU']:
# Suppress warnings from Skia header files.
SOURCES['SkiaGLGlue.cpp'].flags += ['-Wno-implicit-fallthrough']
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
UNIFIED_SOURCES += ['SharedSurfaceGralloc.cpp']
EXPORTS += ['SharedSurfaceGralloc.h']
LOCAL_INCLUDES += ['/widget/gonk']
LOCAL_INCLUDES += ['%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], 'hardware/libhardware/include')]
if gl_provider == 'CGL':
# These files include Mac headers that are unfriendly to unified builds
SOURCES += [

View File

@ -43,7 +43,7 @@ public:
YUVColorSpace aYUVColorSpace,
TextureFlags aTextureFlags);
virtual bool Lock(OpenMode aMode, FenceHandle*) override { return true; }
virtual bool Lock(OpenMode aMode) override { return true; }
virtual void Unlock() override {}

View File

@ -14,13 +14,6 @@
#include "gfx2DGlue.h"
#include "nsAppRunner.h"
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
#include "libdisplay/GonkDisplay.h" // for GonkDisplay
#include <ui/Fence.h>
#include "nsWindow.h"
#include "nsScreenManagerGonk.h"
#endif
namespace mozilla {
namespace layers {
@ -607,48 +600,10 @@ Compositor::IsValid() const
return !!mParent;
}
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
void
Compositor::SetDispAcquireFence(Layer* aLayer)
{
// OpenGL does not provide ReleaseFence for rendering.
// Instead use DispAcquireFence as layer buffer's ReleaseFence
// to prevent flickering and tearing.
// DispAcquireFence is DisplaySurface's AcquireFence.
// AcquireFence will be signaled when a buffer's content is available.
// See Bug 974152.
if (!aLayer || !mWidget) {
return;
}
nsWindow* window = static_cast<nsWindow*>(mWidget->RealWidget());
RefPtr<FenceHandle::FdObj> fence = new FenceHandle::FdObj(
window->GetScreen()->GetPrevDispAcquireFd());
mReleaseFenceHandle.Merge(FenceHandle(fence));
}
FenceHandle
Compositor::GetReleaseFence()
{
if (!mReleaseFenceHandle.IsValid()) {
return FenceHandle();
}
RefPtr<FenceHandle::FdObj> fdObj = mReleaseFenceHandle.GetDupFdObj();
return FenceHandle(fdObj);
}
#else
void
Compositor::SetDispAcquireFence(Layer* aLayer)
{
}
FenceHandle
Compositor::GetReleaseFence()
{
return FenceHandle();
}
#endif
} // namespace layers
} // namespace mozilla

View File

@ -17,7 +17,6 @@
#include "mozilla/gfx/Types.h" // for Float
#include "mozilla/gfx/Triangle.h" // for Triangle, TexturedTriangle
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticTypes, etc
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/layers/LayersTypes.h" // for LayersBackend
#include "mozilla/widget/CompositorWidget.h"
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
@ -435,8 +434,6 @@ public:
virtual void SetDispAcquireFence(Layer* aLayer);
virtual FenceHandle GetReleaseFence();
/**
* Post-rendering stuff if the rendering is done outside of this Compositor
* e.g., by Composer2D.
@ -683,10 +680,6 @@ protected:
bool mIsDestroyed;
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
FenceHandle mReleaseFenceHandle;
#endif
gfx::Color mClearColor;
gfx::Color mDefaultClearColor;

View File

@ -1,478 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "GrallocImages.h"
#include <stddef.h> // for size_t
#include <stdint.h> // for int8_t, uint8_t, uint32_t, etc
#include "nsDebug.h" // for NS_WARNING, NS_PRECONDITION
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/GrallocTextureClient.h"
#include "gfx2DGlue.h"
#include "YCbCrUtils.h" // for YCbCr conversions
#include <ColorConverter.h>
#include <OMX_IVCommon.h>
using namespace mozilla::ipc;
using namespace android;
#define ALIGN(x, align) ((x + align - 1) & ~(align - 1))
namespace mozilla {
namespace layers {
int32_t GrallocImage::sColorIdMap[] = {
HAL_PIXEL_FORMAT_YCbCr_420_P, OMX_COLOR_FormatYUV420Planar,
HAL_PIXEL_FORMAT_YCbCr_422_P, OMX_COLOR_FormatYUV422Planar,
HAL_PIXEL_FORMAT_YCbCr_420_SP, OMX_COLOR_FormatYUV420SemiPlanar,
HAL_PIXEL_FORMAT_YCrCb_420_SP, -1,
HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO, -1,
HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED, HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED,
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS, HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS,
HAL_PIXEL_FORMAT_YV12, OMX_COLOR_FormatYUV420Planar,
HAL_PIXEL_FORMAT_RGBA_8888, -1,
0, 0
};
struct GraphicBufferAutoUnlock {
android::sp<GraphicBuffer> mGraphicBuffer;
GraphicBufferAutoUnlock(android::sp<GraphicBuffer>& aGraphicBuffer)
: mGraphicBuffer(aGraphicBuffer) { }
~GraphicBufferAutoUnlock() { mGraphicBuffer->unlock(); }
};
GrallocImage::GrallocImage()
: RecyclingPlanarYCbCrImage(nullptr)
{
mFormat = ImageFormat::GRALLOC_PLANAR_YCBCR;
}
GrallocImage::~GrallocImage()
{
}
bool
GrallocImage::SetData(const Data& aData)
{
MOZ_ASSERT(!mTextureClient, "TextureClient is already set");
NS_PRECONDITION(aData.mYSize.width % 2 == 0, "Image should have even width");
NS_PRECONDITION(aData.mYSize.height % 2 == 0, "Image should have even height");
NS_PRECONDITION(aData.mYStride % 16 == 0, "Image should have stride of multiple of 16 pixels");
mData = aData;
mSize = aData.mPicSize;
if (gfxPlatform::GetPlatform()->IsInGonkEmulator()) {
// Emulator does not support HAL_PIXEL_FORMAT_YV12.
return false;
}
RefPtr<LayersIPCChannel> allocator = ImageBridgeChild::GetSingleton();
GrallocTextureData* texData = GrallocTextureData::Create(mData.mYSize, HAL_PIXEL_FORMAT_YV12,
gfx::BackendType::NONE,
GraphicBuffer::USAGE_SW_READ_OFTEN |
GraphicBuffer::USAGE_SW_WRITE_OFTEN |
GraphicBuffer::USAGE_HW_TEXTURE,
allocator
);
if (!texData) {
return false;
}
mTextureClient = new TextureClient(texData, TextureFlags::DEFAULT, allocator);
sp<GraphicBuffer> graphicBuffer = texData->GetGraphicBuffer();
void* vaddr;
if (graphicBuffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
&vaddr) != OK) {
return false;
}
uint8_t* yChannel = static_cast<uint8_t*>(vaddr);
gfx::IntSize ySize = aData.mYSize;
int32_t yStride = graphicBuffer->getStride();
uint8_t* vChannel = yChannel + (yStride * ySize.height);
gfx::IntSize uvSize = gfx::IntSize(ySize.width / 2,
ySize.height / 2);
// Align to 16 bytes boundary
int32_t uvStride = ((yStride / 2) + 15) & ~0x0F;
uint8_t* uChannel = vChannel + (uvStride * uvSize.height);
// Memory outside of the image width may not writable. If the stride
// equals to the image width then we can use only one copy.
if (yStride == mData.mYStride &&
yStride == ySize.width) {
memcpy(yChannel, mData.mYChannel, yStride * ySize.height);
} else {
for (int i = 0; i < ySize.height; i++) {
memcpy(yChannel + i * yStride,
mData.mYChannel + i * mData.mYStride,
ySize.width);
}
}
if (uvStride == mData.mCbCrStride &&
uvStride == uvSize.width) {
memcpy(uChannel, mData.mCbChannel, uvStride * uvSize.height);
memcpy(vChannel, mData.mCrChannel, uvStride * uvSize.height);
} else {
for (int i = 0; i < uvSize.height; i++) {
memcpy(uChannel + i * uvStride,
mData.mCbChannel + i * mData.mCbCrStride,
uvSize.width);
memcpy(vChannel + i * uvStride,
mData.mCrChannel + i * mData.mCbCrStride,
uvSize.width);
}
}
graphicBuffer->unlock();
// Initialze the channels' addresses.
// Do not cache the addresses when gralloc buffer is not locked.
// gralloc hal could map gralloc buffer only when the buffer is locked,
// though some gralloc hals implementation maps it when it is allocated.
mData.mYChannel = nullptr;
mData.mCrChannel = nullptr;
mData.mCbChannel = nullptr;
return true;
}
void
GrallocImage::AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
{
mTextureClient = aGraphicBuffer;
mSize = aSize;
}
/**
* Converts YVU420 semi planar frames to RGB565, possibly taking different
* stride values.
* Needed because the Android ColorConverter class assumes that the Y and UV
* channels have equal stride.
*/
static void
ConvertYVU420SPToRGB565(void *aYData, uint32_t aYStride,
void *aUData, void *aVData, uint32_t aUVStride,
void *aOut,
uint32_t aWidth, uint32_t aHeight)
{
uint8_t *y = (uint8_t*)aYData;
bool isCbCr;
int8_t *uv;
if (aUData < aVData) {
// The color format is YCbCr
isCbCr = true;
uv = (int8_t*)aUData;
} else {
// The color format is YCrCb
isCbCr = false;
uv = (int8_t*)aVData;
}
uint16_t *rgb = (uint16_t*)aOut;
for (size_t i = 0; i < aHeight; i++) {
for (size_t j = 0; j < aWidth; j++) {
int8_t d, e;
if (isCbCr) {
d = uv[j & ~1] - 128;
e = uv[j | 1] - 128;
} else {
d = uv[j | 1] - 128;
e = uv[j & ~1] - 128;
}
// Constants taken from https://en.wikipedia.org/wiki/YUV
int32_t r = (298 * y[j] + 409 * e + 128) >> 11;
int32_t g = (298 * y[j] - 100 * d - 208 * e + 128) >> 10;
int32_t b = (298 * y[j] + 516 * d + 128) >> 11;
r = r > 0x1f ? 0x1f : r < 0 ? 0 : r;
g = g > 0x3f ? 0x3f : g < 0 ? 0 : g;
b = b > 0x1f ? 0x1f : b < 0 ? 0 : b;
*rgb++ = (uint16_t)(r << 11 | g << 5 | b);
}
y += aYStride;
if (i % 2) {
uv += aUVStride;
}
}
}
/**
* Converts the format of vendor-specific YVU420(planar and semi-planar)
* with the help of GraphicBuffer::lockYCbCr. In this way, we can convert
* the YUV color format without awaring actual definition/enumeration
* of vendor formats.
*/
static status_t
ConvertVendorYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
gfx::DataSourceSurface *aSurface,
gfx::DataSourceSurface::MappedSurface *aMappedSurface)
{
status_t rv = BAD_VALUE;
#if ANDROID_VERSION >= 18
android_ycbcr ycbcr;
// Check if the vendor provides explicit addresses of Y/Cb/Cr buffer from lockYCbCr
rv = aBuffer->lockYCbCr(android::GraphicBuffer::USAGE_SW_READ_OFTEN, &ycbcr);
if (rv != OK) {
NS_WARNING("Couldn't lock graphic buffer using lockYCbCr()");
return rv;
}
GraphicBufferAutoUnlock unlock(aBuffer);
uint32_t width = aSurface->GetSize().width;
uint32_t height = aSurface->GetSize().height;
if (ycbcr.chroma_step == 2) {
// From the system/core/include/system/graphics.h
// @chroma_step is the distance in bytes from one chroma pixel value to
// the next. This is 2 bytes for semiplanar (because chroma values are
// interleaved and each chroma value is one byte) and 1 for planar.
ConvertYVU420SPToRGB565(ycbcr.y, ycbcr.ystride,
ycbcr.cb, ycbcr.cr, ycbcr.cstride,
aMappedSurface->mData,
width, height);
} else {
layers::PlanarYCbCrData ycbcrData;
ycbcrData.mYChannel = static_cast<uint8_t*>(ycbcr.y);
ycbcrData.mYStride = ycbcr.ystride;
ycbcrData.mYSize = aSurface->GetSize();
ycbcrData.mCbChannel = static_cast<uint8_t*>(ycbcr.cb);
ycbcrData.mCrChannel = static_cast<uint8_t*>(ycbcr.cr);
ycbcrData.mCbCrStride = ycbcr.cstride;
ycbcrData.mCbCrSize = aSurface->GetSize() / 2;
ycbcrData.mPicSize = aSurface->GetSize();
gfx::ConvertYCbCrToRGB(ycbcrData,
aSurface->GetFormat(),
aSurface->GetSize(),
aMappedSurface->mData,
aMappedSurface->mStride);
}
#endif
return rv;
}
static status_t
ConvertOmxYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
gfx::DataSourceSurface *aSurface,
gfx::DataSourceSurface::MappedSurface *aMappedSurface,
const layers::PlanarYCbCrData& aYcbcrData)
{
uint32_t omxFormat =
GrallocImage::GetOmxFormat(aBuffer->getPixelFormat());
if (!omxFormat) {
NS_WARNING("Unknown color format");
return BAD_VALUE;
}
status_t rv;
uint8_t *buffer;
rv = aBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void **>(&buffer));
if (rv != OK) {
NS_WARNING("Couldn't lock graphic buffer");
return BAD_VALUE;
}
GraphicBufferAutoUnlock unlock(aBuffer);
uint32_t format = aBuffer->getPixelFormat();
uint32_t width = aSurface->GetSize().width;
uint32_t height = aSurface->GetSize().height;
uint32_t stride = aBuffer->getStride();
if (format == GrallocImage::HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
// The Adreno hardware decoder aligns image dimensions to a multiple of 32,
// so we have to account for that here
uint32_t alignedWidth = ALIGN(width, 32);
uint32_t alignedHeight = ALIGN(height, 32);
uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
uint32_t uvStride = 2 * ALIGN(width / 2, 32);
ConvertYVU420SPToRGB565(buffer, alignedWidth,
buffer + uvOffset + 1,
buffer + uvOffset,
uvStride,
aMappedSurface->mData,
width, height);
return OK;
}
if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
uint32_t uvOffset = height * stride;
ConvertYVU420SPToRGB565(buffer, stride,
buffer + uvOffset + 1,
buffer + uvOffset,
stride,
aMappedSurface->mData,
width, height);
return OK;
}
if (format == HAL_PIXEL_FORMAT_YV12) {
// Depend on platforms, it is possible for HW decoder to output YV12 format.
// It means the mData won't be configured during the SetData API because the
// yuv data has already stored in GraphicBuffer. Here we try to confgiure the
// mData if it doesn't contain valid configuration.
layers::PlanarYCbCrData ycbcrData = aYcbcrData;
if (!ycbcrData.mYChannel) {
ycbcrData.mYChannel = buffer;
ycbcrData.mYSkip = 0;
ycbcrData.mYStride = aBuffer->getStride();
ycbcrData.mYSize = aSurface->GetSize();
ycbcrData.mCbSkip = 0;
ycbcrData.mCbCrSize = aSurface->GetSize() / 2;
ycbcrData.mPicSize = aSurface->GetSize();
ycbcrData.mCrChannel = buffer + ycbcrData.mYStride * aBuffer->getHeight();
ycbcrData.mCrSkip = 0;
// Align to 16 bytes boundary
ycbcrData.mCbCrStride = ALIGN(ycbcrData.mYStride / 2, 16);
ycbcrData.mCbChannel = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
} else {
// Update channels' address.
// Gralloc buffer could map gralloc buffer only when the buffer is locked.
ycbcrData.mYChannel = buffer;
ycbcrData.mCrChannel = buffer + ycbcrData.mYStride * aBuffer->getHeight();
ycbcrData.mCbChannel = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
}
gfx::ConvertYCbCrToRGB(ycbcrData,
aSurface->GetFormat(),
aSurface->GetSize(),
aMappedSurface->mData,
aMappedSurface->mStride);
return OK;
}
if (format == HAL_PIXEL_FORMAT_RGBA_8888) {
uint32_t* src = (uint32_t*)(buffer);
uint16_t* dest = (uint16_t*)(aMappedSurface->mData);
// Convert RGBA8888 to RGB565
for (size_t i = 0; i < width * height; i++) {
uint32_t r = ((*src >> 0 ) & 0xFF);
uint32_t g = ((*src >> 8 ) & 0xFF);
uint32_t b = ((*src >> 16) & 0xFF);
*dest++ = ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);
src++;
}
return OK;
}
android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)omxFormat,
OMX_COLOR_Format16bitRGB565);
if (!colorConverter.isValid()) {
NS_WARNING("Invalid color conversion");
return BAD_VALUE;
}
uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5_UINT16);
rv = colorConverter.convert(buffer, width, height,
0, 0, width - 1, height - 1 /* source crop */,
aMappedSurface->mData, pixelStride, height,
0, 0, width - 1, height - 1 /* dest crop */);
if (rv) {
NS_WARNING("OMX color conversion failed");
return BAD_VALUE;
}
return OK;
}
already_AddRefed<gfx::DataSourceSurface>
GetDataSourceSurfaceFrom(android::sp<android::GraphicBuffer>& aGraphicBuffer,
gfx::IntSize aSize,
const layers::PlanarYCbCrData& aYcbcrData)
{
MOZ_ASSERT(aGraphicBuffer.get());
RefPtr<gfx::DataSourceSurface> surface =
gfx::Factory::CreateDataSourceSurface(aSize, gfx::SurfaceFormat::R5G6B5_UINT16);
if (NS_WARN_IF(!surface)) {
return nullptr;
}
gfx::DataSourceSurface::MappedSurface mappedSurface;
if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) {
NS_WARNING("Could not map DataSourceSurface");
return nullptr;
}
int32_t rv;
rv = ConvertOmxYUVFormatToRGB565(aGraphicBuffer, surface, &mappedSurface, aYcbcrData);
if (rv == OK) {
surface->Unmap();
return surface.forget();
}
rv = ConvertVendorYUVFormatToRGB565(aGraphicBuffer, surface, &mappedSurface);
surface->Unmap();
if (rv != OK) {
NS_WARNING("Unknown color format");
return nullptr;
}
return surface.forget();
}
already_AddRefed<gfx::SourceSurface>
GrallocImage::GetAsSourceSurface()
{
if (!mTextureClient) {
return nullptr;
}
android::sp<GraphicBuffer> graphicBuffer = GetGraphicBuffer();
RefPtr<gfx::DataSourceSurface> surface =
GetDataSourceSurfaceFrom(graphicBuffer, mSize, mData);
return surface.forget();
}
android::sp<android::GraphicBuffer>
GrallocImage::GetGraphicBuffer() const
{
if (!mTextureClient) {
return nullptr;
}
return static_cast<GrallocTextureData*>(mTextureClient->GetInternalData())->GetGraphicBuffer();
}
void*
GrallocImage::GetNativeBuffer()
{
if (!mTextureClient) {
return nullptr;
}
android::sp<android::GraphicBuffer> graphicBuffer = GetGraphicBuffer();
if (!graphicBuffer.get()) {
return nullptr;
}
return graphicBuffer->getNativeBuffer();
}
TextureClient*
GrallocImage::GetTextureClient(KnowsCompositor* aForwarder)
{
return mTextureClient;
}
} // namespace layers
} // namespace mozilla

View File

@ -1,136 +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 GRALLOCIMAGES_H
#define GRALLOCIMAGES_H
#ifdef MOZ_WIDGET_GONK
#include "ImageLayers.h"
#include "ImageContainer.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
#include "mozilla/layers/FenceUtils.h"
#include "mozilla/layers/LayersSurfaces.h"
#include <ui/GraphicBuffer.h>
namespace mozilla {
namespace layers {
class TextureClient;
already_AddRefed<gfx::DataSourceSurface>
GetDataSourceSurfaceFrom(android::sp<android::GraphicBuffer>& aGraphicBuffer,
gfx::IntSize aSize,
const layers::PlanarYCbCrData& aYcbcrData);
/**
* The YUV format supported by Android HAL
*
* 4:2:0 - CbCr width and height is half that of Y.
*
* This format assumes
* - an even width
* - an even height
* - a horizontal stride multiple of 16 pixels
* - a vertical stride equal to the height
*
* y_size = stride * height
* c_size = ALIGN(stride/2, 16) * height/2
* size = y_size + c_size * 2
* cr_offset = y_size
* cb_offset = y_size + c_size
*
* The Image that is rendered is the picture region defined by
* mPicX, mPicY and mPicSize. The size of the rendered image is
* mPicSize, not mYSize or mCbCrSize.
*/
class GrallocImage : public RecyclingPlanarYCbCrImage
{
typedef PlanarYCbCrData Data;
static int32_t sColorIdMap[];
public:
GrallocImage();
virtual ~GrallocImage();
/**
* This makes a copy of the data buffers, in order to support functioning
* in all different layer managers.
*/
virtual bool SetData(const Data& aData);
using RecyclingPlanarYCbCrImage::AdoptData;
/**
* Share the SurfaceDescriptor without making the copy, in order
* to support functioning in all different layer managers.
*/
void AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
// From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
enum {
/* OEM specific HAL formats */
HAL_PIXEL_FORMAT_YCbCr_422_P = 0x102,
HAL_PIXEL_FORMAT_YCbCr_420_P = 0x103,
HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x109,
HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO = 0x10A,
HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x7FA30C03,
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS = 0x7FA30C04,
};
enum {
GRALLOC_SW_UAGE = android::GraphicBuffer::USAGE_SOFTWARE_MASK,
};
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
void* GetNativeBuffer();
virtual bool IsValid() { return !!mTextureClient; }
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual GrallocImage* AsGrallocImage() override
{
return this;
}
virtual uint8_t* GetBuffer()
{
return static_cast<uint8_t*>(GetNativeBuffer());
}
int GetUsage()
{
return (static_cast<ANativeWindowBuffer*>(GetNativeBuffer()))->usage;
}
static int GetOmxFormat(int aFormat)
{
uint32_t omxFormat = 0;
for (int i = 0; sColorIdMap[i]; i += 2) {
if (sColorIdMap[i] == aFormat) {
omxFormat = sColorIdMap[i + 1];
break;
}
}
return omxFormat;
}
private:
RefPtr<TextureClient> mTextureClient;
};
} // namespace layers
} // namespace mozilla
#endif
#endif /* GRALLOCIMAGES_H */

View File

@ -24,9 +24,6 @@
#include "mozilla/gfx/gfxVars.h"
#include "nsISupportsUtils.h" // for NS_IF_ADDREF
#include "YCbCrUtils.h" // for YCbCr conversions
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#endif
#include "gfx2DGlue.h"
#include "mozilla/gfx/2D.h"
@ -178,18 +175,6 @@ ImageContainer::CreateSharedRGBImage()
return new SharedRGBImage(mImageClient);
}
#ifdef MOZ_WIDGET_GONK
RefPtr<OverlayImage>
ImageContainer::CreateOverlayImage()
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mImageClient || !mImageClient->AsImageClientSingle()) {
return nullptr;
}
return new OverlayImage();
}
#endif
void
ImageContainer::SetCurrentImageInternal(const nsTArray<NonOwningImage>& aImages)
{

View File

@ -152,7 +152,6 @@ class SharedPlanarYCbCrImage;
class PlanarYCbCrImage;
class TextureClient;
class KnowsCompositor;
class GrallocImage;
class NVImage;
struct ImageBackendData
@ -171,8 +170,6 @@ class SharedRGBImage;
class SurfaceTextureImage;
#elif defined(XP_MACOSX)
class MacIOSurfaceImage;
#elif defined(MOZ_WIDGET_GONK)
class OverlayImage;
#endif
/**
@ -215,11 +212,6 @@ public:
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() = 0;
virtual GrallocImage* AsGrallocImage()
{
return nullptr;
}
virtual bool IsValid() { return true; }
virtual uint8_t* GetBuffer() { return nullptr; }
@ -385,10 +377,6 @@ public:
// Factory methods for shared image types.
RefPtr<SharedRGBImage> CreateSharedRGBImage();
#ifdef MOZ_WIDGET_GONK
RefPtr<OverlayImage> CreateOverlayImage();
#endif
struct NonOwningImage {
explicit NonOwningImage(Image* aImage = nullptr,
TimeStamp aTimeStamp = TimeStamp(),
@ -909,54 +897,6 @@ private:
TextureFlags mTextureFlags;
};
#ifdef MOZ_WIDGET_GONK
class OverlayImage : public Image {
/**
* OverlayImage is a special Image type that does not hold any buffer.
* It only hold an Id as identifier to the real content of the Image.
* Therefore, OverlayImage must be handled by some specialized hardware(e.g. HWC)
* to show its content.
*/
public:
struct Data {
int32_t mOverlayId;
gfx::IntSize mSize;
};
struct SidebandStreamData {
GonkNativeHandle mStream;
gfx::IntSize mSize;
};
OverlayImage() : Image(nullptr, ImageFormat::OVERLAY_IMAGE) { mOverlayId = INVALID_OVERLAY; }
void SetData(const Data& aData)
{
mOverlayId = aData.mOverlayId;
mSize = aData.mSize;
mSidebandStream = GonkNativeHandle();
}
void SetData(const SidebandStreamData& aData)
{
mSidebandStream = aData.mStream;
mSize = aData.mSize;
mOverlayId = INVALID_OVERLAY;
}
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; } ;
int32_t GetOverlayId() { return mOverlayId; }
GonkNativeHandle& GetSidebandStream() { return mSidebandStream; }
gfx::IntSize GetSize() { return mSize; }
private:
int32_t mOverlayId;
GonkNativeHandle mSidebandStream;
gfx::IntSize mSize;
};
#endif
} // namespace layers
} // namespace mozilla

View File

@ -461,101 +461,6 @@ protected:
int64_t mFrameStamp;
};
#ifdef MOZ_WIDGET_GONK
// B2G optimization.
class DebugGLGraphicBuffer final: public DebugGLData {
public:
DebugGLGraphicBuffer(void *layerRef,
GLenum target,
GLuint name,
const LayerRenderState &aState,
bool aIsMask,
UniquePtr<Packet> aPacket)
: DebugGLData(Packet::TEXTURE),
mLayerRef(reinterpret_cast<uint64_t>(layerRef)),
mTarget(target),
mName(name),
mState(aState),
mIsMask(aIsMask),
mPacket(Move(aPacket))
{
}
virtual bool Write() override {
return WriteToStream(*mPacket);
}
bool TryPack(bool packData) {
android::sp<android::GraphicBuffer> buffer = mState.mSurface;
MOZ_ASSERT(buffer.get());
mPacket->set_type(mDataType);
TexturePacket* tp = mPacket->mutable_texture();
tp->set_layerref(mLayerRef);
tp->set_name(mName);
tp->set_target(mTarget);
tp->set_ismask(mIsMask);
int pFormat = buffer->getPixelFormat();
if (HAL_PIXEL_FORMAT_RGBA_8888 != pFormat &&
HAL_PIXEL_FORMAT_RGBX_8888 != pFormat) {
return false;
}
int32_t stride = buffer->getStride() * 4;
int32_t height = buffer->getHeight();
int32_t width = buffer->getWidth();
int32_t sourceSize = stride * height;
if (sourceSize <= 0) {
return false;
}
uint32_t dFormat = mState.FormatRBSwapped() ?
LOCAL_GL_BGRA : LOCAL_GL_RGBA;
tp->set_dataformat(dFormat);
tp->set_dataformat((1 << 16 | tp->dataformat()));
tp->set_width(width);
tp->set_height(height);
tp->set_stride(stride);
if (packData) {
uint8_t* grallocData = nullptr;
if (BAD_VALUE == buffer->lock(GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_NEVER,
reinterpret_cast<void**>(&grallocData)))
{
return false;
}
// Do not return before buffer->unlock();
auto compressedData =
MakeUnique<char[]>(LZ4::maxCompressedSize(sourceSize));
int compressedSize = LZ4::compress((char*)grallocData,
sourceSize,
compressedData.get());
if (compressedSize > 0) {
tp->set_data(compressedData.get(), compressedSize);
} else {
buffer->unlock();
return false;
}
buffer->unlock();
}
return true;
}
private:
uint64_t mLayerRef;
GLenum mTarget;
GLuint mName;
const LayerRenderState &mState;
bool mIsMask;
UniquePtr<Packet> mPacket;
};
#endif
class DebugGLTextureData final: public DebugGLData {
public:
DebugGLTextureData(GLContext* cx,
@ -947,13 +852,6 @@ private:
bool aFlipY,
bool aIsMask,
UniquePtr<Packet> aPacket);
#ifdef MOZ_WIDGET_GONK
static bool SendGraphicBuffer(GLContext* aGLContext,
void* aLayerRef,
TextureSourceOGL* aSource,
const TexturedEffect* aEffect,
bool aIsMask);
#endif
static void SetAndSendTexture(GLContext* aGLContext,
void* aLayerRef,
TextureSourceOGL* aSource,
@ -1110,51 +1008,6 @@ SenderHelper::SendTextureSource(GLContext* aGLContext,
}
#ifdef MOZ_WIDGET_GONK
bool
SenderHelper::SendGraphicBuffer(GLContext* aGLContext,
void* aLayerRef,
TextureSourceOGL* aSource,
const TexturedEffect* aEffect,
bool aIsMask) {
GLuint texID = GetTextureID(aGLContext, aSource);
if (HasTextureIdBeenSent(texID)) {
return false;
}
if (!aEffect->mState.mSurface.get()) {
return false;
}
// Expose packet creation here, so we could dump primary texture effect attributes.
auto packet = MakeUnique<layerscope::Packet>();
layerscope::TexturePacket* texturePacket = packet->mutable_texture();
texturePacket->set_mpremultiplied(aEffect->mPremultiplied);
DumpFilter(texturePacket, aEffect->mSamplingFilter);
DumpRect(texturePacket->mutable_mtexturecoords(), aEffect->mTextureCoords);
GLenum target = aSource->GetTextureTarget();
mozilla::UniquePtr<DebugGLGraphicBuffer> package =
MakeUnique<DebugGLGraphicBuffer>(aLayerRef, target, texID, aEffect->mState, aIsMask, Move(packet));
// The texure content in this TexureHost is not altered,
// we don't need to send it again.
bool changed = gLayerScopeManager.GetContentMonitor()->IsChangedOrNew(
aEffect->mState.mTexture);
if (!package->TryPack(changed)) {
return false;
}
// Transfer ownership to SocketManager.
gLayerScopeManager.GetSocketManager()->AppendDebugData(package.release());
sSentTextureIds.push_back(texID);
gLayerScopeManager.CurrentSession().mTexIDs.push_back(texID);
gLayerScopeManager.GetContentMonitor()->ClearChangedHost(aEffect->mState.mTexture);
return true;
}
#endif
void
SenderHelper::SetAndSendTexture(GLContext* aGLContext,
void* aLayerRef,
@ -1180,12 +1033,6 @@ SenderHelper::SendTexturedEffect(GLContext* aGLContext,
return;
}
#ifdef MOZ_WIDGET_GONK
if (SendGraphicBuffer(aGLContext, aLayerRef, source, aEffect, false)) {
return;
}
#endif
// Fallback texture sending path.
SetAndSendTexture(aGLContext, aLayerRef, source, aEffect);
}

View File

@ -366,8 +366,6 @@ AppendToString(std::stringstream& aStream, ImageFormat format,
aStream << "ImageFormat::PLANAR_YCBCR"; break;
case ImageFormat::GRALLOC_PLANAR_YCBCR:
aStream << "ImageFormat::GRALLOC_PLANAR_YCBCR"; break;
case ImageFormat::GONK_CAMERA_IMAGE:
aStream << "ImageFormat::GONK_CAMERA_IMAGE"; break;
case ImageFormat::SHARED_RGB:
aStream << "ImageFormat::SHARED_RGB"; break;
case ImageFormat::CAIRO_SURFACE:

View File

@ -5,21 +5,12 @@
#include "LayersTypes.h"
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
#endif
namespace mozilla {
namespace layers {
LayerRenderState::LayerRenderState()
: mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
, mHasOwnOffset(false)
#ifdef MOZ_WIDGET_GONK
, mSurface(nullptr)
, mOverlayId(INVALID_OVERLAY)
, mTexture(nullptr)
#endif
{
}
@ -27,12 +18,6 @@ LayerRenderState::LayerRenderState(const LayerRenderState& aOther)
: mFlags(aOther.mFlags)
, mHasOwnOffset(aOther.mHasOwnOffset)
, mOffset(aOther.mOffset)
#ifdef MOZ_WIDGET_GONK
, mSurface(aOther.mSurface)
, mOverlayId(aOther.mOverlayId)
, mSize(aOther.mSize)
, mTexture(aOther.mTexture)
#endif
{
}
@ -40,19 +25,5 @@ LayerRenderState::~LayerRenderState()
{
}
#ifdef MOZ_WIDGET_GONK
LayerRenderState::LayerRenderState(android::GraphicBuffer* aSurface,
const gfx::IntSize& aSize,
LayerRenderStateFlags aFlags,
TextureHost* aTexture)
: mFlags(aFlags)
, mHasOwnOffset(false)
, mSurface(aSurface)
, mOverlayId(INVALID_OVERLAY)
, mSize(aSize)
, mTexture(aTexture)
{}
#endif
} // namespace layers
} // namespace mozilla

View File

@ -8,11 +8,6 @@
#include <stdint.h> // for uint32_t
#ifdef MOZ_WIDGET_GONK
#include <utils/RefBase.h>
#include "mozilla/layers/GonkNativeHandle.h"
#endif
#include "Units.h"
#include "mozilla/gfx/Point.h" // for IntPoint
#include "mozilla/TypedEnumBits.h"
@ -86,8 +81,6 @@ enum class LayerRenderStateFlags : int8_t {
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags)
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
struct LayerRenderState {
// Constructors and destructor are defined in LayersTypes.cpp so we don't
// have to pull in a definition for GraphicBuffer.h here. In KK at least,
@ -97,36 +90,6 @@ struct LayerRenderState {
LayerRenderState(const LayerRenderState& aOther);
~LayerRenderState();
#ifdef MOZ_WIDGET_GONK
LayerRenderState(android::GraphicBuffer* aSurface,
const gfx::IntSize& aSize,
LayerRenderStateFlags aFlags,
TextureHost* aTexture);
bool OriginBottomLeft() const
{ return bool(mFlags & LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT); }
bool BufferRotated() const
{ return bool(mFlags & LayerRenderStateFlags::BUFFER_ROTATION); }
bool FormatRBSwapped() const
{ return bool(mFlags & LayerRenderStateFlags::FORMAT_RB_SWAP); }
void SetOverlayId(const int32_t& aId)
{ mOverlayId = aId; }
void SetSidebandStream(const GonkNativeHandle& aStream)
{
mSidebandStream = aStream;
}
android::GraphicBuffer* GetGrallocBuffer() const
{ return mSurface.get(); }
const GonkNativeHandle& GetSidebandStream()
{ return mSidebandStream; }
#endif
void SetOffset(const nsIntPoint& aOffset)
{
mOffset = aOffset;
@ -139,17 +102,6 @@ struct LayerRenderState {
bool mHasOwnOffset;
// the location of the layer's origin on mSurface
nsIntPoint mOffset;
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
#ifdef MOZ_WIDGET_GONK
// surface to render
android::sp<android::GraphicBuffer> mSurface;
int32_t mOverlayId;
// size of mSurface
gfx::IntSize mSize;
TextureHost* mTexture;
GonkNativeHandle mSidebandStream;
#endif
};
enum class ScaleMode : int8_t {

View File

@ -406,20 +406,6 @@ ComputeBufferRect(const IntRect& aRequestedRect)
// rendering glitch, and guarantees image rows can be SIMD'd for
// even r5g6b5 surfaces pretty much everywhere.
rect.width = std::max(aRequestedRect.width, 64);
#ifdef MOZ_WIDGET_GONK
// Set a minumum height to guarantee a minumum height of buffers we
// allocate. Some GL implementations fail to render gralloc textures
// with a height 9px-16px. It happens on Adreno 200. Adreno 320 does not
// have this problem. 32 is choosed as alignment of gralloc buffers.
// See Bug 873937.
// Increase the height only when the requested height is more than 0.
// See Bug 895976.
// XXX it might be better to disable it on the gpu that does not have
// the height problem.
if (rect.height > 0) {
rect.height = std::max(aRequestedRect.height, 32);
}
#endif
return rect;
}
@ -480,7 +466,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer,
}
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
#else
if (!aLayer->GetParent() ||

View File

@ -18,7 +18,7 @@ namespace layers {
class DIBTextureData : public TextureData
{
public:
virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
virtual bool Lock(OpenMode) override { return true; }
virtual void Unlock() override {}

View File

@ -22,10 +22,6 @@
#include "nsRegion.h" // for nsIntRegion
#include "nsTArray.h" // for nsTArray
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
#include <ui/Fence.h>
#endif
namespace mozilla {
struct TileUnit {};

View File

@ -1,306 +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 "GrallocTextureHostBasic.h"
#include "GrallocImages.h" // for GetDataSourceSurfaceFrom()
#include "mozilla/layers/SharedBufferManagerParent.h"
#if ANDROID_VERSION >= 17
#include <ui/Fence.h>
#endif
namespace mozilla {
namespace layers {
static gfx::SurfaceFormat
HalFormatToSurfaceFormat(int aHalFormat, TextureFlags aFlags)
{
bool swapRB = bool(aFlags & TextureFlags::RB_SWAPPED);
switch (aHalFormat) {
case android::PIXEL_FORMAT_BGRA_8888:
return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
case android::PIXEL_FORMAT_RGBA_8888:
return swapRB ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::R8G8B8A8;
case android::PIXEL_FORMAT_RGBX_8888:
return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
case android::PIXEL_FORMAT_RGB_565:
return gfx::SurfaceFormat::R5G6B5_UINT16;
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCbCr_422_I:
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
case HAL_PIXEL_FORMAT_YV12:
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
#endif
// Needs convert to RGB565
return gfx::SurfaceFormat::R5G6B5_UINT16;
default:
if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
// Reserved range for HAL specific formats.
// Needs convert to RGB565
return gfx::SurfaceFormat::R5G6B5_UINT16;
} else {
MOZ_CRASH("GFX: Unhandled HAL pixel format");
return gfx::SurfaceFormat::UNKNOWN; // not reached
}
}
}
static bool
NeedsConvertFromYUVtoRGB565(int aHalFormat)
{
switch (aHalFormat) {
case android::PIXEL_FORMAT_BGRA_8888:
case android::PIXEL_FORMAT_RGBA_8888:
case android::PIXEL_FORMAT_RGBX_8888:
case android::PIXEL_FORMAT_RGB_565:
return false;
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCbCr_422_I:
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
case HAL_PIXEL_FORMAT_YV12:
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
#endif
return true;
default:
if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
// Reserved range for HAL specific formats.
return true;
} else {
MOZ_CRASH("GFX: Unhandled HAL pixel format YUV");
return false; // not reached
}
}
}
GrallocTextureHostBasic::GrallocTextureHostBasic(
TextureFlags aFlags,
const SurfaceDescriptorGralloc& aDescriptor)
: TextureHost(aFlags)
, mGrallocHandle(aDescriptor)
, mSize(0, 0)
, mCropSize(0, 0)
, mFormat(gfx::SurfaceFormat::UNKNOWN)
, mIsOpaque(aDescriptor.isOpaque())
{
android::GraphicBuffer* grallocBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
MOZ_ASSERT(grallocBuffer);
if (grallocBuffer) {
mFormat =
HalFormatToSurfaceFormat(grallocBuffer->getPixelFormat(),
aFlags & TextureFlags::RB_SWAPPED);
mSize = gfx::IntSize(grallocBuffer->getWidth(), grallocBuffer->getHeight());
mCropSize = mSize;
} else {
printf_stderr("gralloc buffer is nullptr\n");
}
}
bool
GrallocTextureHostBasic::Lock()
{
if (!mCompositor || !IsValid()) {
return false;
}
if (mTextureSource) {
return true;
}
android::sp<android::GraphicBuffer> graphicBuffer =
GetGraphicBufferFromDesc(mGrallocHandle);
MOZ_ASSERT(graphicBuffer.get());
RefPtr<gfx::DataSourceSurface> surf;
if (NeedsConvertFromYUVtoRGB565(graphicBuffer->getPixelFormat())) {
PlanarYCbCrData ycbcrData;
surf = GetDataSourceSurfaceFrom(graphicBuffer,
mCropSize,
ycbcrData);
} else {
uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN;
int32_t rv = graphicBuffer->lock(usage,
reinterpret_cast<void**>(&mMappedBuffer));
if (rv) {
mMappedBuffer = nullptr;
NS_WARNING("Couldn't lock graphic buffer");
return false;
}
surf = gfx::Factory::CreateWrappingDataSourceSurface(
mMappedBuffer,
graphicBuffer->getStride() * gfx::BytesPerPixel(mFormat),
mCropSize,
mFormat);
}
if (surf) {
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
mTextureSource->Update(surf, nullptr);
return true;
}
mMappedBuffer = nullptr;
return false;
}
bool
GrallocTextureHostBasic::IsValid() const
{
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
return graphicBuffer != nullptr;
}
bool
GrallocTextureHostBasic::BindTextureSource(CompositableTextureSourceRef& aTexture)
{
aTexture = mTextureSource;
return !!aTexture;
}
void
GrallocTextureHostBasic::UnbindTextureSource()
{
TextureHost::UnbindTextureSource();
ClearTextureSource();
}
void
GrallocTextureHostBasic::ClearTextureSource()
{
mTextureSource = nullptr;
if (mMappedBuffer) {
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
MOZ_ASSERT(graphicBuffer);
mMappedBuffer = nullptr;
graphicBuffer->unlock();
}
}
void
GrallocTextureHostBasic::SetCompositor(Compositor* aCompositor)
{
BasicCompositor* compositor = AssertBasicCompositor(aCompositor);
if (!compositor) {
return;
}
mCompositor = compositor;
if (mTextureSource) {
mTextureSource->SetCompositor(compositor);
}
}
Compositor*
GrallocTextureHostBasic::GetCompositor()
{
return mCompositor;
}
gfx::SurfaceFormat
GrallocTextureHostBasic::GetFormat() const {
return mFormat;
}
void
GrallocTextureHostBasic::WaitAcquireFenceHandleSyncComplete()
{
if (!mAcquireFenceHandle.IsValid()) {
return;
}
#if ANDROID_VERSION >= 17
RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
android::sp<android::Fence> fence(
new android::Fence(fdObj->GetAndResetFd()));
// Wait fece complete with timeout.
// If a source of the fence becomes invalid because of error,
// fene complete is not signaled. See Bug 1061435.
int rv = fence->wait(400 /*400 msec*/);
if (rv != android::OK) {
NS_ERROR("failed to wait fence complete");
}
#endif
}
void
GrallocTextureHostBasic::SetCropRect(nsIntRect aCropRect)
{
MOZ_ASSERT(aCropRect.TopLeft() == gfx::IntPoint(0, 0));
MOZ_ASSERT(!aCropRect.IsEmpty());
MOZ_ASSERT(aCropRect.width <= mSize.width);
MOZ_ASSERT(aCropRect.height <= mSize.height);
gfx::IntSize cropSize(aCropRect.width, aCropRect.height);
if (mCropSize == cropSize) {
return;
}
mCropSize = cropSize;
ClearTextureSource();
}
void
GrallocTextureHostBasic::DeallocateSharedData()
{
ClearTextureSource();
if (mGrallocHandle.buffer().type() != MaybeMagicGrallocBufferHandle::Tnull_t) {
MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
base::ProcessId owner;
if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
owner = handle.get_GrallocBufferRef().mOwner;
}
else {
owner = handle.get_MagicGrallocBufferHandle().mRef.mOwner;
}
SharedBufferManagerParent::DropGrallocBuffer(owner, mGrallocHandle);
}
}
void
GrallocTextureHostBasic::ForgetSharedData()
{
ClearTextureSource();
}
void
GrallocTextureHostBasic::DeallocateDeviceData()
{
ClearTextureSource();
}
LayerRenderState
GrallocTextureHostBasic::GetRenderState()
{
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
if (graphicBuffer) {
LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT;
if (mIsOpaque) {
flags |= LayerRenderStateFlags::OPAQUE;
}
if (mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT) {
flags |= LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT;
}
if (mFlags & TextureFlags::RB_SWAPPED) {
flags |= LayerRenderStateFlags::FORMAT_RB_SWAP;
}
return LayerRenderState(graphicBuffer,
mCropSize,
flags,
this);
}
return LayerRenderState();
}
} // namespace layers
} // namespace mozilla

View File

@ -1,88 +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_GRALLOCTEXTUREHOST_BASIC_H
#define MOZILLA_GFX_GRALLOCTEXTUREHOST_BASIC_H
#include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
#include "mozilla/layers/TextureHostBasic.h"
namespace mozilla {
namespace layers {
class BasicCompositor;
/**
* A TextureHost for shared gralloc
*
* Most of the logic actually happens in GrallocTextureSourceBasic.
*/
class GrallocTextureHostBasic : public TextureHost
{
public:
GrallocTextureHostBasic(TextureFlags aFlags,
const SurfaceDescriptorGralloc& aDescriptor);
virtual void SetCompositor(Compositor* aCompositor) override;
virtual Compositor* GetCompositor() override;
virtual bool Lock() override;
virtual gfx::SurfaceFormat GetFormat() const override;
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
virtual void UnbindTextureSource() override;
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
{
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
}
virtual void WaitAcquireFenceHandleSyncComplete() override;
virtual gfx::IntSize GetSize() const override { return mCropSize; }
virtual void SetCropRect(nsIntRect aCropRect) override;
virtual void DeallocateSharedData() override;
virtual void ForgetSharedData() override;
virtual void DeallocateDeviceData() override;
virtual LayerRenderState GetRenderState() override;
bool IsValid() const;
void ClearTextureSource();
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() override { return "GrallocTextureHostBasic"; }
#endif
protected:
RefPtr<BasicCompositor> mCompositor;
RefPtr<DataTextureSource> mTextureSource;
SurfaceDescriptorGralloc mGrallocHandle;
// gralloc buffer size.
gfx::IntSize mSize;
// Size reported by TextureClient, can be different in some cases (video?),
// used by LayerRenderState.
gfx::IntSize mCropSize;
gfx::SurfaceFormat mFormat;
bool mIsOpaque;
/**
* Points to a mapped gralloc buffer when TextureSource is valid.
*/
uint8_t* mMappedBuffer;
};
} // namespace layers
} // namespace mozilla
#endif // MOZILLA_GFX_GRALLOCTEXTUREHOST_BASIC_H

View File

@ -34,7 +34,7 @@ X11TextureData::X11TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
bool
X11TextureData::Lock(OpenMode aMode, FenceHandle*)
X11TextureData::Lock(OpenMode aMode)
{
return true;
}

View File

@ -21,7 +21,7 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual bool Lock(OpenMode aMode, FenceHandle*) override;
virtual bool Lock(OpenMode aMode) override;
virtual void Unlock() override;

View File

@ -7,9 +7,6 @@
#ifdef XP_MACOSX
#include "MacIOSurfaceTextureHostBasic.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "GrallocTextureHostBasic.h"
#endif
using namespace mozilla::gl;
using namespace mozilla::gfx;
@ -28,13 +25,6 @@ CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
aDesc.get_SurfaceDescriptorMacIOSurface();
return MakeAndAddRef<MacIOSurfaceTextureHostBasic>(aFlags, desc);
}
#endif
#ifdef MOZ_WIDGET_GONK
if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc) {
const SurfaceDescriptorGralloc& desc =
aDesc.get_SurfaceDescriptorGralloc();
return MakeAndAddRef<GrallocTextureHostBasic>(aFlags, desc);
}
#endif
return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
}

View File

@ -17,7 +17,6 @@
#include "mozilla/layers/AsyncCanvasRenderer.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
#include "mozilla/layers/GrallocTextureClient.h"
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/layers/TextureClientOGL.h"

View File

@ -238,7 +238,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
//
// Desktop does not support async zoom yet, so we ignore this for those
// platforms.
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_UIKIT)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_UIKIT)
if (mWidget && mWidget->GetOwningTabChild()) {
mCompositorMightResample = AsyncPanZoomEnabled();
}

View File

@ -150,7 +150,7 @@ ClientTiledPaintedLayer::BeginPaint()
if (!displayPortAncestor || !scrollAncestor) {
// No displayport or scroll ancestor, so we can't do progressive rendering.
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_WIDGET_ANDROID)
// Both Android and b2g on phones are guaranteed to have a displayport set, so this
// should never happen.
NS_WARNING("Tiled PaintedLayer with no scrollable container ancestor");

View File

@ -27,22 +27,6 @@ namespace layers {
using namespace mozilla::gfx;
void
RemoveTextureFromCompositableTracker::ReleaseTextureClient()
{
if (mTextureClient &&
mTextureClient->GetAllocator() &&
!mTextureClient->GetAllocator()->UsesImageBridge())
{
RefPtr<TextureClientReleaseTask> task = new TextureClientReleaseTask(mTextureClient);
RefPtr<LayersIPCChannel> allocator = mTextureClient->GetAllocator();
mTextureClient = nullptr;
allocator->GetMessageLoop()->PostTask(task.forget());
} else {
mTextureClient = nullptr;
}
}
void
CompositableClient::InitIPDLActor(PCompositableChild* aActor, uint64_t aAsyncID)
{

View File

@ -12,7 +12,6 @@
#include "mozilla/Assertions.h" // for MOZ_CRASH
#include "mozilla/RefPtr.h" // for already_AddRefed, RefCounted
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/LayersTypes.h" // for LayersBackend, TextureDumpMode
#include "mozilla/layers/TextureClient.h" // for TextureClient
@ -29,55 +28,6 @@ class CompositableChild;
class PCompositableChild;
class TextureClientRecycleAllocator;
/**
* Handle RemoveTextureFromCompositableAsync() transaction.
*/
class RemoveTextureFromCompositableTracker : public AsyncTransactionTracker {
public:
explicit RemoveTextureFromCompositableTracker(AsyncTransactionWaiter* aWaiter = nullptr)
: AsyncTransactionTracker(aWaiter)
{
MOZ_COUNT_CTOR(RemoveTextureFromCompositableTracker);
}
protected:
~RemoveTextureFromCompositableTracker()
{
MOZ_COUNT_DTOR(RemoveTextureFromCompositableTracker);
ReleaseTextureClient();
}
public:
virtual void Complete() override
{
ReleaseTextureClient();
}
virtual void Cancel() override
{
ReleaseTextureClient();
}
virtual void SetTextureClient(TextureClient* aTextureClient) override
{
ReleaseTextureClient();
mTextureClient = aTextureClient;
}
virtual void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle) override
{
if (mTextureClient) {
mTextureClient->SetReleaseFenceHandle(aReleaseFenceHandle);
}
}
protected:
void ReleaseTextureClient();
private:
RefPtr<TextureClient> mTextureClient;
};
/**
* CompositableClient manages the texture-specific logic for composite layers,
* independently of the layer. It is the content side of a CompositableClient/

View File

@ -24,7 +24,7 @@ public:
virtual void FillInfo(TextureData::Info& aInfo) const override;
virtual bool Lock(OpenMode, FenceHandle*) override { return true; };
virtual bool Lock(OpenMode) override { return true; };
virtual void Unlock() override {};

View File

@ -33,10 +33,6 @@
#include "nsISupportsImpl.h" // for Image::Release, etc
#include "nsRect.h" // for mozilla::gfx::IntRect
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#endif
namespace mozilla {
namespace layers {
@ -70,21 +66,6 @@ ImageClient::CreateImageClient(CompositableType aCompositableHostType,
void
ImageClient::RemoveTexture(TextureClient* aTexture)
{
RemoveTextureWithWaiter(aTexture);
}
void
ImageClient::RemoveTextureWithWaiter(TextureClient* aTexture,
AsyncTransactionWaiter* aAsyncTransactionWaiter)
{
if (aAsyncTransactionWaiter &&
GetForwarder()->GetTextureForwarder()->UsesImageBridge()) {
RefPtr<AsyncTransactionTracker> request =
new RemoveTextureFromCompositableTracker(aAsyncTransactionWaiter);
GetForwarder()->RemoveTextureFromCompositableAsync(request, this, aTexture);
return;
}
MOZ_ASSERT(!aAsyncTransactionWaiter);
GetForwarder()->RemoveTextureFromCompositable(this, aTexture);
}
@ -101,12 +82,12 @@ TextureInfo ImageClientSingle::GetTextureInfo() const
}
void
ImageClientSingle::FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter)
ImageClientSingle::FlushAllImages()
{
MOZ_ASSERT(GetForwarder()->GetTextureForwarder()->UsesImageBridge());
for (auto& b : mBuffers) {
RemoveTextureWithWaiter(b.mTextureClient, aAsyncTransactionWaiter);
RemoveTexture(b.mTextureClient);
}
mBuffers.Clear();
}
@ -222,28 +203,6 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
for (auto& img : images) {
Image* image = img.mImage;
#ifdef MOZ_WIDGET_GONK
if (image->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
OverlayImage* overlayImage = static_cast<OverlayImage*>(image);
OverlaySource source;
if (overlayImage->GetSidebandStream().IsValid()) {
// Duplicate GonkNativeHandle::NhObj for ipc,
// since ParamTraits<GonkNativeHandle>::Write() absorbs native_handle_t.
RefPtr<GonkNativeHandle::NhObj> nhObj = overlayImage->GetSidebandStream().GetDupNhObj();
GonkNativeHandle handle(nhObj);
if (!handle.IsValid()) {
return false;
}
source.handle() = OverlayHandle(handle);
} else {
source.handle() = OverlayHandle(overlayImage->GetOverlayId());
}
source.size() = overlayImage->GetSize();
GetForwarder()->UseOverlaySource(this, source, image->GetPictureRect());
continue;
}
#endif
RefPtr<TextureClient> texture = image->GetTextureClient(GetForwarder());
const bool hasTextureClient = !!texture;

View File

@ -11,7 +11,6 @@
#include "mozilla/Attributes.h" // for override
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
#include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
@ -25,7 +24,6 @@ namespace layers {
class ClientLayer;
class CompositableForwarder;
class AsyncTransactionTracker;
class Image;
class ImageContainer;
class ShadowableLayer;
@ -64,13 +62,10 @@ public:
* asynchronously remove all the textures used by the image client.
*
*/
virtual void FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter) {}
virtual void FlushAllImages() {}
virtual void RemoveTexture(TextureClient* aTexture) override;
void RemoveTextureWithWaiter(TextureClient* aTexture,
AsyncTransactionWaiter* aAsyncTransactionWaiter = nullptr);
virtual ImageClientSingle* AsImageClientSingle() { return nullptr; }
static already_AddRefed<TextureClient> CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwarder);
@ -102,7 +97,7 @@ public:
virtual TextureInfo GetTextureInfo() const override;
virtual void FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter) override;
virtual void FlushAllImages() override;
ImageClientSingle* AsImageClientSingle() override { return this; }

View File

@ -10,7 +10,6 @@
#include "gfxPlatform.h" // for gfxPlatform
#include "mozilla/Atomics.h"
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
#include "mozilla/layers/AsyncTransactionTracker.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/ImageBridgeChild.h"
@ -53,11 +52,6 @@
#include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include <cutils/properties.h>
#include "mozilla/layers/GrallocTextureClient.h"
#endif
#if 0
#define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
#else
@ -422,7 +416,6 @@ void TextureClient::Destroy(bool aForceSync)
mBorrowedDrawTarget = nullptr;
mReadLock = nullptr;
CancelWaitFenceHandleOnImageBridge();
RefPtr<TextureChild> actor = mActor;
mActor = nullptr;
@ -497,10 +490,6 @@ TextureClient::Lock(OpenMode aMode)
return mOpenMode == aMode;
}
if (!!mFenceHandleWaiter && (aMode & OpenMode::OPEN_WRITE)) {
mFenceHandleWaiter->WaitComplete();
}
if (aMode & OpenMode::OPEN_WRITE && IsReadLocked()) {
NS_WARNING("Attempt to Lock a texture that is being read by the compositor!");
return false;
@ -508,8 +497,7 @@ TextureClient::Lock(OpenMode aMode)
LockActor();
FenceHandle* fence = (mReleaseFenceHandle.IsValid() && (aMode & OpenMode::OPEN_WRITE)) ? &mReleaseFenceHandle : nullptr;
mIsLocked = mData->Lock(aMode, fence);
mIsLocked = mData->Lock(aMode);
mOpenMode = aMode;
auto format = GetFormat();
@ -720,21 +708,6 @@ TextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
return mData ? mData->Serialize(aOutDescriptor) : false;
}
void
TextureClient::WaitForBufferOwnership(bool aWaitReleaseFence)
{
if (mFenceHandleWaiter) {
mFenceHandleWaiter->WaitComplete();
}
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 21
if (aWaitReleaseFence && mReleaseFenceHandle.IsValid()) {
mData->WaitForFence(&mReleaseFenceHandle);
mReleaseFenceHandle = FenceHandle();
}
#endif
}
// static
PTextureChild*
TextureClient::CreateIPDLActor()
@ -829,46 +802,6 @@ TextureClient::SetAddedToCompositableClient()
}
}
void
TextureClient::WaitFenceHandleOnImageBridge(Mutex& aMutex)
{
MOZ_ASSERT(NS_IsMainThread());
aMutex.AssertCurrentThreadOwns();
if (!mFenceHandleWaiter) {
mFenceHandleWaiter = new AsyncTransactionWaiter();
}
MOZ_ASSERT(mFenceHandleWaiter->GetWaitCount() <= 1);
if (mFenceHandleWaiter->GetWaitCount() > 0) {
return;
}
mFenceHandleWaiter->IncrementWaitCount();
}
void
TextureClient::ClearWaitFenceHandleOnImageBridge(Mutex& aMutex)
{
aMutex.AssertCurrentThreadOwns();
if (!mFenceHandleWaiter) {
return;
}
MOZ_ASSERT(mFenceHandleWaiter->GetWaitCount() <= 1);
if (mFenceHandleWaiter->GetWaitCount() == 0) {
return;
}
mFenceHandleWaiter->DecrementWaitCount();
}
void
TextureClient::CancelWaitFenceHandleOnImageBridge()
{
if (!NeedsFenceHandle() || GetFlags() & TextureFlags::RECYCLE) {
return;
}
ImageBridgeChild::GetSingleton()->CancelWaitFenceHandle(this);
}
void CancelTextureClientRecycle(uint64_t aTextureId, LayersIPCChannel* aAllocator)
{
if (!aAllocator) {
@ -894,7 +827,6 @@ TextureClient::CancelWaitForRecycle()
CancelTextureClientRecycle(mSerial, GetAllocator());
return;
}
CancelWaitFenceHandleOnImageBridge();
}
/* static */ void
@ -1131,13 +1063,6 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
#endif
#endif
#ifdef MOZ_WIDGET_GONK
if (!data && aSize.width <= aMaxTextureSize && aSize.height <= aMaxTextureSize) {
data = GrallocTextureData::CreateForDrawing(aSize, aFormat, moz2DBackend,
aAllocator);
}
#endif
#ifdef XP_MACOSX
if (!data && gfxPrefs::UseIOSurfaceTextures()) {
data = MacIOSurfaceTextureData::Create(aSize, aFormat, moz2DBackend);

View File

@ -17,7 +17,6 @@
#include "mozilla/gfx/2D.h" // for DrawTarget
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/ipc/Shmem.h" // for Shmem
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
@ -42,17 +41,12 @@ namespace mozilla {
#define GFX_DEBUG_TRACK_CLIENTS_IN_POOL 1
#endif
namespace gl {
class SharedSurface_Gralloc;
}
namespace layers {
class AsyncTransactionWaiter;
class BufferTextureData;
class CompositableForwarder;
class KnowsCompositor;
class GrallocTextureData;
class LayersIPCChannel;
class CompositableClient;
struct PlanarYCbCrData;
@ -265,7 +259,7 @@ public:
virtual void FillInfo(TextureData::Info& aInfo) const = 0;
virtual bool Lock(OpenMode aMode, FenceHandle* aFence) = 0;
virtual bool Lock(OpenMode aMode) = 0;
virtual void Unlock() = 0;
@ -292,10 +286,6 @@ public:
virtual bool ReadBack(TextureReadbackSink* aReadbackSink) { return false; }
/// Ideally this should not be exposed and users of TextureClient would use Lock/Unlock
/// preoperly but that requires a few changes to SharedSurface and maybe gonk video.
virtual void WaitForFence(FenceHandle* aFence) {};
virtual void SyncWithObject(SyncObject* aFence) {};
virtual TextureFlags GetTextureFlags() const { return TextureFlags::NO_FLAGS; }
@ -306,8 +296,6 @@ public:
}
#endif
virtual GrallocTextureData* AsGrallocTextureData() { return nullptr; }
virtual BufferTextureData* AsBufferTextureData() { return nullptr; }
};
@ -590,36 +578,6 @@ public:
*/
void Destroy(bool sync = false);
virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
{
mReleaseFenceHandle.Merge(aReleaseFenceHandle);
}
virtual FenceHandle GetAndResetReleaseFenceHandle()
{
FenceHandle fence;
mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
return fence;
}
virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
{
mAcquireFenceHandle = aAcquireFenceHandle;
}
virtual const FenceHandle& GetAcquireFenceHandle() const
{
return mAcquireFenceHandle;
}
/**
* This function waits until the buffer is no longer being used.
*
* XXX - Ideally we shouldn't need this method because Lock the right
* thing already.
*/
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true);
/**
* Track how much of this texture is wasted.
* For example we might allocate a 256x256 tile but only use 10x10.
@ -650,22 +608,6 @@ public:
uint64_t GetSerial() const { return mSerial; }
bool NeedsFenceHandle()
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (!mData) {
return false;
}
return !!mData->AsGrallocTextureData();
#else
return false;
#endif
}
void WaitFenceHandleOnImageBridge(Mutex& aMutex);
void ClearWaitFenceHandleOnImageBridge(Mutex& aMutex);
void CancelWaitFenceHandleOnImageBridge();
void CancelWaitForRecycle();
/**
@ -731,7 +673,6 @@ private:
void Finalize() {}
friend class AtomicRefCountedWithFinalize<TextureClient>;
friend class gl::SharedSurface_Gralloc;
protected:
/**
* Should only be called *once* per texture, in TextureClient::InitIPDLActor.
@ -757,9 +698,6 @@ protected:
RefPtr<gfx::DrawTarget> mBorrowedDrawTarget;
TextureFlags mFlags;
FenceHandle mReleaseFenceHandle;
FenceHandle mAcquireFenceHandle;
RefPtr<AsyncTransactionWaiter> mFenceHandleWaiter;
gl::GfxTextureWasteTracker mWasteTracker;
@ -789,7 +727,6 @@ protected:
static mozilla::Atomic<uint64_t> sSerialCounter;
friend class TextureChild;
friend class RemoveTextureFromCompositableTracker;
friend void TestTextureClientSurface(TextureClient*, gfxImageSurface*);
friend void TestTextureClientYCbCr(TextureClient*, PlanarYCbCrData&);

View File

@ -13,11 +13,6 @@
#include "nsThreadUtils.h"
#include "SharedSurface.h"
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/GrallocTextureClient.h"
#include "SharedSurfaceGralloc.h"
#endif
using namespace mozilla::gl;
namespace mozilla {
@ -73,67 +68,6 @@ SharedSurfaceTextureClient::Create(UniquePtr<gl::SharedSurface> surf, gl::Surfac
return MakeAndAddRef<SharedSurfaceTextureClient>(data, flags, aAllocator);
}
void
SharedSurfaceTextureClient::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
{
#ifdef MOZ_WIDGET_GONK
gl::SharedSurface_Gralloc* surf = nullptr;
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
surf = gl::SharedSurface_Gralloc::Cast(Surf());
}
if (surf && surf->GetTextureClient()) {
surf->GetTextureClient()->SetReleaseFenceHandle(aReleaseFenceHandle);
return;
}
#endif
TextureClient::SetReleaseFenceHandle(aReleaseFenceHandle);
}
FenceHandle
SharedSurfaceTextureClient::GetAndResetReleaseFenceHandle()
{
#ifdef MOZ_WIDGET_GONK
gl::SharedSurface_Gralloc* surf = nullptr;
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
surf = gl::SharedSurface_Gralloc::Cast(Surf());
}
if (surf && surf->GetTextureClient()) {
return surf->GetTextureClient()->GetAndResetReleaseFenceHandle();
}
#endif
return TextureClient::GetAndResetReleaseFenceHandle();
}
void
SharedSurfaceTextureClient::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
{
#ifdef MOZ_WIDGET_GONK
gl::SharedSurface_Gralloc* surf = nullptr;
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
surf = gl::SharedSurface_Gralloc::Cast(Surf());
}
if (surf && surf->GetTextureClient()) {
return surf->GetTextureClient()->SetAcquireFenceHandle(aAcquireFenceHandle);
}
#endif
TextureClient::SetAcquireFenceHandle(aAcquireFenceHandle);
}
const FenceHandle&
SharedSurfaceTextureClient::GetAcquireFenceHandle() const
{
#ifdef MOZ_WIDGET_GONK
gl::SharedSurface_Gralloc* surf = nullptr;
if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
surf = gl::SharedSurface_Gralloc::Cast(Surf());
}
if (surf && surf->GetTextureClient()) {
return surf->GetTextureClient()->GetAcquireFenceHandle();
}
#endif
return TextureClient::GetAcquireFenceHandle();
}
SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
{
// XXX - Things break when using the proper destruction handshake with

View File

@ -40,7 +40,7 @@ public:
~SharedSurfaceTextureData();
virtual bool Lock(OpenMode, FenceHandle*) override { return false; }
virtual bool Lock(OpenMode) override { return false; }
virtual void Unlock() override {}
@ -66,14 +66,6 @@ public:
Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
LayersIPCChannel* aAllocator, TextureFlags aFlags);
virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle) override;
virtual FenceHandle GetAndResetReleaseFenceHandle() override;
virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle) override;
virtual const FenceHandle& GetAcquireFenceHandle() const override;
gl::SharedSurface* Surf() const {
return static_cast<const SharedSurfaceTextureData*>(GetInternalData())->Surf();
}

View File

@ -308,7 +308,7 @@ ClientTiledLayerBuffer::GetContentType(SurfaceMode* aMode) const
SurfaceMode mode = mPaintedLayer.GetSurfaceMode();
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
#else
if (!mPaintedLayer.GetParent() ||
@ -319,7 +319,7 @@ ClientTiledLayerBuffer::GetContentType(SurfaceMode* aMode) const
}
#endif
} else if (mode == SurfaceMode::SURFACE_OPAQUE) {
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
if (IsLowPrecision()) {
// If we're in low-res mode, drawing can sample from outside the visible
// region. Make sure that we only sample transparency if that happens.

View File

@ -703,15 +703,6 @@ LayerRenderState
ImageHostOverlay::GetRenderState()
{
LayerRenderState state;
#ifdef MOZ_WIDGET_GONK
if (mOverlay.handle().type() == OverlayHandle::Tint32_t) {
state.SetOverlayId(mOverlay.handle().get_int32_t());
} else if (mOverlay.handle().type() == OverlayHandle::TGonkNativeHandle) {
state.SetSidebandStream(mOverlay.handle().get_GonkNativeHandle());
}
state.mSize.width = mPictureRect.Width();
state.mSize.height = mPictureRect.Height();
#endif
return state;
}

View File

@ -58,16 +58,12 @@
#include <android/log.h>
#include <android/native_window.h>
#endif
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_WIDGET_ANDROID)
#include "opengl/CompositorOGL.h"
#include "GLContextEGL.h"
#include "GLContextProvider.h"
#include "ScopedGLHelpers.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "nsScreenManagerGonk.h"
#include "nsWindow.h"
#endif
#include "GeckoProfiler.h"
#include "TextRenderer.h" // for TextRenderer
#include "mozilla/layers/CompositorBridgeParent.h"
@ -481,7 +477,7 @@ LayerManagerComposite::UpdateAndRender()
}
Render(invalid, opaque);
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_WIDGET_ANDROID)
RenderToPresentationSurface();
#endif
mGeometryChanged = false;
@ -1006,7 +1002,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
RecordFrame();
}
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_WIDGET_ANDROID)
class ScopedCompositorProjMatrix {
public:
ScopedCompositorProjMatrix(CompositorOGL* aCompositor, const Matrix4x4& aProjMatrix):
@ -1113,40 +1109,6 @@ LayerManagerComposite::RenderToPresentationSurface()
const IntSize windowSize(ANativeWindow_getWidth(window),
ANativeWindow_getHeight(window));
#elif defined(MOZ_WIDGET_GONK)
CompositorOGL* compositor = mCompositor->AsCompositorOGL();
nsScreenGonk* screen = static_cast<nsWindow*>(mCompositor->GetWidget()->RealWidget())->GetScreen();
if (!screen->IsPrimaryScreen()) {
// Only primary screen support mirroring
return;
}
nsWindow* mirrorScreenWidget = screen->GetMirroringWidget();
if (!mirrorScreenWidget) {
// No mirroring
return;
}
nsScreenGonk* mirrorScreen = mirrorScreenWidget->GetScreen();
if (!mirrorScreen->GetTopWindows().IsEmpty()) {
return;
}
EGLSurface surface = mirrorScreen->GetEGLSurface();
if (surface == LOCAL_EGL_NO_SURFACE) {
// Create GLContext
RefPtr<GLContext> gl = gl::GLContextProvider::CreateForWindow(mirrorScreenWidget, false);
mirrorScreenWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT,
reinterpret_cast<uintptr_t>(gl.get()));
surface = mirrorScreen->GetEGLSurface();
if (surface == LOCAL_EGL_NO_SURFACE) {
// Failed to create EGLSurface
return;
}
}
GLContext* gl = compositor->gl();
GLContextEGL* egl = GLContextEGL::Cast(gl);
const IntSize windowSize = mirrorScreen->GetNaturalBounds().Size().ToUnknownSize();
#endif
if ((windowSize.width <= 0) || (windowSize.height <= 0)) {
@ -1213,15 +1175,6 @@ LayerManagerComposite::RenderToPresentationSurface()
RootLayer()->RenderLayer(clipRect);
mCompositor->EndFrame();
#ifdef MOZ_WIDGET_GONK
mCompositor->SetDispAcquireFence(mRoot); // Call after EndFrame()
RefPtr<Composer2D> composer2D;
composer2D = mCompositor->GetWidget()->GetComposer2D();
if (composer2D) {
composer2D->Render(mirrorScreenWidget);
}
#endif
}
#endif

View File

@ -326,7 +326,7 @@ private:
* Render the current layer tree to the active target.
*/
void Render(const nsIntRegion& aInvalidRegion, const nsIntRegion& aOpaqueRegion);
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#if defined(MOZ_WIDGET_ANDROID)
void RenderToPresentationSurface();
#endif

View File

@ -35,11 +35,6 @@
#include "../d3d11/CompositorD3D11.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "../opengl/GrallocTextureClient.h"
#include "../opengl/GrallocTextureHost.h"
#endif
#ifdef MOZ_X11
#include "mozilla/layers/X11TextureHost.h"
#endif
@ -161,41 +156,6 @@ TextureHost::GetIPDLActor()
return mActor;
}
bool
TextureHost::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
{
if (!aReleaseFenceHandle.IsValid()) {
// HWC might not provide Fence.
// In this case, HWC implicitly handles buffer's fence.
return false;
}
mReleaseFenceHandle.Merge(aReleaseFenceHandle);
return true;
}
FenceHandle
TextureHost::GetAndResetReleaseFenceHandle()
{
FenceHandle fence;
mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
return fence;
}
void
TextureHost::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
{
mAcquireFenceHandle = aAcquireFenceHandle;
}
FenceHandle
TextureHost::GetAndResetAcquireFenceHandle()
{
RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
return FenceHandle(fdObj);
}
void
TextureHost::SetLastFwdTransactionId(uint64_t aTransactionId)
{
@ -241,7 +201,6 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
case SurfaceDescriptor::TSurfaceDescriptorSharedGLTexture:
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSurfaceDescriptorGralloc:
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
if (aBackend == LayersBackend::LAYERS_OPENGL) {
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
@ -386,9 +345,8 @@ TextureHost::NotifyNotUsed()
}
// Do not need to call NotifyNotUsed() if TextureHost does not have
// TextureFlags::RECYCLE flag and TextureHost is not GrallocTextureHostOGL.
if (!(GetFlags() & TextureFlags::RECYCLE) &&
!AsGrallocTextureHostOGL()) {
// TextureFlags::RECYCLE flag.
if (!(GetFlags() & TextureFlags::RECYCLE)) {
return;
}
@ -397,13 +355,11 @@ TextureHost::NotifyNotUsed()
// - TextureHost does not have Compositor.
// - Compositor is BasicCompositor.
// - TextureHost has intermediate buffer.
// - TextureHost is GrallocTextureHostOGL. Fence object is used to detect
// end of buffer usage.
if (!compositor ||
compositor->IsDestroyed() ||
compositor->AsBasicCompositor() ||
HasIntermediateBuffer() ||
AsGrallocTextureHostOGL()) {
HasIntermediateBuffer()) {
static_cast<TextureParent*>(mActor)->NotifyNotUsed(mFwdTransactionId);
return;
}

View File

@ -17,7 +17,6 @@
#include "mozilla/gfx/Types.h" // for SurfaceFormat, etc
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/mozalloc.h" // for operator delete
@ -44,7 +43,6 @@ class Compositor;
class CompositableParentManager;
class ReadLockDescriptor;
class CompositorBridgeParent;
class GrallocTextureHostOGL;
class SurfaceDescriptor;
class HostIPCAllocator;
class ISurfaceAllocator;
@ -587,32 +585,8 @@ public:
int NumCompositableRefs() const { return mCompositableCount; }
/**
* Store a fence that will signal when the current buffer is no longer being read.
* Similar to android's GLConsumer::setReleaseFence()
*/
bool SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle);
/**
* Return a releaseFence's Fence and clear a reference to the Fence.
*/
FenceHandle GetAndResetReleaseFenceHandle();
void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle);
/**
* Return a acquireFence's Fence and clear a reference to the Fence.
*/
FenceHandle GetAndResetAcquireFenceHandle();
virtual void WaitAcquireFenceHandleSyncComplete() {};
void SetLastFwdTransactionId(uint64_t aTransactionId);
virtual bool NeedsFenceHandle() { return false; }
virtual FenceHandle GetCompositorReleaseFence() { return FenceHandle(); }
void DeserializeReadLock(const ReadLockDescriptor& aDesc,
ISurfaceAllocator* aAllocator);
@ -622,15 +596,9 @@ public:
virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
virtual GrallocTextureHostOGL* AsGrallocTextureHostOGL() { return nullptr; }
protected:
void ReadUnlock();
FenceHandle mReleaseFenceHandle;
FenceHandle mAcquireFenceHandle;
void RecycleTexture(TextureFlags aFlags);
virtual void UpdatedInternal(const nsIntRegion *Region) {}

View File

@ -28,10 +28,6 @@
#include "nsRegion.h" // for nsIntRegion
#include "nscore.h" // for nsACString
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
#include <ui/Fence.h>
#endif
namespace mozilla {
namespace layers {

View File

@ -249,7 +249,7 @@ D3D11TextureData::~D3D11TextureData()
// when it calls EndDraw. This EndDraw should not execute anything so it
// shouldn't -really- need the lock but the debug layer chokes on this.
if (mDrawTarget) {
Lock(OpenMode::OPEN_NONE, nullptr);
Lock(OpenMode::OPEN_NONE);
mDrawTarget = nullptr;
Unlock();
}
@ -257,7 +257,7 @@ D3D11TextureData::~D3D11TextureData()
}
bool
D3D11TextureData::Lock(OpenMode aMode, FenceHandle*)
D3D11TextureData::Lock(OpenMode aMode)
{
if (!LockD3DTexture(mTexture.get())) {
return false;

View File

@ -65,7 +65,7 @@ public:
virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
virtual bool Lock(OpenMode aMode, FenceHandle*) override;
virtual bool Lock(OpenMode aMode) override;
virtual void Unlock() override;
@ -77,7 +77,6 @@ public:
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const override;
// TODO - merge this with the FenceHandle API!
virtual void SyncWithObject(SyncObject* aSync) override;
ID3D11Texture2D* GetD3D11Texture() { return mTexture; }
@ -136,7 +135,7 @@ public:
const gfx::IntSize& aSizeY,
const gfx::IntSize& aSizeCbCr);
virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
virtual bool Lock(OpenMode) override { return true; }
virtual void Unlock() override {}

View File

@ -610,7 +610,7 @@ D3D9TextureData::FillInfo(TextureData::Info& aInfo) const
}
bool
D3D9TextureData::Lock(OpenMode aMode, FenceHandle*)
D3D9TextureData::Lock(OpenMode aMode)
{
if (!DeviceManagerD3D9::GetDevice()) {
// If the device has failed then we should not lock the surface,

View File

@ -178,7 +178,7 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
virtual bool Lock(OpenMode aMode, FenceHandle*) override;
virtual bool Lock(OpenMode aMode) override;
virtual void Unlock() override;
@ -227,7 +227,7 @@ public:
virtual void FillInfo(TextureData::Info& aInfo) const override;
virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
virtual bool Lock(OpenMode) override { return true; }
virtual void Unlock() override {}

View File

@ -1,169 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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/. */
#include "AsyncTransactionTracker.h"
#include "mozilla/layers/ImageBridgeChild.h" // for ImageBridgeChild
#include "mozilla/gfx/Logging.h"
namespace mozilla {
namespace layers {
void
AsyncTransactionWaiter::WaitComplete()
{
MOZ_ASSERT(!InImageBridgeChildThread());
MonitorAutoLock mon(mCompletedMonitor);
int count = 0;
const int maxCount = 5;
while (mWaitCount > 0 && (count < maxCount)) {
if (!NS_SUCCEEDED(mCompletedMonitor.Wait(PR_MillisecondsToInterval(10000)))) {
NS_WARNING("Failed to wait Monitor");
return;
}
if (count > 1) {
printf_stderr("Waiting async transaction complete.\n");
}
count++;
}
if (mWaitCount > 0) {
printf_stderr("Timeout of waiting transaction complete.");
}
if (count == maxCount) {
gfxDevCrash(gfx::LogReason::AsyncTransactionTimeout) << "Bug 1244883: AsyncTransactionWaiter timed out.";
}
}
Atomic<uint64_t> AsyncTransactionTracker::sSerialCounter(0);
AsyncTransactionTracker::AsyncTransactionTracker(AsyncTransactionWaiter* aWaiter)
: mSerial(GetNextSerial())
, mWaiter(aWaiter)
#ifdef DEBUG
, mCompleted(false)
#endif
{
if (mWaiter) {
mWaiter->IncrementWaitCount();
}
}
AsyncTransactionTracker::~AsyncTransactionTracker()
{
}
void
AsyncTransactionTracker::NotifyComplete()
{
MOZ_ASSERT(!mCompleted);
#ifdef DEBUG
mCompleted = true;
#endif
Complete();
if (mWaiter) {
mWaiter->DecrementWaitCount();
}
}
void
AsyncTransactionTracker::NotifyCancel()
{
MOZ_ASSERT(!mCompleted);
#ifdef DEBUG
mCompleted = true;
#endif
Cancel();
if (mWaiter) {
mWaiter->DecrementWaitCount();
}
}
Atomic<uint64_t> AsyncTransactionTrackersHolder::sSerialCounter(0);
AsyncTransactionTrackersHolder::AsyncTransactionTrackersHolder()
: mSerial(GetNextSerial())
, mIsTrackersHolderDestroyed(false)
{
MOZ_COUNT_CTOR(AsyncTransactionTrackersHolder);
}
AsyncTransactionTrackersHolder::~AsyncTransactionTrackersHolder()
{
if (!mIsTrackersHolderDestroyed) {
DestroyAsyncTransactionTrackersHolder();
}
MOZ_COUNT_DTOR(AsyncTransactionTrackersHolder);
}
void
AsyncTransactionTrackersHolder::HoldUntilComplete(AsyncTransactionTracker* aTransactionTracker)
{
if (!aTransactionTracker) {
return;
}
if (mIsTrackersHolderDestroyed && aTransactionTracker) {
aTransactionTracker->NotifyComplete();
return;
}
if (aTransactionTracker) {
mAsyncTransactionTrackers[aTransactionTracker->GetId()] = aTransactionTracker;
}
}
void
AsyncTransactionTrackersHolder::TransactionCompleteted(uint64_t aTransactionId)
{
TransactionCompletetedInternal(aTransactionId);
}
void
AsyncTransactionTrackersHolder::TransactionCompletetedInternal(uint64_t aTransactionId)
{
std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it
= mAsyncTransactionTrackers.find(aTransactionId);
if (it != mAsyncTransactionTrackers.end()) {
it->second->NotifyComplete();
mAsyncTransactionTrackers.erase(it);
}
}
void
AsyncTransactionTrackersHolder::SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle,
uint64_t aTransactionId)
{
std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it
= mAsyncTransactionTrackers.find(aTransactionId);
if (it != mAsyncTransactionTrackers.end()) {
it->second->SetReleaseFenceHandle(aReleaseFenceHandle);
}
}
void
AsyncTransactionTrackersHolder::ClearAllAsyncTransactionTrackers()
{
std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it;
for (it = mAsyncTransactionTrackers.begin();
it != mAsyncTransactionTrackers.end(); it++) {
it->second->NotifyCancel();
}
mAsyncTransactionTrackers.clear();
}
void
AsyncTransactionTrackersHolder::DestroyAsyncTransactionTrackersHolder() {
mIsTrackersHolderDestroyed = true;
ClearAllAsyncTransactionTrackers();
}
} // namespace layers
} // namespace mozilla

View File

@ -1,172 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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/. */
#ifndef mozilla_layers_AsyncTransactionTracker_h
#define mozilla_layers_AsyncTransactionTracker_h
#include <map>
#include "mozilla/Atomics.h"
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/Monitor.h" // for Monitor
#include "mozilla/RefPtr.h" // for AtomicRefCounted
namespace mozilla {
namespace layers {
class TextureClient;
class AsyncTransactionTrackersHolder;
/**
* Object that lets you wait for one or more async transactions to complete.
*/
class AsyncTransactionWaiter
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncTransactionWaiter)
AsyncTransactionWaiter()
: mCompletedMonitor("AsyncTransactionWaiter")
, mWaitCount(0)
{}
void IncrementWaitCount()
{
MonitorAutoLock lock(mCompletedMonitor);
++mWaitCount;
}
void DecrementWaitCount()
{
MonitorAutoLock lock(mCompletedMonitor);
MOZ_ASSERT(mWaitCount > 0);
--mWaitCount;
if (mWaitCount == 0) {
mCompletedMonitor.Notify();
}
}
/**
* Wait until asynchronous transactions complete.
*/
void WaitComplete();
uint32_t GetWaitCount() { return mWaitCount; }
private:
~AsyncTransactionWaiter() {}
Monitor mCompletedMonitor;
uint32_t mWaitCount;
};
/**
* AsyncTransactionTracker tracks asynchronous transaction.
* It is typically used for asynchronous layer transaction handling.
*/
class AsyncTransactionTracker
{
friend class AsyncTransactionTrackersHolder;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncTransactionTracker)
explicit AsyncTransactionTracker(AsyncTransactionWaiter* aWaiter = nullptr);
/**
* Notify async transaction complete.
*/
void NotifyComplete();
/**
* Notify async transaction cancel.
*/
void NotifyCancel();
uint64_t GetId()
{
return mSerial;
}
/**
* Called when asynchronous transaction complete.
*/
virtual void Complete()= 0;
/**
* Called when asynchronous transaction is cancelled.
* The cancel typically happens when IPC is disconnected
*/
virtual void Cancel()= 0;
virtual void SetTextureClient(TextureClient* aTextureClient) {}
virtual void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle) {}
protected:
virtual ~AsyncTransactionTracker();
static uint64_t GetNextSerial()
{
return ++sSerialCounter;
}
uint64_t mSerial;
RefPtr<AsyncTransactionWaiter> mWaiter;
#ifdef DEBUG
bool mCompleted;
#endif
static Atomic<uint64_t> sSerialCounter;
};
class AsyncTransactionTrackersHolder
{
public:
AsyncTransactionTrackersHolder();
virtual ~AsyncTransactionTrackersHolder();
void HoldUntilComplete(AsyncTransactionTracker* aTransactionTracker);
void TransactionCompleteted(uint64_t aTransactionId);
static void TransactionCompleteted(uint64_t aHolderId, uint64_t aTransactionId);
static void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle,
uint64_t aHolderId,
uint64_t aTransactionId);
uint64_t GetId()
{
return mSerial;
}
void DestroyAsyncTransactionTrackersHolder();
protected:
static uint64_t GetNextSerial()
{
return ++sSerialCounter;
}
void TransactionCompletetedInternal(uint64_t aTransactionId);
void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle, uint64_t aTransactionId);
void ClearAllAsyncTransactionTrackers();
const uint64_t mSerial;
bool mIsTrackersHolderDestroyed;
std::map<uint64_t, RefPtr<AsyncTransactionTracker> > mAsyncTransactionTrackers;
static Atomic<uint64_t> sSerialCounter;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_AsyncTransactionTracker_h

View File

@ -26,7 +26,6 @@ namespace mozilla {
namespace layers {
class CompositableClient;
class AsyncTransactionTracker;
class ImageContainer;
class SurfaceDescriptor;
class SurfaceDescriptorTiles;
@ -72,12 +71,6 @@ public:
const ThebesBufferData& aThebesBufferData,
const nsIntRegion& aUpdatedRegion) = 0;
#ifdef MOZ_WIDGET_GONK
virtual void UseOverlaySource(CompositableClient* aCompositabl,
const OverlaySource& aOverlay,
const gfx::IntRect& aPictureRect) = 0;
#endif
virtual void Destroy(CompositableChild* aCompositable);
virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) = 0;
@ -94,19 +87,6 @@ public:
virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture) = 0;
/**
* Tell the CompositableHost on the compositor side to remove the texture
* from the CompositableHost. The compositor side sends back transaction
* complete message.
* This function does not delete the TextureHost corresponding to the
* TextureClient passed in parameter.
* It is used when the TextureClient recycled.
* Only ImageBridge implements it.
*/
virtual void RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
CompositableClient* aCompositable,
TextureClient* aTexture) {}
struct TimedTextureClient {
TimedTextureClient()
: mTextureClient(nullptr), mFrameID(0), mProducerID(0) {}

View File

@ -16,7 +16,6 @@
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/ContentHost.h" // for ContentHostBase
#include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent
#include "mozilla/layers/SharedBufferManagerParent.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG
@ -61,7 +60,7 @@ ScheduleComposition(CompositableHost* aCompositable)
return true;
}
#if defined(DEBUG) || defined(MOZ_WIDGET_GONK)
#if defined(DEBUG)
static bool ValidatePictureRect(const mozilla::gfx::IntSize& aSize,
const nsIntRect& aPictureRect)
{
@ -159,21 +158,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
compositable->RemoveTextureHost(tex);
break;
}
case CompositableOperationDetail::TOpRemoveTextureAsync: {
const OpRemoveTextureAsync& op = aEdit.detail().get_OpRemoveTextureAsync();
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->RemoveTextureHost(tex);
// Only ImageBridge child sends it.
MOZ_ASSERT(UsesImageBridge());
if (UsesImageBridge()) {
ReplyRemoveTexture(OpReplyRemoveTexture(op.holderId(),
op.transactionId()));
}
break;
}
case CompositableOperationDetail::TOpUseTexture: {
const OpUseTexture& op = aEdit.detail().get_OpUseTexture();
@ -189,14 +173,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
t->mProducerID = timedTexture.producerID();
t->mTexture->DeserializeReadLock(timedTexture.sharedLock(), this);
MOZ_ASSERT(ValidatePictureRect(t->mTexture->GetSize(), t->mPictureRect));
MaybeFence maybeFence = timedTexture.fence();
if (maybeFence.type() == MaybeFence::TFenceHandle) {
FenceHandle fence = maybeFence.get_FenceHandle();
if (fence.IsValid()) {
t->mTexture->SetAcquireFenceHandle(fence);
}
}
}
if (textures.Length() > 0) {
compositable->UseTextureHost(textures);
@ -246,16 +222,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
}
break;
}
#ifdef MOZ_WIDGET_GONK
case CompositableOperationDetail::TOpUseOverlaySource: {
const OpUseOverlaySource& op = aEdit.detail().get_OpUseOverlaySource();
if (!ValidatePictureRect(op.overlay().size(), op.picture())) {
return false;
}
compositable->UseOverlaySource(op.overlay(), op.picture());
break;
}
#endif
default: {
MOZ_ASSERT(false, "bad type");
}

View File

@ -10,7 +10,6 @@
#include <vector> // for vector
#include "mozilla/Attributes.h" // for override
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
#include "mozilla/layers/ISurfaceAllocator.h" // for ISurfaceAllocator
#include "mozilla/layers/LayersMessages.h" // for EditReply, etc
@ -47,8 +46,6 @@ protected:
bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv);
virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) {};
uint64_t mFwdTransactionId = 0;
};

View File

@ -14,10 +14,6 @@
#include <math.h>
#include "GeckoProfiler.h"
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/GrallocTextureHost.h"
#endif
#define TEST_STEPS 1000
#define DURATION_THRESHOLD 30
#define THRESHOLD_ABORT_COUNT 5
@ -275,92 +271,6 @@ public:
}
};
#ifdef MOZ_WIDGET_GONK
class TrivialGrallocQuadBench : public BenchTest {
public:
TrivialGrallocQuadBench()
: BenchTest("Travial Gralloc Quad (10s 256x256 quads)")
{}
uint32_t* mBuf;
android::sp<android::GraphicBuffer> mGralloc;
RefPtr<TextureSource> mTexture;
virtual void Setup(Compositor* aCompositor, size_t aStep) {
mBuf = nullptr;
int w = 256;
int h = 256;
int32_t format = android::PIXEL_FORMAT_RGBA_8888;;
mGralloc = new android::GraphicBuffer(w, h,
format,
android::GraphicBuffer::USAGE_SW_READ_OFTEN |
android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
android::GraphicBuffer::USAGE_HW_TEXTURE);
mTexture = new mozilla::layers::GrallocTextureSourceOGL((CompositorOGL*)aCompositor, mGralloc.get(), SurfaceFormat::B8G8R8A8);
}
void DrawFrame(Compositor* aCompositor, const gfx::Rect& aScreenRect, size_t aStep) {
EffectChain effects;
effects.mPrimaryEffect = CreateEffect(aStep);
DrawFrameTrivialQuad(aCompositor, aScreenRect, aStep, effects);
}
virtual void Teardown(Compositor* aCompositor) {
mGralloc = nullptr;
mTexture = nullptr;
free(mBuf);
}
virtual already_AddRefed<Effect> CreateEffect(size_t i) {
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture,
SamplingFilter::POINT);
}
};
class StressGrallocQuadBench : public BenchTest {
public:
StressGrallocQuadBench()
: BenchTest("Stress Gralloc Quad (10s 256x256 quads)")
{}
uint32_t* mBuf;
android::sp<android::GraphicBuffer> mGralloc;
RefPtr<TextureSource> mTexture;
virtual void Setup(Compositor* aCompositor, size_t aStep) {
mBuf = nullptr;
int w = 256;
int h = 256;
int32_t format = android::PIXEL_FORMAT_RGBA_8888;;
mGralloc = new android::GraphicBuffer(w, h,
format,
android::GraphicBuffer::USAGE_SW_READ_OFTEN |
android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
android::GraphicBuffer::USAGE_HW_TEXTURE);
mTexture = new mozilla::layers::GrallocTextureSourceOGL((CompositorOGL*)aCompositor, mGralloc.get(), SurfaceFormat::B8G8R8A8);
}
void DrawFrame(Compositor* aCompositor, const gfx::Rect& aScreenRect, size_t aStep) {
EffectChain effects;
effects.mPrimaryEffect = CreateEffect(aStep);
DrawFrameStressQuad(aCompositor, aScreenRect, aStep, effects);
}
virtual void Teardown(Compositor* aCompositor) {
mGralloc = nullptr;
mTexture = nullptr;
free(mBuf);
}
virtual already_AddRefed<Effect> CreateEffect(size_t i) {
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture,
SamplingFilter::POINT);
}
};
#endif
static void RunCompositorBench(Compositor* aCompositor, const gfx::Rect& aScreenRect)
{
std::vector<BenchTest*> tests;
@ -371,10 +281,6 @@ static void RunCompositorBench(Compositor* aCompositor, const gfx::Rect& aScreen
tests.push_back(new EffectSolidColorStressBench());
tests.push_back(new TrivialTexturedQuadBench());
tests.push_back(new StressTexturedQuadBench());
#ifdef MOZ_WIDGET_GONK
tests.push_back(new TrivialGrallocQuadBench());
tests.push_back(new StressGrallocQuadBench());
#endif
for (size_t i = 0; i < tests.size(); i++) {
BenchTest* test = tests[i];

View File

@ -876,12 +876,6 @@ CompositorBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessa
const AsyncParentMessageData& message = aMessages[i];
switch (message.type()) {
case AsyncParentMessageData::TOpDeliverFence: {
const OpDeliverFence& op = message.get_OpDeliverFence();
FenceHandle fence = op.fence();
DeliverFence(op.TextureId(), fence);
break;
}
case AsyncParentMessageData::TOpNotifyNotUsed: {
const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
@ -918,21 +912,12 @@ CompositorBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient
return;
}
if (!(aClient->GetFlags() & TextureFlags::RECYCLE) &&
!aClient->NeedsFenceHandle()) {
if (!(aClient->GetFlags() & TextureFlags::RECYCLE)) {
return;
}
if (aClient->GetFlags() & TextureFlags::RECYCLE) {
aClient->SetLastFwdTransactionId(GetFwdTransactionId());
mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
return;
}
MOZ_ASSERT(!(aClient->GetFlags() & TextureFlags::RECYCLE));
MOZ_ASSERT(aClient->NeedsFenceHandle());
// Handle a case of fence delivery via ImageBridge.
// GrallocTextureData alwasys requests fence delivery if ANDROID_VERSION >= 17.
ImageBridgeChild::GetSingleton()->HoldUntilFenceHandleDelivery(aClient, GetFwdTransactionId());
aClient->SetLastFwdTransactionId(GetFwdTransactionId());
mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
}
void
@ -949,16 +934,6 @@ CompositorBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransacti
mTexturesWaitingRecycled.Remove(aTextureId);
}
void
CompositorBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
{
RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
if (!client) {
return;
}
client->SetReleaseFenceHandle(aReleaseFenceHandle);
}
void
CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
{

View File

@ -189,8 +189,6 @@ public:
*/
void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
TextureClientPool* GetTexturePool(KnowsCompositor* aAllocator,

View File

@ -85,11 +85,6 @@
# include "mozilla/widget/CompositorWidgetParent.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "GeckoTouchDispatcher.h"
#include "nsScreenManagerGonk.h"
#endif
#include "LayerScope.h"
namespace mozilla {
@ -117,38 +112,13 @@ CompositorBridgeParentBase::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTr
return;
}
if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
!texture->NeedsFenceHandle()) {
if (!(texture->GetFlags() & TextureFlags::RECYCLE)) {
return;
}
if (texture->GetFlags() & TextureFlags::RECYCLE) {
SendFenceHandleIfPresent(aTexture);
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
mPendingAsyncMessage.push_back(
OpNotifyNotUsed(textureId, aTransactionId));
return;
}
// Gralloc requests to deliver fence to client side.
// If client side does not use TextureFlags::RECYCLE flag,
// The fence can not be delivered via LayerTransactionParent.
// TextureClient might wait the fence delivery on main thread.
MOZ_ASSERT(ImageBridgeParent::GetInstance(GetChildProcessId()));
if (ImageBridgeParent::GetInstance(GetChildProcessId())) {
// Send message back via PImageBridge.
ImageBridgeParent::NotifyNotUsedToNonRecycle(
GetChildProcessId(),
aTexture,
aTransactionId);
} else {
NS_ERROR("ImageBridgeParent should exist");
}
if (!IsAboutToSendAsyncMessages()) {
SendPendingAsyncMessages();
}
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
mPendingAsyncMessage.push_back(
OpNotifyNotUsed(textureId, aTransactionId));
}
void
@ -349,24 +319,9 @@ CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorBridgeParent* aComp
, mCurrentCompositeTask(nullptr)
, mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor")
, mSetNeedsCompositeTask(nullptr)
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
, mDisplayEnabled(false)
, mSetDisplayMonitor("SetDisplayMonitor")
, mSetDisplayTask(nullptr)
#endif
#endif
{
MOZ_ASSERT(NS_IsMainThread() || XRE_GetProcessType() == GeckoProcessType_GPU);
mVsyncObserver = new Observer(this);
#ifdef MOZ_WIDGET_GONK
GeckoTouchDispatcher::GetInstance()->SetCompositorVsyncScheduler(this);
#if ANDROID_VERSION >= 19
RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
screenManager->SetCompositorVsyncScheduler(this);
#endif
#endif
// mAsapScheduling is set on the main thread during init,
// but is only accessed after on the compositor thread.
@ -382,54 +337,6 @@ CompositorVsyncScheduler::~CompositorVsyncScheduler()
mCompositorBridgeParent = nullptr;
}
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
void
CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
{
// SetDisplay() is usually called from nsScreenManager at main thread. Post
// to compositor thread if needs.
if (!CompositorThreadHolder::IsInCompositorThread()) {
MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock lock(mSetDisplayMonitor);
RefPtr<CancelableRunnable> task =
NewCancelableRunnableMethod<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
mSetDisplayTask = task;
ScheduleTask(task.forget(), 0);
return;
} else {
MonitorAutoLock lock(mSetDisplayMonitor);
mSetDisplayTask = nullptr;
}
if (mDisplayEnabled == aDisplayEnable) {
return;
}
mDisplayEnabled = aDisplayEnable;
if (!mDisplayEnabled) {
CancelCurrentSetNeedsCompositeTask();
CancelCurrentCompositeTask();
}
}
void
CompositorVsyncScheduler::CancelSetDisplayTask()
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MonitorAutoLock lock(mSetDisplayMonitor);
if (mSetDisplayTask) {
mSetDisplayTask->Cancel();
mSetDisplayTask = nullptr;
}
// CancelSetDisplayTask is only be called in clean-up process, so
// mDisplayEnabled could be false there.
mDisplayEnabled = false;
}
#endif //ANDROID_VERSION >= 19
#endif //MOZ_WIDGET_GONK
void
CompositorVsyncScheduler::Destroy()
{
@ -442,11 +349,6 @@ CompositorVsyncScheduler::Destroy()
mVsyncObserver->Destroy();
mVsyncObserver = nullptr;
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
CancelSetDisplayTask();
#endif
#endif
CancelCurrentSetNeedsCompositeTask();
CancelCurrentCompositeTask();
}
@ -521,15 +423,6 @@ CompositorVsyncScheduler::SetNeedsComposite()
mSetNeedsCompositeTask = nullptr;
}
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
// Skip composition when display off.
if (!mDisplayEnabled) {
return;
}
#endif
#endif
mNeedsComposite++;
if (!mIsObservingVsync && mNeedsComposite) {
ObserveVsync();
@ -652,9 +545,6 @@ CompositorVsyncScheduler::UnobserveVsync()
void
CompositorVsyncScheduler::DispatchTouchEvents(TimeStamp aVsyncTimestamp)
{
#ifdef MOZ_WIDGET_GONK
GeckoTouchDispatcher::GetInstance()->NotifyVsync(aVsyncTimestamp);
#endif
}
void

View File

@ -95,19 +95,6 @@ public:
explicit CompositorVsyncScheduler(CompositorBridgeParent* aCompositorBridgeParent,
widget::CompositorWidget* aWidget);
#ifdef MOZ_WIDGET_GONK
// emulator-ics never trigger the display on/off, so compositor will always
// skip composition request at that device. Only check the display status
// with kk device and upon.
#if ANDROID_VERSION >= 19
// SetDisplay() and CancelSetDisplayTask() are used for the display on/off.
// It will clear all composition related task and flag, and skip another
// composition task during the display off. That could prevent the problem
// that compositor might show the old content at the first frame of display on.
void SetDisplay(bool aDisplayEnable);
#endif
#endif
bool NotifyVsync(TimeStamp aVsyncTimestamp);
void SetNeedsComposite();
void OnForceComposeToTarget();
@ -144,11 +131,6 @@ private:
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
void DispatchVREvents(TimeStamp aVsyncTimestamp);
void CancelCurrentSetNeedsCompositeTask();
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
void CancelSetDisplayTask();
#endif
#endif
class Observer final : public VsyncObserver
{
@ -183,14 +165,6 @@ private:
mozilla::Monitor mSetNeedsCompositeMonitor;
RefPtr<CancelableRunnable> mSetNeedsCompositeTask;
#ifdef MOZ_WIDGET_GONK
#if ANDROID_VERSION >= 19
bool mDisplayEnabled;
mozilla::Monitor mSetDisplayMonitor;
RefPtr<CancelableRunnable> mSetDisplayTask;
#endif
#endif
};
class CompositorBridgeParentBase : public PCompositorBridgeParent,

View File

@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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/. */
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
#pragma GCC visibility push(default)
#include "sync/sync.h" // for sync_merge
#pragma GCC visibility pop
#endif
#include "FenceUtils.h"
using namespace mozilla::layers;
namespace IPC {
void
ParamTraits<FenceHandle>::Write(Message* aMsg,
const paramType& aParam)
{
FenceHandle handle = aParam;
MOZ_ASSERT(handle.IsValid());
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
RefPtr<FenceHandle::FdObj> fence = handle.GetAndResetFdObj();
aMsg->WriteFileDescriptor(base::FileDescriptor(fence->GetAndResetFd(), true));
#endif
}
bool
ParamTraits<FenceHandle>::Read(const Message* aMsg,
PickleIterator* aIter, paramType* aResult)
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
base::FileDescriptor fd;
if (aMsg->ReadFileDescriptor(aIter, &fd)) {
aResult->Merge(FenceHandle(new FenceHandle::FdObj(fd.fd)));
}
#endif
return true;
}
} // namespace IPC
namespace mozilla {
namespace layers {
FenceHandle::FenceHandle()
: mFence(new FdObj())
{
}
FenceHandle::FenceHandle(FdObj* aFdObj)
: mFence(aFdObj)
{
MOZ_ASSERT(aFdObj);
}
void
FenceHandle::Merge(const FenceHandle& aFenceHandle)
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (!aFenceHandle.IsValid()) {
return;
}
if (!IsValid()) {
mFence = aFenceHandle.mFence;
} else {
int result = sync_merge("FenceHandle", mFence->mFd, aFenceHandle.mFence->mFd);
if (result == -1) {
mFence = aFenceHandle.mFence;
} else {
mFence = new FdObj(result);
}
}
#endif
}
void
FenceHandle::TransferToAnotherFenceHandle(FenceHandle& aFenceHandle)
{
aFenceHandle.mFence = this->GetAndResetFdObj();
}
already_AddRefed<FenceHandle::FdObj>
FenceHandle::GetAndResetFdObj()
{
RefPtr<FdObj> fence = mFence;
mFence = new FdObj();
return fence.forget();
}
already_AddRefed<FenceHandle::FdObj>
FenceHandle::GetDupFdObj()
{
RefPtr<FdObj> fdObj;
if (IsValid()) {
fdObj = new FenceHandle::FdObj(dup(mFence->mFd));
} else {
fdObj = new FenceHandle::FdObj();
}
return fdObj.forget();
}
} // namespace layers
} // namespace mozilla

View File

@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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/. */
#ifndef IPC_FencerUtils_h
#define IPC_FencerUtils_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/RefPtr.h" // for nsRefPtr
namespace mozilla {
namespace layers {
class FenceHandle {
public:
class FdObj {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FdObj)
friend class FenceHandle;
public:
FdObj()
: mFd(-1) {}
explicit FdObj(int aFd)
: mFd(aFd) {}
int GetAndResetFd()
{
int fd = mFd;
mFd = -1;
return fd;
}
private:
virtual ~FdObj() {
if (mFd != -1) {
close(mFd);
}
}
int mFd;
};
FenceHandle();
explicit FenceHandle(FdObj* aFdObj);
bool operator==(const FenceHandle& aOther) const {
return mFence.get() == aOther.mFence.get();
}
bool IsValid() const
{
return (mFence->mFd != -1);
}
void Merge(const FenceHandle& aFenceHandle);
void TransferToAnotherFenceHandle(FenceHandle& aFenceHandle);
already_AddRefed<FdObj> GetAndResetFdObj();
already_AddRefed<FdObj> GetDupFdObj();
private:
RefPtr<FdObj> mFence;
};
} // namespace layers
} // namespace mozilla
namespace IPC {
template <>
struct ParamTraits<mozilla::layers::FenceHandle> {
typedef mozilla::layers::FenceHandle paramType;
static void Write(Message* aMsg, const paramType& aParam);
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
};
} // namespace IPC
#endif // IPC_FencerUtils_h

View File

@ -8,88 +8,15 @@
#ifndef IPC_GonkNativeHandle_h
#define IPC_GonkNativeHandle_h
#ifdef MOZ_WIDGET_GONK
#include <cutils/native_handle.h>
#endif
#include "mozilla/RefPtr.h" // for RefPtr
#include "nsISupportsImpl.h"
namespace mozilla {
namespace layers {
#ifdef MOZ_WIDGET_GONK
// GonkNativeHandle wraps android's native_handle_t and is used to support
// android's sideband stream.
// The sideband stream is a device-specific mechanism for passing buffers
// to hwcomposer. It is used to render TV streams and DRM protected streams.
// The native_handle_t represents device-specific kernel objects on android.
class GonkNativeHandle {
public:
class NhObj {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NhObj)
friend class GonkNativeHandle;
public:
NhObj()
: mHandle(nullptr) {}
explicit NhObj(native_handle_t* aHandle)
: mHandle(aHandle) {}
native_handle_t* GetAndResetNativeHandle()
{
native_handle_t* handle = mHandle;
mHandle = nullptr;
return handle;
}
private:
virtual ~NhObj() {
if (mHandle) {
native_handle_close(mHandle);
native_handle_delete(mHandle);
}
}
native_handle_t* mHandle;
};
GonkNativeHandle();
explicit GonkNativeHandle(NhObj* aNhObj);
bool operator==(const GonkNativeHandle& aOther) const {
return mNhObj.get() == aOther.mNhObj.get();
}
bool IsValid() const
{
return mNhObj && mNhObj->mHandle;
}
void TransferToAnother(GonkNativeHandle& aHandle);
already_AddRefed<NhObj> GetAndResetNhObj();
already_AddRefed<NhObj> GetDupNhObj();
static already_AddRefed<NhObj> CreateDupNhObj(native_handle_t* aHandle);
// Return non owning handle.
native_handle_t* GetRawNativeHandle() const
{
if (mNhObj) {
return mNhObj->mHandle;
}
return nullptr;
}
private:
RefPtr<NhObj> mNhObj;
};
#else
struct GonkNativeHandle {
bool operator==(const GonkNativeHandle&) const { return false; }
};
#endif
} // namespace layers
} // namespace mozilla

View File

@ -14,22 +14,12 @@
namespace IPC {
#ifdef MOZ_WIDGET_GONK
template <>
struct ParamTraits<mozilla::layers::GonkNativeHandle> {
typedef mozilla::layers::GonkNativeHandle paramType;
static void Write(Message* aMsg, const paramType& aParam);
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
};
#else
template <>
struct ParamTraits<mozilla::layers::GonkNativeHandle> {
typedef mozilla::layers::GonkNativeHandle paramType;
static void Write(Message*, const paramType&) {}
static bool Read(const Message*, PickleIterator*, paramType*) { return false; }
};
#endif
} // namespace IPC

View File

@ -24,34 +24,6 @@ mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType()
return ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
}
void
HostIPCAllocator::SendFenceHandleIfPresent(PTextureParent* aTexture)
{
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
if (!texture) {
return;
}
if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
!texture->NeedsFenceHandle()) {
return;
}
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
// Send a ReleaseFence of CompositorOGL.
FenceHandle fence = texture->GetCompositorReleaseFence();
if (fence.IsValid()) {
mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
}
// Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
fence = texture->GetAndResetReleaseFenceHandle();
if (fence.IsValid()) {
mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
}
}
void
HostIPCAllocator::SendPendingAsyncMessages()
{

View File

@ -17,18 +17,6 @@
#include "mozilla/layers/LayersMessages.h" // for ShmemSection
#include "LayersTypes.h"
/*
* FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
* (I think that this doesn't apply anymore.)
*
* This #define is actually needed here, because subclasses of ISurfaceAllocator,
* namely ShadowLayerForwarder, will or will not override AllocGrallocBuffer
* depending on whether MOZ_HAVE_SURFACEDESCRIPTORGRALLOC is defined.
*/
#ifdef MOZ_WIDGET_GONK
#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
#endif
namespace mozilla {
namespace ipc {
class Shmem;
@ -148,8 +136,6 @@ public:
virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) = 0;
void SendFenceHandleIfPresent(PTextureParent* aTexture);
virtual void SendPendingAsyncMessages();
virtual void SetAboutToSendAsyncMessages()

View File

@ -171,10 +171,8 @@ ImageBridgeChild::UseTextures(CompositableClient* aCompositable,
ReadLockDescriptor readLock;
t.mTextureClient->SerializeReadLock(readLock);
FenceHandle fence = t.mTextureClient->GetAcquireFenceHandle();
textures.AppendElement(TimedTexture(nullptr, t.mTextureClient->GetIPDLActor(),
readLock,
fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
t.mTimeStamp, t.mPictureRect,
t.mFrameID, t.mProducerID));
@ -219,24 +217,6 @@ ImageBridgeChild::UseComponentAlphaTextures(CompositableClient* aCompositable,
);
}
#ifdef MOZ_WIDGET_GONK
void
ImageBridgeChild::UseOverlaySource(CompositableClient* aCompositable,
const OverlaySource& aOverlay,
const nsIntRect& aPictureRect)
{
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->IsConnected());
CompositableOperation op(
nullptr,
aCompositable->GetIPDLActor(),
OpUseOverlaySource(aOverlay, aPictureRect));
mTxn->AddEdit(op);
}
#endif
void
ImageBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient)
{
@ -263,102 +243,6 @@ ImageBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
mTexturesWaitingRecycled.Remove(aTextureId);
}
void
ImageBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
{
RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
if (!client) {
return;
}
client->SetReleaseFenceHandle(aReleaseFenceHandle);
}
void
ImageBridgeChild::HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId)
{
MOZ_ASSERT(NS_IsMainThread());
// XXX Re-enable fence handling
return;
#ifdef MOZ_WIDGET_GONK
if (!aClient) {
return;
}
MutexAutoLock lock(mWaitingFenceHandleMutex);
aClient->SetLastFwdTransactionId(aTransactionId);
aClient->WaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
mTexturesWaitingFenceHandle.Put(aClient->GetSerial(), aClient);
#else
NS_RUNTIMEABORT("not reached");
#endif
}
void
ImageBridgeChild::DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
{
// XXX Re-enable fence handling
return;
#ifdef MOZ_WIDGET_GONK
MutexAutoLock lock(mWaitingFenceHandleMutex);
TextureClient* client = mTexturesWaitingFenceHandle.Get(aTextureId).get();
if (!client) {
return;
}
MOZ_ASSERT(aTextureId == client->GetSerial());
client->SetReleaseFenceHandle(aReleaseFenceHandle);
#else
NS_RUNTIMEABORT("not reached");
#endif
}
void
ImageBridgeChild::NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId)
{
// XXX Re-enable fence handling
return;
#ifdef MOZ_WIDGET_GONK
MutexAutoLock lock(mWaitingFenceHandleMutex);
RefPtr<TextureClient> client = mTexturesWaitingFenceHandle.Get(aTextureId);
if (!client) {
return;
}
if (aTransactionId < client->GetLastFwdTransactionId()) {
return;
}
MOZ_ASSERT(aTextureId == client->GetSerial());
client->ClearWaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
mTexturesWaitingFenceHandle.Remove(aTextureId);
// Release TextureClient on allocator's message loop.
RefPtr<TextureClientReleaseTask> task =
MakeAndAddRef<TextureClientReleaseTask>(client);
RefPtr<LayersIPCChannel> allocator = client->GetAllocator();
client = nullptr;
allocator->GetMessageLoop()->PostTask(task.forget());
#else
NS_RUNTIMEABORT("not reached");
#endif
}
void
ImageBridgeChild::CancelWaitFenceHandle(TextureClient* aClient)
{
// XXX Re-enable fence handling
return;
#ifdef MOZ_WIDGET_GONK
MutexAutoLock lock(mWaitingFenceHandleMutex);
aClient->ClearWaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
mTexturesWaitingFenceHandle.Remove(aClient->GetSerial());
#else
NS_RUNTIMEABORT("not reached");
#endif
}
void
ImageBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
{
@ -516,9 +400,6 @@ ImageBridgeChild::ImageBridgeChild()
: mCanSend(false)
, mCalledClose(false)
, mFwdTransactionId(0)
#ifdef MOZ_WIDGET_GONK
, mWaitingFenceHandleMutex("ImageBridgeChild::mWaitingFenceHandleMutex")
#endif
{
MOZ_ASSERT(NS_IsMainThread());
@ -534,7 +415,6 @@ void
ImageBridgeChild::MarkShutDown()
{
mTexturesWaitingRecycled.Clear();
mTrackersHolder.DestroyAsyncTransactionTrackersHolder();
mCanSend = false;
}
@ -719,21 +599,11 @@ ImageBridgeChild::UpdateAsyncCanvasRendererNow(AsyncCanvasRenderer* aWrapper)
void
ImageBridgeChild::FlushAllImagesSync(SynchronousTask* aTask,
ImageClient* aClient,
ImageContainer* aContainer,
RefPtr<AsyncTransactionWaiter> aWaiter)
ImageContainer* aContainer)
{
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(aWaiter);
#else
MOZ_ASSERT(!aWaiter);
#endif
AutoCompleteTask complete(aTask);
if (!CanSend()) {
#ifdef MOZ_WIDGET_GONK
aWaiter->DecrementWaitCount();
#endif
return;
}
@ -742,15 +612,8 @@ ImageBridgeChild::FlushAllImagesSync(SynchronousTask* aTask,
if (aContainer) {
aContainer->ClearImagesFromImageBridge();
}
aClient->FlushAllImages(aWaiter);
aClient->FlushAllImages();
EndTransaction();
// This decrement is balanced by the increment in FlushAllImages.
// If any AsyncTransactionTrackers were created by FlushAllImages and attached
// to aWaiter, aWaiter will not complete until those trackers all complete.
// Otherwise, aWaiter will be ready to complete now.
#ifdef MOZ_WIDGET_GONK
aWaiter->DecrementWaitCount();
#endif
}
void
@ -766,28 +629,16 @@ ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContaine
SynchronousTask task("FlushAllImages Lock");
RefPtr<AsyncTransactionWaiter> waiter;
#ifdef MOZ_WIDGET_GONK
waiter = new AsyncTransactionWaiter();
// This increment is balanced by the decrement in FlushAllImagesSync
waiter->IncrementWaitCount();
#endif
// RefPtrs on arguments are not needed since this dispatches synchronously.
RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::FlushAllImagesSync,
&task,
aClient,
aContainer,
waiter);
aContainer);
GetMessageLoop()->PostTask(runnable.forget());
task.Wait();
#ifdef MOZ_WIDGET_GONK
waiter->WaitComplete();
#endif
}
void
@ -844,9 +695,6 @@ ImageBridgeChild::EndTransaction()
void
ImageBridgeChild::SendImageBridgeThreadId()
{
#ifdef MOZ_WIDGET_GONK
PImageBridgeChild::SendImageBridgeThreadId(gettid());
#endif
}
bool
@ -1304,45 +1152,11 @@ ImageBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageDat
const AsyncParentMessageData& message = aMessages[i];
switch (message.type()) {
case AsyncParentMessageData::TOpDeliverFence: {
const OpDeliverFence& op = message.get_OpDeliverFence();
FenceHandle fence = op.fence();
DeliverFence(op.TextureId(), fence);
break;
}
case AsyncParentMessageData::TOpDeliverFenceToNonRecycle: {
// Notify ReleaseCompositableRef to a TextureClient that belongs to
// LayerTransactionChild. It is used only on gonk to deliver fence to
// a TextureClient that does not have TextureFlags::RECYCLE.
// In this case, LayerTransactionChild's ipc could not be used to deliver fence.
const OpDeliverFenceToNonRecycle& op = message.get_OpDeliverFenceToNonRecycle();
FenceHandle fence = op.fence();
DeliverFenceToNonRecycle(op.TextureId(), fence);
break;
}
case AsyncParentMessageData::TOpNotifyNotUsed: {
const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
break;
}
case AsyncParentMessageData::TOpNotifyNotUsedToNonRecycle: {
// Notify ReleaseCompositableRef to a TextureClient that belongs to
// LayerTransactionChild. It is used only on gonk to deliver fence to
// a TextureClient that does not have TextureFlags::RECYCLE.
// In this case, LayerTransactionChild's ipc could not be used to deliver fence.
const OpNotifyNotUsedToNonRecycle& op = message.get_OpNotifyNotUsedToNonRecycle();
NotifyNotUsedToNonRecycle(op.TextureId(), op.fwdTransactionId());
break;
}
case AsyncParentMessageData::TOpReplyRemoveTexture: {
const OpReplyRemoveTexture& op = message.get_OpReplyRemoveTexture();
MOZ_ASSERT(mTrackersHolder.GetId() == op.holderId());
mTrackersHolder.TransactionCompleteted(op.transactionId());
break;
}
default:
NS_ERROR("unknown AsyncParentMessageData type");
return false;
@ -1426,32 +1240,6 @@ ImageBridgeChild::RemoveTextureFromCompositable(CompositableClient* aCompositabl
}
}
void
ImageBridgeChild::RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
CompositableClient* aCompositable,
TextureClient* aTexture)
{
MOZ_ASSERT(CanSend());
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->IsSharedWithCompositor());
MOZ_ASSERT(aCompositable->IsConnected());
if (!aTexture || !aTexture->IsSharedWithCompositor() || !aCompositable->IsConnected()) {
return;
}
CompositableOperation op(
nullptr, aCompositable->GetIPDLActor(),
OpRemoveTextureAsync(
mTrackersHolder.GetId(),
aAsyncTransactionTracker->GetId(),
nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
mTxn->AddNoSwapEdit(op);
// Hold AsyncTransactionTracker until receving reply
mTrackersHolder.HoldUntilComplete(aAsyncTransactionTracker);
}
bool ImageBridgeChild::IsSameProcess() const
{
return OtherPid() == base::GetCurrentProcId();

View File

@ -12,7 +12,6 @@
#include "mozilla/Atomics.h"
#include "mozilla/RefPtr.h" // for already_AddRefed
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTrackerHolder
#include "mozilla/layers/CanvasClient.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/CompositorTypes.h"
@ -37,7 +36,6 @@ class Shmem;
namespace layers {
class AsyncCanvasRenderer;
class AsyncTransactionTracker;
class ImageClient;
class ImageContainer;
class ImageContainerChild;
@ -257,8 +255,7 @@ private:
void FlushAllImagesSync(
SynchronousTask* aTask,
ImageClient* aClient,
ImageContainer* aContainer,
RefPtr<AsyncTransactionWaiter> aWaiter);
ImageContainer* aContainer);
void ProxyAllocShmemNow(SynchronousTask* aTask, AllocShmemParams* aParams);
void ProxyDeallocShmemNow(SynchronousTask* aTask, Shmem* aShmem);
@ -279,11 +276,6 @@ public:
virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aClientOnBlack,
TextureClient* aClientOnWhite) override;
#ifdef MOZ_WIDGET_GONK
virtual void UseOverlaySource(CompositableClient* aCompositable,
const OverlaySource& aOverlay,
const nsIntRect& aPictureRect) override;
#endif
void Destroy(CompositableChild* aCompositable) override;
@ -299,16 +291,6 @@ public:
*/
void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
void HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId);
void DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
void NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId);
void CancelWaitFenceHandle(TextureClient* aClient);
virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
@ -317,10 +299,6 @@ public:
virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture) override;
virtual void RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
CompositableClient* aCompositable,
TextureClient* aTexture) override;
virtual void UseTiledLayerBuffer(CompositableClient* aCompositable,
const SurfaceDescriptorTiles& aTileLayerDescriptor) override
{
@ -413,13 +391,6 @@ private:
* It defer calling of TextureClient recycle callback.
*/
nsDataHashtable<nsUint64HashKey, RefPtr<TextureClient> > mTexturesWaitingRecycled;
AsyncTransactionTrackersHolder mTrackersHolder;
#ifdef MOZ_WIDGET_GONK
Mutex mWaitingFenceHandleMutex;
nsDataHashtable<nsUint64HashKey, RefPtr<TextureClient> > mTexturesWaitingFenceHandle;
#endif
};
} // namespace layers

View File

@ -132,9 +132,6 @@ ImageBridgeParent::RecvImageBridgeThreadId(const PlatformThreadId& aThreadId)
return false;
}
mSetChildThreadPriority = true;
#ifdef MOZ_WIDGET_GONK
hal::SetThreadPriority(aThreadId, hal::THREAD_PRIORITY_COMPOSITOR);
#endif
return true;
}
@ -410,74 +407,6 @@ bool ImageBridgeParent::IsSameProcess() const
return OtherPid() == base::GetCurrentProcId();
}
void
ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply)
{
mPendingAsyncMessage.push_back(aReply);
}
void
ImageBridgeParent::SendFenceHandleToNonRecycle(PTextureParent* aTexture)
{
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
if (!texture) {
return;
}
if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
!texture->NeedsFenceHandle()) {
return;
}
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
// Send a ReleaseFence of CompositorOGL.
FenceHandle fence = texture->GetCompositorReleaseFence();
if (fence.IsValid()) {
mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
}
// Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
fence = texture->GetAndResetReleaseFenceHandle();
if (fence.IsValid()) {
mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
}
}
void
ImageBridgeParent::NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
uint64_t aTransactionId)
{
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
if (!texture) {
return;
}
if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
!texture->NeedsFenceHandle()) {
return;
}
SendFenceHandleToNonRecycle(aTexture);
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
mPendingAsyncMessage.push_back(
OpNotifyNotUsedToNonRecycle(textureId, aTransactionId));
}
/*static*/ void
ImageBridgeParent::NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
PTextureParent* aTexture,
uint64_t aTransactionId)
{
ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId);
if (!imageBridge) {
return;
}
imageBridge->NotifyNotUsedToNonRecycle(aTexture, aTransactionId);
}
/*static*/ void
ImageBridgeParent::SetAboutToSendAsyncMessages(base::ProcessId aChildProcessId)
{
@ -506,12 +435,10 @@ ImageBridgeParent::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransaction
return;
}
if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
!texture->NeedsFenceHandle()) {
if (!(texture->GetFlags() & TextureFlags::RECYCLE)) {
return;
}
SendFenceHandleIfPresent(aTexture);
uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
mPendingAsyncMessage.push_back(
OpNotifyNotUsed(textureId, aTransactionId));

View File

@ -113,17 +113,6 @@ public:
virtual bool IsSameProcess() const override;
virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) override;
void SendFenceHandleToNonRecycle(PTextureParent* aTexture);
void NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
uint64_t aTransactionId);
static void NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
PTextureParent* aTexture,
uint64_t aTransactionId);
using CompositableParentManager::SetAboutToSendAsyncMessages;
static void SetAboutToSendAsyncMessages(base::ProcessId aChildProcessId);

View File

@ -11,7 +11,6 @@
#include <stdint.h> // for uint32_t
#include "mozilla/Attributes.h" // for override
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
#include "mozilla/layers/PLayerTransactionChild.h"
#include "mozilla/RefPtr.h"

Some files were not shown because too many files have changed in this diff Show More