Files
palemoon27/gfx/layers/basic/BasicLayersImpl.cpp
T
roytam1 61a988a8ac import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1225237 - Use stable hashing for DOMExpandoSet; r=jonco (4254b32429)
- Bug 1219288 - Store target shapes in module environment object rather than names r=shu (5cb08ce170)
- Bug 1219288 - Add GETIMPORT instruction for accessing module imports that are not namespace imports r=shu (487ccb37d4)
- Bug 1219288 - Optimize GETIMPORT instructions in baseline r=shu (938079be7f)
- Bug 1219288 - Optimize GETIMPORT instructions in Ion r=shu (cfa7b927a4)
- Bug 1224404 - Use stable hashing for WeakMapPtr; r=jonco (59df9ae61c)
- Bug 1223639. Use ForceInside to constrain the displayport rect to the scrollable rect instead of intersect. r=botond (12a978a2fd)
- Bug 1223639. Rename ForceInside to MoveInsideAndClamp so it's clearer what it does. r=botond (562f0a8f53)
- Bug 1212136 - Remove noisy warning that we don't have time to investigate properly. r=tnikkel (4d752f8b1a)
- Bug 1215356. When setting a display port, schedule paint on that frame, not the root frame of the document. r=mattwoodrow (bad289fbb7)
- Bug 1213711 - Initialize Preserves3DContext::mAccumulatedRectLevels. r=thinker. (99dbae372a)
- Bug 1175492 followup: remove extra dashes left over from removing -moz- prefixes. r=longsonr (060368e850)
- Bug 1207143 - Improve GetBounds() to avoid recomputing every time. r=roc (995b9e9d4f)
- Bug 1216386 - Improve AnimatedGeometryRootLookup::Hash. r=roc. (7c84489583)
- Bug 1201327 - Rename mDestRect to mImageLayerDestRect. r=mattwoodrow (fa32340de9)
- Bug 1201327 - Let DLBI detect background-position changes. r=mattwoodrow (de59480f0d)
- Bug 1201327 - Don't repaint the whole frame subtree when background-position changes. r=dbaron (26a085e548)
- Fix wheel events not working on scrollbars of inactive subframes. (bug 1216488, r=tn) (650d70eaf5)
- Bug 1206468 - Remove unused internal appearance value -moz-mac-unified-toolbar. r=mstange (0c56b0fd65)
- Bug 1214212 - Remove clips from separator transform items. r=roc (6f06f60ec9)
- Bug 947062 - Refactor nsDisplayBackgroundImage::GetLayerState. r=mattwoodrow (23d5496afc)
- Bug 1220020. When we turn something into an animated geometry root, clear the cache of animated geometry roots so it's not stale. r=tnikkel (90470c67ae)
- Bug 1156238. Always stop at the root reference frame when looking for an animated geometry root. r=roc,mattwoodrow (b7a41ac2fb)
- Bug 1156238. Fix the computation of animated geometry roots for transform items. r=mattwoodrow (523f062309)
- Bug 1156238. Skip setting async scroll clips if we aren't painting to the window because they are useless then. r=mstange (1d98f27c40)
- Bug 1205087 - Cache the AnimatedGeometryRoot on DisplayItem. r=roc (4f3f5b7e5e)
- Bug 1224209. The animated geometry root of a fixed pos and transformed frame needs to be that frame itself so FrameLayerBuilder can determine it is fixed pos. r=mattwoodrow (974a3ab1e0)
- Bug 1141884 - Handle wheel events on the main thread if the frame has snapping. r=dvander,mstange (3347cdd831)
- Bug 1176775 part 1 - [css-grid] Implement "Implied Minimum Size of Grid Items" (special min-width/height:auto behavior). r=dholbert (c28098d660)
- Bug 1176775 part 2 - [css-grid] Testcases for 'auto' min-sizing and intrinsic 'min-width|height'. (ec70253cc9)
- Bug 1215974. In GetNearestScrollableFrame don't skip the root scroll frame if we are asked to always match the root scroll frame even if it doesn't WantAsyncScroll(). r=botond (97094eb3b1)
- Bug 1215977. Only match the root scroll frame in GetNearestScrollableFrame if we encounter it. r=botond (69569c757c)
- Bug 1215977. Add a flag for GetNearestScrollable that makes fixed pos frames return the root scroll frame of their document. And make APZCCallbackHelper use it to restore previous behaviour. r=botond (c15650e2ba)
- Bug 1190936 - Attempt some graceful handling for an unexpected situation that otherwise crashes the browser. r=botond (61e5fc4b2c)
- Bug 1208780. Set a zero-margin displayport on all scrollable ancestors of frames with displayports if they don't already have a displayport. r=botond (1cb395354a)
- Bug 1221870. Make fixed pos items always find the root scroll frame when looking for the nearest scrollable. r=botond (739da0c2af)
- Bug 1122918 - Part 3 - Use the resolved physical values of 'float' and 'clear' properties during layout. r=heycam (46e77f1e0a)
- Bug 1223479 - Fix displayport size calculation on fennec. r=kats (bd54d7a6c9)
- Bug 1210560 - Part 3: Convert more complex SVG usecases to PushGroupForBlendBack. r=jwatt r=jrmuizel (1a72ef23ba)
- Bug 1210560 - Part 4: Remove code to support non operator-over in nsRenderDocument and move to CanvasRenderingContext2D::DrawWindow. r=roc (a475f22cd2)
- Bug 1210560 - Part 5: Convert BasicLayers usecases to PushGroupForBlendBack and temporary surfaces. r=jrmuizel (5706386aa9)
- Bug 1210560 - Part 6: Convert code to support non-operator OVER in nsCSSRendering to moz2d. r=roc (ba280199c0)
- Bug 1210560 - Part 7: Convert GTK widget code to use Moz2D instead of PushGroup/PopGroup. r=jwatt (d06408ec0a)
- Bug 1210560 - Part 8: Remove unused PushGroup/PopGroup/PopGroupToSource functions. r=jrmuizel (a39ad555c4)
- Bug 1210560 - Followup: Fix function definition prototype. r=bustage on a CLOSED TREE (daa75a342b)
- Bug 1210560 - Followup 2: Fix UniquePtr usage issue. r=bustage on a CLOSED TREE (68ee7667fe)
- Bug 1210560 - Followup 3: Fix an assertion that can occur on mochitest bc4. r=jrmuizel on a CLOSED TREE (6b68389154)
2023-01-06 17:42:55 +08:00

