Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1727488, bug 1727489) for causing bustag…
Browse files Browse the repository at this point in the history
…es on KnowsCompositor.cpp. CLOSED TREE

Backed out changeset 5a00db1b7a6a (bug 1727489)
Backed out changeset 13686567e748 (bug 1727488)
  • Loading branch information
Butkovits Atila committed Aug 26, 2021
1 parent 7acf6d2 commit c83e348
Show file tree
Hide file tree
Showing 47 changed files with 3,692 additions and 136 deletions.
1 change: 1 addition & 0 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "MobileViewportManager.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "nsPresContext.h"
#include "nsCaret.h"
#include "nsContentList.h"
Expand Down
1 change: 1 addition & 0 deletions dom/canvas/ClientWebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "mozilla/ipc/Shmem.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/OOPCanvasRenderer.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
#include "mozilla/layers/WebRenderUserData.h"
Expand Down
1 change: 1 addition & 0 deletions dom/canvas/HostWebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "HostWebGLContext.h"

#include "CompositableHost.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/LayersSurfaces.h"

#include "MozFramebuffer.h"
Expand Down
1 change: 1 addition & 0 deletions dom/canvas/PWebGL.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

include protocol PCompositorBridge;
include protocol PLayerTransaction;

using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::SurfaceDescriptor from "mozilla/layers/LayersTypes.h";
Expand Down
1 change: 1 addition & 0 deletions dom/canvas/WebGLParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "WebGLParent.h"

