Files
palemoon27/gfx/layers/basic/BasicContainerLayer.cpp
T
roytam1 f553544f33 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1144012 - Part 1: Create HwcDevice wrapper. r=sotaro (dcb5bca6c)
- Bug 1143522 - Convert cliprect coordinate in gonk code. r=botond (4b5bfe61b)
- Bug 1144012 - Part 2: Use wrapper in HwcComposer2D. r=sotaro (783cbca1a)
- Bug 1169093 - Do not use HWC when a region of layer is too small r=mattwoodrow (bf77e1a55)
- Bug 1155797 - P1: extract format BPP util function. r=mwu (06f3b96f5)
- Bug 1155797 - P2: show a black solid color frame if we don't have the bootAnim. r=mwu (2e6dda6d2)
- Bug 1153395 - Disable Hardware Vsync on Non Kit-Kat devices. r=mwu (e7ec09cee)
- Bug 1151489. Enable software vsync on all b2g versions. r=kats (597cdc85f)
- Bug 1155797 - P3: turn on vsync for kk, l and up. r=mwu (3e8187e50)
- Bug 1144012 - Part 3: Wrap vsync code. r=sotaro (4eb4af3d8)
- Bug 1144012 - Part 4: Remove the usage of mHwc from GonkDisplayICS. r=sotaro (ad5e257f0)
- Bug 1187048 - Code clean up around nsScreenGonk's EGLSurface handling r=mwu (eecdaf1ef)
- Bug 1188877 - Fix LayerComposite::SetClearRect() calling r=mwu (d748f2c50)
- Bug 1180657 - Use hwc directly on GonkDisplayICS. r=sotaro (55d2699aa)
- Bug 1163905 - b2g.neterror.url should use a relative URL. r=fabrice (abefb3d0b)
- Bug 1186000 - Support screen mirroring to HDMI display on gonk r=mwu,mattwoodrow (3df30f9dd)
- Bug 1186031 - Fix SetDispAcquireFence() calling r=nical (d561ef18c)
- Bug 1191457 - Revert SetDispAcquireFence() calling change r=nical (46bc14d4c)
- Bug 1192352 - Fix fence handling of display mirroring r=nical (fb686f922)
- Bug 1170966 - Check quad's effective region before drawing. r=nical, a=me (d85277b8e)
- Bug 1186236 - Fix drawQuad culling bug. r=nical (4fd64fb71)
- Bug 1192192 - fix quad culling method. r=nical (03c59a942)
- Bug 1179933, add Layer::ReplaceEffectiveTransform for temporary transform changes; r=mstange (c9e0c919a)
- Bug 1151937; [webvr] change deviceId/hardwareId to simple values; r=jrmuizel CLOSED TREE (f4f2332ab)
- Bug 1151904; fix Linux OVR library typo to use lowercase lib; r=me (7580c527b)
- Bug 1179944, [webvr] support Oculus 0.6.0 runtime and rendering; r=mstange (954bbb49c)
- Bug 633097 - Fix jittering animated text by disallowing flattening into a container layer that has animated text. r=mwoodrow (7eada20c4)
- Bug 914457 - Part 1: Use an empty clip rect for layers with an empty visible region (7b2462a5f)
- Bug 914457 - Part 2: Implement Crashtest (f6f6fcfaa)
- Bug 1149923 - Let 2D mask effect can check whether to use IntermediateSurface or not in its own logic. r=roc (f90c6f19c)
- Bug 1177018 - When finding a painted layer for a display item, include event regions in a layer's visible region. r=tn (ccedfcc38)
- Bug 1200158 - Define PaintedLayerData::AccumulateEventRegions() out of line. r=mstange (8fcfe35fd)
- Bug 1200158 - Avoid expensive computations involving the maybe-hit region in hot code paths. r=mstange (871c0944c)
- Bug 1201548 - When testing whether the visible rect intersects event regions in FindPaintedLayerFor(), only use the bounds of the event regions. r=mstange (976798e33)
- Bug 1180295 - Rip out call to setContentDocumentFixedPositionMargins. r=rbarker (c24ed7a7f)
- Bug 1166301 - Use the correct format flags for printing fixed position data in the layers dump. r=kats (a51d7b42a)
- Bug 1166301 - Store a flag on Layer to tell fixed background layers apart from fixed position layers. r=mattwoodrow (c9d1c1c63)
- Bug 1166301 - Annotate fixed background layers with scroll metadata for the animated geometry root of the frame they're the background of. r=mattwoodrow (0f3f8a715)
- Bug 1097464 - Part 6: Handle preserves-3d by compositor. r=roc (b231219b9)
- Hoist scroll info items above inactive blur containers. (bug 1193557 part 1, r=mstange) (d6212d65c)
- Ensure scroll info layers have a dispatch-to-content region. (bug 1193557 part 2, r=kats) (97fe0e4d7)
- Bug 1145143 - Check if buffer size is correct before calling the update. r=nical (fc4019b45)
- Bug 1145143 - When we fail to UpdateRenderTarget, report the size as well. r=bas (885668a28)
- Bug 1161670, cache D3D11 ShaderResourceView on TextureSourceD3D11; r=bas,jrmuizel (5fbd7d741)
- Bug 1188700, [webvr] Fix VR distortion compositing in d3d11/gl to take into account rendertarget size and transform; r=kip (47a73c37a)
- Allow wheel tests finer control over the refresh driver. (bug 1140293, r=mstange) (c47d17d0a)
- Bug 1164274 - Disable the wheel-scroll test on Mulet for intermittent failures. r=mstange (24ba31ab6)
- Bug 1172648 - Full-stack APZ mochitest for bug 1151667. r=kats (19b3fbd74)
- Bug 1173580 - Full-stack APZ layerization mochitest. r=kats (df7d6efc1)
- Bug 1175585 - Full-stack mochitest for wheel transactions. r=kats (b2e00b916)
- Bug 961289 - Add an initial mochitest (for bug 982141) that exercises the APZ testing framework. r=ehsan,kats,BenWa,ted (9e0eea39f)
- Bug 1151663 - Extract some helper functions for writing APZ mochitests into a separate file. r=kats (e0a565ca4)
- remaining  Bug 1151663 - Fix reconstruction of APZC tree structure in APZ mochitests. r=kats (f9836eb45)
- part of Bug 1139155 - Add a basic sanity test to exercise touch-based scrolling on B2G. r=botond (0b1673810)
- part of Add a test case for bug 1193557, r=kats. (157e5d8d0)
- Bug 1166649 - Fix GrallocTextureClient.cpp unified build bustage. r=nical (42d01ef5e)
- namespace (0096c7a24)
- Bug 1181085 - Don't accumulate ImageCompositeNotifications when we're compositing to a DrawTarget. r=nical (e7ad9e485)
- Bug 1186159 - Add an APZ minimap. r=kats (576b74a94)
- Bug 1167215 - Composite on every vsync until the scheduled one. r=roc (6ff8f84ca)
2022-01-04 09:29:39 +08:00

