Files
palemoon27/gfx/layers/ipc/CompositableTransactionParent.cpp
T
roytam1 a057fcd85b import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1201329 - Use AlignedStorage2 instead of char[] for IPDL union members. r=billm (420db1710)
- Bug 1146214 - Remove unused set fence functions. r=nical (148188894)
- Bug 1146214 - Combine FenceHandle and FenceHandleFromChild. r=nical (9d33cdedc)
- Bug 1147894 - Remove the redundant OpUpdateTexture IPDL message. r=sotaro (c3b037c92)
- Bug 1146214 - Implement fence delivery. Combine ipc messages and remove reply fence delivery message. r=nical (cd115f0db)
- Bug 1146214 - Remove the unused code after refactoring. r=nical (2582f1dfa)
- Bug 1146214 - Rename some functions after refactoring. r=nical (fd7655c71)
- Bug 1150381 - [LayerScope]: Don't showing the same texture in the same frame on LayerScope. r=chiajung (7a5310113)
- Bug 1162395 - [LayerScope]: No need to read and send the texture when the same texture id contains in a frame. r=cku (2c67a0994)
- Bug 1168015 - Dump source image from graphic buffer directly on B2G. r=kamidphish, r=hshih (108f3dd5a)
- Bug 1158575: Support using GDI rendering for opaque surfaces when using cross-process layers. r=jrmuizel (8913ea2ff)
- Bug 1155498 - Use FdObj to replace FenceHandle's android fence. r=sotaro (ac0f66f02)
- Bug 1155498 - Part 2 - Use new FenceHandle to handle the fence in TextureHost. r=sotaro (8c3cd6427)
- Bug 1152370 part 1 - Add android aosp VirtualDisplaySurface r=mwu (795674527)
- Bug 1152370 part 2 - Add DisplaySurface r=mwu (f4e7cb123)
- Bug 1151936 - Update GLContextEGL's EGLSurface override handling r=jgilbert (a1a72947b)
- Bug 1154313 - Move sUsingHwc to gfxPrefs r=mwu,nical (d315f572a)
- Bug 1152361 - Ensure outbufAcquireFenceFd is initialized during boot animation. r=mwu (c17f9bc1a)
- Bug 1152135 - Split EGLSurface buffer swap and HWC buffer swap r=mwu,nical,jgilbert (2ec0aaccc)
- Bug 1148149 - Support Android Presentation API. r=snorp, r=jgilbert (60ae01557)
- Bug 1150518 - Remove glClear() on blit composition r=Sushil (24b242a14)
- Bug 1152370 part 3 - Use DisplaySurface r=mwu (c531c0b44)
- Bug 1157661 - Fix a null-check in CompositorOGL::DrawQuad. r=nical (c00d429d3)
- Bug 1113425 part 1 - Fix some bad CSS comment syntax in animation tests; r=mattwoodrow (7abbbb3de)
- Bug 1113425 part 2 - Apply async properties when querying the animated transform; r=mattwoodrow (52e778eeb)
- Bug 1113425 part 4 - Enable test_deferred_start.html on all platforms; r=mattwoodrow (3884a02a3)
- Bug 1113425 part 3 - Make test_deferred_start.html wait an extra frame; r=mattwoodrow (0971c8836)
- Bug 1148949 - Apply async properties when querying the animated transform for cross-process compositor parents too; r=mattwoodrow (8bdeafc25)
- Bug 1157066. When reading back the OMTA transfrom of a layer don't include transforms from async panning or zooming. r=kats,birtles (43c1bab02)
- Bug 1129133 - Clean up GeckoTouchDispatcher so that it's a real singleton. r=kats,mwu (ac97ee5f4)
- Bug 1140578 - Remove some redundant code and an unused return value. r=mchang (9d02a9794)
- Bug 1140578 - Simplify some code. r=mchang (5a2f95805)
- Bug 1140578 - Add a explicit flag to track if we have pending touch moves to process. r=mchang (3255a2ac8)
- Bug 1140578 - Prevent resampling moves across non-move touch events. r=mchang (5a2622f6c)
- Bug 1146987 - Deal with cases where we get a batch of interleaved move and non-move events on the libui thread before anything is processed, with resampling disabled. r=mchang (462ce355c)
- Bug 1149412 - Remove bad assertion. r=mchang (d9d2db4ba)
- Bug 1137151: Marked destructor of |GeckoTouchDispatcher| as protected, r=mwu (21fae6af2)
- Bug 1138502. Reset vsync unobserve count if a force composite occurs. r=mstange (9682c9e62)
- Bug 1148583 - Dispatch touch events before composites. r=kats (cfabb0eef)
- Bug 1128690 - Ensure Talos Performance Tests still work with silk enabled. r=mstange (089e87b89)
- Bug 1138181 - Be more aggressive in updating plugin geometry in the compositor, avoids filtering out important offset updates that don't involve remote layer tree updates. r=roc (e341636de)
- comment coming from Bug 1143249 (2f6c7bdc8)
- Bug 1154614 - Don't try to pick up the same non-reentrant lock twice. r=dvander a=RyanVM (c69cba3d9)
- Bug 1156981 - Split CompositorParent's scheduling of composition to CompositorScheduler r=mchang (bf87b2ba3)
- Bug 1139541 - Make HWC skip opacity=0 layers. r=sotaro (cd6d5114c)
- Bug 1149646 - Delete non-uniform vsync interval warning. r=kats (5bc0cd3fa)
- Bug 1155498 - Part 3 - Use new FenceHandle to handle the fence in Compositor. r=sotaro (f5c685606)
-  Bug 1155498 - Part 4 - Use new FenceHandle to handle the fence in TextureClient. r=sotaro (0390d19fd)
- Bug 1155498 - Part 5 - Use new FenceHandle to handle Decoder fence. r=sotaro (a99b62351)
- Bug 1164513 - Add nullptr check r=milan (41053d048)
- Bug 1155495 - Part 1: Remove TextureHostOGL and integrate the platform specific API into TextureHost. r=nical, r=sotaro (9c909e5e2)
- Bug 1155495 - Part 2: Remove unnecessary class inheritance and casting. r=nical, r=sotaro (4ce5869ff)
- Bug 1133007 - Send the content of a texture only if its was altered since previous transmission. r=kamidphish, r=boris (f78a07160)
- Bug 1156456 patch 1 - Reftests comparing a 3-D transformed cube generated by main-thread paths and off-main-thread animations paths. r=birtles (f0f5309d9)
- Bug 1156456 patch 2 - Transform the z component just like the x and y. r=birtles (cc36b5b91)
- Bug 1156456 patch 3 - Send transform origin and perspective origin to layer in device pixels rather than CSS pixels. r=birtles (94ea8a04a)
- Bug 1156456 followup - Also annotate as fuzzy on Mulet, on a CLOSED TREE. (712c97eff)
- Bug 1156456 followup - Add a simple reftest for off-main-thread animation of opacity. (eac0fe0e4)
- Bug 1157455 patch 1 - Add tests for OMTA transforms in degrees in addition to those in radians. r=birtles (83fb5b7af)
- Bug 1157455 patch 2 - Send angles (in CSS transform functions) to the compositor thread with their units rather than sending all such angles in radians. r=birtles (a8b47f5b0)
- Bug 1157455 patch 3 - When interpolating angles, preserve units when possible in order to avoid floating point error. r=birtles (ace148e00)
- Bug 1157455 followup - fix test_transitions_per_property.html to expect different angle interpolation results, on a CLOSED TREE. (270ef56eb)
- Bug 1022080 - Don't force intermediate surfaces when dumping textures, unless explicitly specified. r=nical (0a010b6c8)
- Bug 1022080 - Make non-HTML dumping of textures work better. r=nical (304939544)
2020-12-02 09:53:44 +08:00