#include "WebGLChild.h"
#include "mozilla/layers/LayerTransactionParent.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
#include "ImageContainer.h"
#include "HostWebGLContext.h"
Expand Down
1 change: 1 addition & 0 deletions dom/ipc/BrowserChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#include "mozilla/layers/IAPZCTreeManager.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "nsBrowserStatusFilter.h"
#include "nsColorPickerProxy.h"
Expand Down
1 change: 1 addition & 0 deletions gfx/layers/CompositorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ enum class CompositableType : uint8_t {
UNKNOWN,
CONTENT_TILED, // tiled painted layer
IMAGE, // image with single buffering
IMAGE_BRIDGE, // ImageBridge protocol
CONTENT_SINGLE, // painted layer interface, single buffering
CONTENT_DOUBLE, // painted layer interface, double buffering
COUNT
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/LayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class RefLayer;
class HostLayer;
class FocusTarget;
class KnowsCompositor;
class ShadowableLayer;
class ShadowLayerForwarder;
class LayerManagerComposite;
class TransactionIdAllocator;
class FrameUniformityData;
Expand Down
23 changes: 22 additions & 1 deletion gfx/layers/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "mozilla/layers/LayerManagerComposite.h" // for HostLayer
#include "mozilla/layers/LayersMessages.h" // for SpecificLayerAttributes, CompositorAnimations (ptr only), ContainerLayerAt...
#include "mozilla/layers/LayersTypes.h" // for EventRegions, operator<<, CompositionPayload, CSSTransformMatrix, MOZ_LAYE...
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
#include "nsBaseHashtable.h" // for nsBaseHashtable<>::Iterator, nsBaseHashtable<>::LookupResult
#include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
#include "nsPrintfCString.h" // for nsPrintfCString
Expand Down Expand Up @@ -1157,14 +1158,16 @@ void Layer::Dump(std::stringstream& aStream, const char* aPrefix,
bool dumpCompositorTexture = gfxEnv::DumpCompositorTextures() &&
AsHostLayer() &&
AsHostLayer()->GetCompositableHost();
bool dumpClientTexture = gfxEnv::DumpPaint() && AsShadowableLayer() &&
AsShadowableLayer()->GetCompositableClient();
nsCString layerId(Name());
layerId.Append('-');
layerId.AppendInt((uint64_t)this);
#endif
if (aDumpHtml) {
aStream << nsPrintfCString(R"(<li><a id="%p" )", this).get();
#ifdef MOZ_DUMP_PAINTING
if (dumpCompositorTexture) {
if (dumpCompositorTexture || dumpClientTexture) {
aStream << nsPrintfCString(R"lit(href="javascript:ViewImage('%s')")lit",
layerId.BeginReading())
.get();
Expand All @@ -1177,11 +1180,29 @@ void Layer::Dump(std::stringstream& aStream, const char* aPrefix,
#ifdef MOZ_DUMP_PAINTING
if (dumpCompositorTexture) {
AsHostLayer()->GetCompositableHost()->Dump(aStream, aPrefix, aDumpHtml);
} else if (dumpClientTexture) {
if (aDumpHtml) {
aStream << nsPrintfCString(R"(<script>array["%s"]=")",
layerId.BeginReading())
.get();
}
AsShadowableLayer()->GetCompositableClient()->Dump(
aStream, aPrefix, aDumpHtml, TextureDumpMode::DoNotCompress);
if (aDumpHtml) {
aStream << R"(";</script>)";
}
}
#endif

if (aDumpHtml) {
aStream << "</a>";
#ifdef MOZ_DUMP_PAINTING
if (dumpClientTexture) {
aStream << nsPrintfCString("<br><img id=\"%s\">\n",
layerId.BeginReading())
.get();
}
#endif
}

if (Layer* mask = GetMaskLayer()) {
Expand Down
7 changes: 7 additions & 0 deletions gfx/layers/Layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CompositorAnimations;
class CanvasLayer;
class RefLayer;
class HostLayer;
class ShadowableLayer;
class SpecificLayerAttributes;
class Compositor;
class TransformData;
Expand Down Expand Up @@ -917,6 +918,12 @@ class Layer {
*/
virtual HostLayer* AsHostLayer() { return nullptr; }

/**
* Dynamic cast to a ShadowableLayer. Return null if this is not a
* ShadowableLayer. Can be used anytime.
*/
virtual ShadowableLayer* AsShadowableLayer() { return nullptr; }

// These getters can be used anytime. They return the effective
// values that should be used when drawing this layer to screen,
// accounting for this layer possibly being a shadow.
Expand Down
7 changes: 6 additions & 1 deletion gfx/layers/LayersTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
#endif
#define MOZ_LAYERS_LOG(_args) \
MOZ_LOG(LayerManager::GetLog(), LogLevel::Debug, _args)
#define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args)
#define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) \
do { \
if (layer->AsShadowableLayer()) { \
MOZ_LOG(LayerManager::GetLog(), LogLevel::Debug, _args); \
} \
} while (0)

#define INVALID_OVERLAY -1

Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/PersistentBufferProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "PersistentBufferProvider.h"

#include "Layers.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/Maybe.h"
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/apz/src/AsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "mozilla/layers/APZUtils.h" // for AsyncTransform
#include "mozilla/layers/CompositorController.h" // for CompositorController
#include "mozilla/layers/DirectionUtils.h" // for GetAxis{Start,End,Length,Scale}
#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent
#include "mozilla/layers/MetricsSharingController.h" // for MetricsSharingController
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/Unused.h" // for unused
Expand Down Expand Up @@ -3659,6 +3660,7 @@ Maybe<CSSPoint> AsyncPanZoomController::GetCurrentAnimationDestination(
ParentLayerPoint
AsyncPanZoomController::AdjustHandoffVelocityForOverscrollBehavior(
ParentLayerPoint& aHandoffVelocity) const {

ParentLayerPoint residualVelocity;
ScrollDirections handoffDirections = GetAllowedHandoffDirections();
if (!handoffDirections.contains(ScrollDirection::eHorizontal)) {
Expand Down
1 change: 1 addition & 0 deletions gfx/layers/apz/util/APZCCallbackHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "mozilla/dom/MouseEventBinding.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/RepaintRequest.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
Expand Down
31 changes: 29 additions & 2 deletions gfx/layers/client/ImageClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/layers/TextureClientOGL.h" // for SurfaceTextureClient
#include "mozilla/mozalloc.h" // for operator delete, etc
Expand All @@ -48,6 +48,9 @@ already_AddRefed<ImageClient> ImageClient::CreateImageClient(
result =
new ImageClientSingle(aForwarder, aFlags, CompositableType::IMAGE);
break;
case CompositableType::IMAGE_BRIDGE:
result = new ImageClientBridge(aForwarder, aFlags);
break;
case CompositableType::UNKNOWN:
result = nullptr;
break;
Expand Down Expand Up @@ -274,5 +277,29 @@ ImageClient::ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
mType(aType),
mLastUpdateGenerationCounter(0) {}

ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,
TextureFlags aFlags)
: ImageClient(aFwd, aFlags, CompositableType::IMAGE_BRIDGE) {}

bool ImageClientBridge::UpdateImage(ImageContainer* aContainer,
uint32_t aContentFlags) {
if (!GetForwarder() || !mLayer) {
return false;
}
if (mAsyncContainerHandle == aContainer->GetAsyncContainerHandle()) {
return true;
}

mAsyncContainerHandle = aContainer->GetAsyncContainerHandle();
if (!mAsyncContainerHandle) {
// If we couldn't contact a working ImageBridgeParent, just return.
return true;
}

static_cast<ShadowLayerForwarder*>(GetForwarder())
->AttachAsyncCompositable(mAsyncContainerHandle, mLayer);
return true;
}

} // namespace layers
} // namespace mozilla
18 changes: 18 additions & 0 deletions gfx/layers/client/ImageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ class ImageClientSingle : public ImageClient {
nsTArray<Buffer> mBuffers;
};

/**
* Image class to be used for async image uploads using the image bridge
* protocol.
* We store the ImageBridge id in the TextureClientIdentifier.
*/
class ImageClientBridge : public ImageClient {
public:
ImageClientBridge(CompositableForwarder* aFwd, TextureFlags aFlags);

bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) override;
bool Connect(ImageContainer* aImageContainer) override { return false; }

TextureInfo GetTextureInfo() const override { return TextureInfo(mType); }

protected:
CompositableHandle mAsyncContainerHandle;
};

} // namespace layers
} // namespace mozilla

Expand Down
16 changes: 15 additions & 1 deletion gfx/layers/client/TextureClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/PTextureChild.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/TextureClientOGL.h"
#include "mozilla/layers/TextureClientRecycleAllocator.h"
#include "mozilla/layers/TextureRecorded.h"
Expand Down Expand Up @@ -1033,6 +1034,13 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return false;
}
if (ShadowLayerForwarder* forwarder = aForwarder->AsLayerForwarder()) {
// Do the DOM labeling.
if (nsISerialEventTarget* target = forwarder->GetEventTarget()) {
forwarder->GetCompositorBridgeChild()->ReplaceEventTargetForActor(
mActor, target);
}
}
mActor->mCompositableForwarder = aForwarder;
mActor->mUsesImageBridge =
aForwarder->GetTextureForwarder()->UsesImageBridge();
Expand All @@ -1051,14 +1059,20 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
mExternalImageId =
aForwarder->GetTextureForwarder()->GetNextExternalImageId();

nsISerialEventTarget* target = nullptr;
// Get the layers id if the forwarder is a ShadowLayerForwarder.
if (ShadowLayerForwarder* forwarder = aForwarder->AsLayerForwarder()) {
target = forwarder->GetEventTarget();
}

ReadLockDescriptor readLockDescriptor = null_t();
if (mReadLock) {
mReadLock->Serialize(readLockDescriptor, GetAllocator()->GetParentPid());
}

PTextureChild* actor = aForwarder->GetTextureForwarder()->CreateTexture(
desc, readLockDescriptor, aForwarder->GetCompositorBackendType(),
GetFlags(), mSerial, mExternalImageId, nullptr);
GetFlags(), mSerial, mExternalImageId, target);

if (!actor) {
gfxCriticalNote << static_cast<int32_t>(desc.type()) << ", "
Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/composite/CompositableHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ already_AddRefed<CompositableHost> CompositableHost::Create(
const TextureInfo& aTextureInfo, bool aUseWebRender) {
RefPtr<CompositableHost> result;
switch (aTextureInfo.mCompositableType) {
case CompositableType::IMAGE_BRIDGE:
NS_ERROR("Cannot create an image bridge compositable this way");
break;
case CompositableType::CONTENT_TILED:
result = new TiledContentHost(aTextureInfo);
break;
Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/ipc/CompositableForwarder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CompositableClient;
class CompositableHandle;
class ImageContainer;
class PTextureChild;
class ShadowLayerForwarder;
class SurfaceDescriptorTiles;
class TextureClient;
class ThebesBufferData;
Expand Down Expand Up @@ -111,6 +112,8 @@ class CompositableForwarder : public KnowsCompositor {

static uint32_t GetMaxFileDescriptorsPerMessage();

virtual ShadowLayerForwarder* AsLayerForwarder() { return nullptr; }

protected:
nsTArray<RefPtr<TextureClient>> mTexturesToRemove;
nsTArray<RefPtr<CompositableClient>> mCompositableClientsToRemove;
Expand Down
27 changes: 27 additions & 0 deletions gfx/layers/ipc/CompositorBridgeChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "mozilla/layers/APZCTreeManagerChild.h"
#include "mozilla/layers/CanvasChild.h"
#include "mozilla/layers/LayerManager.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/PLayerTransactionChild.h"
#include "mozilla/layers/PTextureChild.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient
#include "mozilla/layers/TextureClientPool.h" // for TextureClientPool
Expand Down Expand Up @@ -55,6 +57,7 @@

using mozilla::Unused;
using mozilla::gfx::GPUProcessManager;
using mozilla::layers::LayerTransactionChild;

namespace mozilla {
namespace layers {
Expand Down Expand Up @@ -170,6 +173,14 @@ void CompositorBridgeChild::Destroy() {
return;
}

AutoTArray<PLayerTransactionChild*, 16> transactions;
ManagedPLayerTransactionChild(transactions);
for (int i = transactions.Length() - 1; i >= 0; --i) {
RefPtr<LayerTransactionChild> layers =
static_cast<LayerTransactionChild*>(transactions[i]);
layers->Destroy();
}

AutoTArray<PWebRenderBridgeChild*, 16> wrBridges;
ManagedPWebRenderBridgeChild(wrBridges);
for (int i = wrBridges.Length() - 1; i >= 0; --i) {
Expand Down Expand Up @@ -303,6 +314,22 @@ bool CompositorBridgeChild::CompositorIsInGPUProcess() {
return bridge->OtherPid() != dom::ContentChild::GetSingleton()->OtherPid();
}

PLayerTransactionChild* CompositorBridgeChild::AllocPLayerTransactionChild(
const nsTArray<LayersBackend>& aBackendHints, const LayersId& aId) {
LayerTransactionChild* c = new LayerTransactionChild(aId);
c->AddIPDLReference();

return c;
}

bool CompositorBridgeChild::DeallocPLayerTransactionChild(
PLayerTransactionChild* actor) {
LayersId childId = static_cast<LayerTransactionChild*>(actor)->GetId();
ClearSharedFrameMetricsData(childId);
static_cast<LayerTransactionChild*>(actor)->ReleaseIPDLReference();
return true;
}

mozilla::ipc::IPCResult CompositorBridgeChild::RecvInvalidateLayers(
const LayersId& aLayersId) {
if (mLayerManager) {
Expand Down
Loading

0 comments on commit c83e348

Please sign in to comment.