169 lines
5.8 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BasicContainerLayer.h"
#include <sys/types.h> // for int32_t
#include "BasicLayersImpl.h" // for ToData
#include "basic/BasicImplData.h" // for BasicImplData
#include "basic/BasicLayers.h" // for BasicLayerManager
#include "mozilla/gfx/BaseRect.h" // for BaseRect
#include "mozilla/mozalloc.h" // for operator new
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "nsPoint.h" // for nsIntPoint
#include "nsRegion.h" // for nsIntRegion
#include "ReadbackProcessor.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
BasicContainerLayer::~BasicContainerLayer()
{
while (mFirstChild) {
ContainerLayer::RemoveChild(mFirstChild);
}
MOZ_COUNT_DTOR(BasicContainerLayer);
}
void
BasicContainerLayer::ComputeEffectiveTransforms(const Matrix4x4& aTransformToSurface)
{
// We push groups for container layers if we need to, which always
// are aligned in device space, so it doesn't really matter how we snap
// containers.
Matrix residual;
Matrix4x4 idealTransform = GetLocalTransform() * aTransformToSurface;
if (!Extend3DContext() && !Is3DContextLeaf()) {
// For 3D transform leaked from extended parent layer.
idealTransform.ProjectTo2D();
}
if (!idealTransform.CanDraw2D()) {
if (!Extend3DContext() ||
(!idealTransform.Is2D() && Creates3DContextWithExtendingChildren())) {
if (!Creates3DContextWithExtendingChildren()) {
idealTransform.ProjectTo2D();
}
mEffectiveTransform = idealTransform;
ComputeEffectiveTransformsForChildren(Matrix4x4());
ComputeEffectiveTransformForMaskLayers(Matrix4x4());
mUseIntermediateSurface = true;
return;
}
mEffectiveTransform = idealTransform;
ComputeEffectiveTransformsForChildren(idealTransform);
ComputeEffectiveTransformForMaskLayers(idealTransform);
mUseIntermediateSurface = false;
return;
}
// With 2D transform or extended 3D context.
Layer* child = GetFirstChild();
bool hasSingleBlendingChild = false;
if (!HasMultipleChildren() && child) {
hasSingleBlendingChild = child->GetMixBlendMode() != CompositionOp::OP_OVER;
}
/* If we have a single childand it is not blending,, it can just inherit our opacity,
* otherwise we need a PushGroup and we need to mark ourselves as using
* an intermediate surface so our children don't inherit our opacity
* via GetEffectiveOpacity.
* Having a mask layer always forces our own push group
* Having a blend mode also always forces our own push group
*/
mUseIntermediateSurface =
GetMaskLayer() ||
GetForceIsolatedGroup() ||
(GetMixBlendMode() != CompositionOp::OP_OVER && HasMultipleChildren()) ||
(GetEffectiveOpacity() != 1.0 && (HasMultipleChildren() || hasSingleBlendingChild));
if (!Extend3DContext()) {
idealTransform.ProjectTo2D();
}
mEffectiveTransform =
!mUseIntermediateSurface ?
idealTransform : SnapTransformTranslation(idealTransform, &residual);
Matrix4x4 childTransformToSurface =
(!mUseIntermediateSurface ||
(mUseIntermediateSurface && !Extend3DContext() /* 2D */)) ?
idealTransform : Matrix4x4::From2D(residual);
ComputeEffectiveTransformsForChildren(childTransformToSurface);
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
}
bool
BasicContainerLayer::ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect)
{
Matrix transform;
if (!GetEffectiveTransform().CanDraw2D(&transform) ||
ThebesMatrix(transform).HasNonIntegerTranslation())
return false;
nsIntPoint offset(int32_t(transform._31), int32_t(transform._32));
gfx::IntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset);
nsIntRegion covered;
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
if (ToData(l)->IsHidden())
continue;
Matrix childTransform;
if (!l->GetEffectiveTransform().CanDraw2D(&childTransform) ||
ThebesMatrix(childTransform).HasNonIntegerTranslation() ||
l->GetEffectiveOpacity() != 1.0)
return false;
nsIntRegion childRegion = l->GetEffectiveVisibleRegion();
childRegion.MoveBy(int32_t(childTransform._31), int32_t(childTransform._32));
childRegion.And(childRegion, rect);
if (l->GetClipRect()) {
childRegion.And(childRegion, ParentLayerIntRect::ToUntyped(*l->GetClipRect()) + offset);
}
nsIntRegion intersection;
intersection.And(covered, childRegion);
if (!intersection.IsEmpty())
return false;
covered.Or(covered, childRegion);
}
return covered.Contains(rect);
}
void
BasicContainerLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback)
{
ReadbackProcessor readback;
if (BasicManager()->IsRetained()) {
readback.BuildUpdates(this);
}
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
BasicImplData* data = ToData(l);
data->Validate(aCallback, aCallbackData, &readback);
if (l->GetMaskLayer()) {
data = ToData(l->GetMaskLayer());
data->Validate(aCallback, aCallbackData, nullptr);
}
}
}
already_AddRefed<ContainerLayer>
BasicLayerManager::CreateContainerLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<ContainerLayer> layer = new BasicContainerLayer(this);
return layer.forget();
}
} // namespace layers
} // namespace mozilla