210 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 "BasicLayersImpl.h"
#include <new> // for operator new
#include "Layers.h" // for Layer, etc
#include "basic/BasicImplData.h" // for BasicImplData
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/DebugOnly.h" // for DebugOnly
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "AutoMaskData.h"
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
bool
GetMaskData(Layer* aMaskLayer,
const Point& aDeviceOffset,
AutoMoz2DMaskData* aMaskData)
{
if (aMaskLayer) {
RefPtr<SourceSurface> surface =
static_cast<BasicImplData*>(aMaskLayer->ImplData())->GetAsSourceSurface();
if (surface) {
Matrix transform;
Matrix4x4 effectiveTransform = aMaskLayer->GetEffectiveTransform();
DebugOnly<bool> maskIs2D = effectiveTransform.CanDraw2D(&transform);
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
transform.PostTranslate(-aDeviceOffset.x, -aDeviceOffset.y);
aMaskData->Construct(transform, surface);
return true;
}
}
return false;
}
already_AddRefed<SourceSurface>
GetMaskForLayer(Layer* aLayer, Matrix* aMaskTransform)
{
if (!aLayer->GetMaskLayer()) {
return nullptr;
}
MOZ_ASSERT(aMaskTransform);
AutoMoz2DMaskData mask;
if (GetMaskData(aLayer->GetMaskLayer(), Point(), &mask)) {
*aMaskTransform = mask.GetTransform();
RefPtr<SourceSurface> surf = mask.GetSurface();
return surf.forget();
}
return nullptr;
}
void
PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer)
{
AutoMoz2DMaskData mask;
if (GetMaskData(aMaskLayer, Point(), &mask)) {
aContext->SetMatrix(ThebesMatrix(mask.GetTransform()));
aContext->Mask(mask.GetSurface(), aOpacity);
return;
}
// if there is no mask, just paint normally
aContext->Paint(aOpacity);
}
void
FillRectWithMask(DrawTarget* aDT,
const Rect& aRect,
const Color& aColor,
const DrawOptions& aOptions,
SourceSurface* aMaskSource,
const Matrix* aMaskTransform)
{
if (aMaskSource && aMaskTransform) {
aDT->PushClipRect(aRect);
Matrix oldTransform = aDT->GetTransform();
aDT->SetTransform(*aMaskTransform);
aDT->MaskSurface(ColorPattern(aColor), aMaskSource, Point(), aOptions);
aDT->SetTransform(oldTransform);
aDT->PopClip();
return;
}
aDT->FillRect(aRect, ColorPattern(aColor), aOptions);
}
void
FillRectWithMask(DrawTarget* aDT,
const gfx::Point& aDeviceOffset,
const Rect& aRect,
const Color& aColor,
const DrawOptions& aOptions,
Layer* aMaskLayer)
{
AutoMoz2DMaskData mask;
if (GetMaskData(aMaskLayer, aDeviceOffset, &mask)) {
const Matrix& maskTransform = mask.GetTransform();
FillRectWithMask(aDT, aRect, aColor, aOptions, mask.GetSurface(), &maskTransform);
return;
}
FillRectWithMask(aDT, aRect, aColor, aOptions);
}
void
FillRectWithMask(DrawTarget* aDT,
const Rect& aRect,
SourceSurface* aSurface,
Filter aFilter,
const DrawOptions& aOptions,
ExtendMode aExtendMode,
SourceSurface* aMaskSource,
const Matrix* aMaskTransform,
const Matrix* aSurfaceTransform)
{
if (aMaskSource && aMaskTransform) {
aDT->PushClipRect(aRect);
Matrix oldTransform = aDT->GetTransform();
Matrix inverseMask = *aMaskTransform;
inverseMask.Invert();
Matrix transform = oldTransform * inverseMask;
if (aSurfaceTransform) {
transform = (*aSurfaceTransform) * transform;
}
SurfacePattern source(aSurface, aExtendMode, transform, aFilter);
aDT->SetTransform(*aMaskTransform);
aDT->MaskSurface(source, aMaskSource, Point(0, 0), aOptions);
aDT->SetTransform(oldTransform);
aDT->PopClip();
return;
}
aDT->FillRect(aRect,
SurfacePattern(aSurface, aExtendMode,
aSurfaceTransform ? (*aSurfaceTransform) : Matrix(),
aFilter), aOptions);
}
void
FillRectWithMask(DrawTarget* aDT,
const gfx::Point& aDeviceOffset,
const Rect& aRect,
SourceSurface* aSurface,
Filter aFilter,
const DrawOptions& aOptions,
Layer* aMaskLayer)
{
AutoMoz2DMaskData mask;
if (GetMaskData(aMaskLayer, aDeviceOffset, &mask)) {
const Matrix& maskTransform = mask.GetTransform();
FillRectWithMask(aDT, aRect, aSurface, aFilter, aOptions, ExtendMode::CLAMP,
mask.GetSurface(), &maskTransform);
return;
}
FillRectWithMask(aDT, aRect, aSurface, aFilter, aOptions, ExtendMode::CLAMP);
}
BasicImplData*
ToData(Layer* aLayer)
{
return static_cast<BasicImplData*>(aLayer->ImplData());
}
gfx::CompositionOp
GetEffectiveOperator(Layer* aLayer)
{
CompositionOp op = aLayer->GetEffectiveMixBlendMode();
if (op != CompositionOp::OP_OVER) {
return op;
}
return ToData(aLayer)->GetOperator();
}
ShadowableLayer*
ToShadowable(Layer* aLayer)
{
return aLayer->AsShadowableLayer();
}
bool
ShouldShadow(Layer* aLayer)
{
if (!ToShadowable(aLayer)) {
MOZ_ASSERT(aLayer->GetType() == Layer::TYPE_READBACK,
"Only expect not to shadow ReadbackLayers");
return false;
}
return true;
}
} // namespace layers
} // namespace mozilla