264 lines
9.9 KiB
C++

/* -*- 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 "CompositableTransactionParent.h"
#include "CompositableHost.h" // for CompositableParent, etc
#include "CompositorParent.h" // for CompositorParent
#include "GLContext.h" // for GLContext
#include "Layers.h" // for Layer
#include "RenderTrace.h" // for RenderTraceInvalidateEnd, etc
#include "TiledLayerBuffer.h" // for TiledLayerComposer
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr
#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
#include "mozilla/layers/TextureHost.h" // for TextureHost
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
#include "mozilla/layers/PaintedLayerComposite.h"
#include "mozilla/mozalloc.h" // for operator delete
#include "mozilla/unused.h"
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
#include "nsRegion.h" // for nsIntRegion
namespace mozilla {
namespace layers {
class ClientTiledLayerBuffer;
class Compositor;
template<typename Op>
CompositableHost* AsCompositable(const Op& op)
{
return CompositableHost::FromIPDLActor(op.compositableParent());
}
// This function can in some cases fail and return false without it being a bug.
// This can theoretically happen if the ImageBridge sends frames before
// we created the layer tree. Since we can't enforce that the layer
// tree is already created before ImageBridge operates, there isn't much
// we can do about it, but in practice it is very rare.
// Typically when a tab with a video is dragged from a window to another,
// there can be a short time when the video is still sending frames
// asynchonously while the layer tree is not reconstructed. It's not a
// big deal.
// Note that Layers transactions do not need to call this because they always
// schedule the composition, in LayerManagerComposite::EndTransaction.
template<typename T>
bool ScheduleComposition(const T& op)
{
CompositableHost* comp = AsCompositable(op);
uint64_t id = comp->GetCompositorID();
if (!comp || !id) {
return false;
}
CompositorParent* cp = CompositorParent::GetCompositor(id);
if (!cp) {
return false;
}
cp->ScheduleComposition();
return true;
}
bool
CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv)
{
switch (aEdit.type()) {
case CompositableOperation::TOpPaintTextureRegion: {
MOZ_LAYERS_LOG(("[ParentSide] Paint PaintedLayer"));
const OpPaintTextureRegion& op = aEdit.get_OpPaintTextureRegion();
CompositableHost* compositable = AsCompositable(op);
Layer* layer = compositable->GetLayer();
if (!layer || layer->GetType() != Layer::TYPE_PAINTED) {
return false;
}
PaintedLayerComposite* thebes = static_cast<PaintedLayerComposite*>(layer);
const ThebesBufferData& bufferData = op.bufferData();
RenderTraceInvalidateStart(thebes, "FF00FF", op.updatedRegion().GetBounds());
nsIntRegion frontUpdatedRegion;
if (!compositable->UpdateThebes(bufferData,
op.updatedRegion(),
thebes->GetValidRegion(),
&frontUpdatedRegion))
{
return false;
}
replyv.push_back(
OpContentBufferSwap(op.compositableParent(), nullptr, frontUpdatedRegion));
RenderTraceInvalidateEnd(thebes, "FF00FF");
break;
}
case CompositableOperation::TOpUpdatePictureRect: {
const OpUpdatePictureRect& op = aEdit.get_OpUpdatePictureRect();
CompositableHost* compositable = AsCompositable(op);
MOZ_ASSERT(compositable);
compositable->SetPictureRect(op.picture());
break;
}
case CompositableOperation::TOpUseTiledLayerBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Paint TiledLayerBuffer"));
const OpUseTiledLayerBuffer& op = aEdit.get_OpUseTiledLayerBuffer();
CompositableHost* compositable = AsCompositable(op);
TiledLayerComposer* tileComposer = compositable->AsTiledLayerComposer();
NS_ASSERTION(tileComposer, "compositable is not a tile composer");
const SurfaceDescriptorTiles& tileDesc = op.tileLayerDescriptor();
bool success = tileComposer->UseTiledLayerBuffer(this, tileDesc);
if (!success) {
return false;
}
break;
}
case CompositableOperation::TOpRemoveTexture: {
const OpRemoveTexture& op = aEdit.get_OpRemoveTexture();
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->RemoveTextureHost(tex);
// send FenceHandle if present.
SendFenceHandleIfPresent(op.textureParent(), compositable);
break;
}
case CompositableOperation::TOpRemoveTextureAsync: {
const OpRemoveTextureAsync& op = aEdit.get_OpRemoveTextureAsync();
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->RemoveTextureHost(tex);
if (!IsAsync() && ImageBridgeParent::GetInstance(GetChildProcessId())) {
// send FenceHandle if present via ImageBridge.
ImageBridgeParent::AppendDeliverFenceMessage(
GetChildProcessId(),
op.holderId(),
op.transactionId(),
op.textureParent(),
compositable);
// If the message is recievied via PLayerTransaction,
// Send message back via PImageBridge.
ImageBridgeParent::ReplyRemoveTexture(
GetChildProcessId(),
OpReplyRemoveTexture(op.holderId(),
op.transactionId()));
} else {
// send FenceHandle if present.
SendFenceHandleIfPresent(op.textureParent(), compositable);
ReplyRemoveTexture(OpReplyRemoveTexture(op.holderId(),
op.transactionId()));
}
break;
}
case CompositableOperation::TOpUseTexture: {
const OpUseTexture& op = aEdit.get_OpUseTexture();
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->UseTextureHost(tex);
MaybeFence maybeFence = op.fence();
if (maybeFence.type() == MaybeFence::TFenceHandle) {
FenceHandle fence = maybeFence.get_FenceHandle();
if (fence.IsValid() && tex) {
tex->SetAcquireFenceHandle(fence);
}
}
if (IsAsync() && compositable->GetLayer()) {
ScheduleComposition(op);
// Async layer updates don't trigger invalidation, manually tell the layer
// that its content have changed.
compositable->GetLayer()->SetInvalidRectToVisibleRegion();
}
break;
}
case CompositableOperation::TOpUseComponentAlphaTextures: {
const OpUseComponentAlphaTextures& op = aEdit.get_OpUseComponentAlphaTextures();
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> texOnBlack = TextureHost::AsTextureHost(op.textureOnBlackParent());
RefPtr<TextureHost> texOnWhite = TextureHost::AsTextureHost(op.textureOnWhiteParent());
MOZ_ASSERT(texOnBlack && texOnWhite);
compositable->UseComponentAlphaTextures(texOnBlack, texOnWhite);
if (IsAsync()) {
ScheduleComposition(op);
}
break;
}
#ifdef MOZ_WIDGET_GONK
case CompositableOperation::TOpUseOverlaySource: {
const OpUseOverlaySource& op = aEdit.get_OpUseOverlaySource();
CompositableHost* compositable = AsCompositable(op);
MOZ_ASSERT(compositable->GetType() == CompositableType::IMAGE_OVERLAY, "Invalid operation!");
compositable->UseOverlaySource(op.overlay());
break;
}
#endif
default: {
MOZ_ASSERT(false, "bad type");
}
}
return true;
}
void
CompositableParentManager::SendPendingAsyncMessages()
{
if (mPendingAsyncMessage.empty()) {
return;
}
// Some type of AsyncParentMessageData message could have
// one file descriptor (e.g. OpDeliverFence).
// A number of file descriptors per gecko ipc message have a limitation
// on OS_POSIX (MACOSX or LINUX).
#if defined(OS_POSIX)
static const uint32_t kMaxMessageNumber = FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE;
#else
// default number that works everywhere else
static const uint32_t kMaxMessageNumber = 250;
#endif
InfallibleTArray<AsyncParentMessageData> messages;
messages.SetCapacity(mPendingAsyncMessage.size());
for (size_t i = 0; i < mPendingAsyncMessage.size(); i++) {
messages.AppendElement(mPendingAsyncMessage[i]);
// Limit maximum number of messages.
if (messages.Length() >= kMaxMessageNumber) {
SendAsyncMessage(messages);
// Initialize Messages.
messages.Clear();
}
}
if (messages.Length() > 0) {
SendAsyncMessage(messages);
}
mPendingAsyncMessage.clear();
}
} // namespace layers
} // namespace mozilla