Files
palemoon27/gfx/layers/composite/PaintedLayerComposite.cpp
T
roytam1 f672f60d2d import change from rmottola/Arctic-Fox:
- Bug 1135100 - Don't update GC thing pointers that haven't changed after marking r=terrence (0df3ea820)
- Bug 1135857 - Remove ContentClientIncremental. r=mattwoodrow (059587352)
- Bug 1135809 - add apz. prefs to about:support. r=kats (6439aaf6b)
- Bug 1135361 - Fix position of ruby annotation in vertical-rl mode when justification is applied to the base. r=jfkthame (a00bb53be)
- Bug 1133288 - Remove nonstandard expression closures from editor. r=ehsan (605992184)
- Bug 1135361 - Reftest for ruby positioning in justified vertical text. r=xidorn (60fe87ae3)
- Bug 1135984 - Fix typo which made Context.__init__ set the unused exe (312c35ef2)
- Bug 1077864, Part 1: Check consistency of certificates' signature and signatureAlgorithm fields, r=keeler (9a11f90c3)
- Bug 1077864, Part 2: Override the trust level for OCSP response signer certs so that they are never considered trust anchors, r=keeler (c46772e6d)
- Bug 1077864, Part 3: update nsserrors.properties so error message gets localized. (935233549)
- Bug 1135407: Factor out duplicate logic in tests, r=keeler (383ff80c5)
- Bug 1131767: Prune away paths using unacceptable algorithms earlier, r=keeler (55182b7e2)
- Followup to Bug 1135563 - uiUnsupportedAlreadyNotified.js doesn't use httpd.js. r=me (cef9dbdcd)
- Bug 1135563 - Fix several javascript warnings for xpcshell app update tests and cleanup style. r=spohl (6330eb78c)
- Bug 1123019 - In DrawTargetTiled::StrokeRect and StrokeLine, skip tiles that don't intersect the stroke. r=jrmuizel (71afc7653)
- Bug 1123019 - Shrink clipped stroked rectangles and stroked lines. r=jrmuizel (17e93d70f)
- Bug 1123019 - Actually use the clipped rect variable. r=jrmuizel (29c96ab43)
2019-09-04 21:12:58 +08:00

198 lines
5.2 KiB
C++

/* -*- 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 "PaintedLayerComposite.h"
#include "CompositableHost.h" // for TiledLayerProperties, etc
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for CSSRect, LayerPixel, etc
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for Point
#include "mozilla/gfx/Rect.h" // for RoundedToInt, Rect
#include "mozilla/gfx/Types.h" // for Filter::Filter::LINEAR
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/ContentHost.h" // for ContentHost
#include "mozilla/layers/Effects.h" // for EffectChain
#include "mozilla/mozalloc.h" // for operator delete
#include "nsAString.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "nsMathUtils.h" // for NS_lround
#include "nsPoint.h" // for nsIntPoint
#include "nsRect.h" // for nsIntRect
#include "nsSize.h" // for nsIntSize
#include "nsString.h" // for nsAutoCString
#include "TextRenderer.h"
#include "GoannaProfiler.h"
namespace mozilla {
namespace layers {
class TiledLayerComposer;
PaintedLayerComposite::PaintedLayerComposite(LayerManagerComposite *aManager)
: PaintedLayer(aManager, nullptr)
, LayerComposite(aManager)
, mBuffer(nullptr)
{
MOZ_COUNT_CTOR(PaintedLayerComposite);
mImplData = static_cast<LayerComposite*>(this);
}
PaintedLayerComposite::~PaintedLayerComposite()
{
MOZ_COUNT_DTOR(PaintedLayerComposite);
CleanupResources();
}
bool
PaintedLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::CONTENT_TILED:
case CompositableType::CONTENT_SINGLE:
case CompositableType::CONTENT_DOUBLE:
mBuffer = static_cast<ContentHost*>(aHost);
return true;
default:
return false;
}
}
void
PaintedLayerComposite::Disconnect()
{
Destroy();
}
void
PaintedLayerComposite::Destroy()
{
if (!mDestroyed) {
CleanupResources();
mDestroyed = true;
}
}
Layer*
PaintedLayerComposite::GetLayer()
{
return this;
}
void
PaintedLayerComposite::SetLayerManager(LayerManagerComposite* aManager)
{
LayerComposite::SetLayerManager(aManager);
mManager = aManager;
if (mBuffer) {
mBuffer->SetCompositor(mCompositor);
}
}
TiledLayerComposer*
PaintedLayerComposite::GetTiledLayerComposer()
{
if (!mBuffer) {
return nullptr;
}
MOZ_ASSERT(mBuffer->IsAttached());
return mBuffer->AsTiledLayerComposer();
}
LayerRenderState
PaintedLayerComposite::GetRenderState()
{
if (!mBuffer || !mBuffer->IsAttached() || mDestroyed) {
return LayerRenderState();
}
return mBuffer->GetRenderState();
}
void
PaintedLayerComposite::RenderLayer(const nsIntRect& aClipRect)
{
if (!mBuffer || !mBuffer->IsAttached()) {
return;
}
PROFILER_LABEL("PaintedLayerComposite", "RenderLayer",
js::ProfileEntry::Category::GRAPHICS);
MOZ_ASSERT(mBuffer->GetCompositor() == mCompositeManager->GetCompositor() &&
mBuffer->GetLayer() == this,
"buffer is corrupted");
const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
RefPtr<gfx::DataSourceSurface> surf = mBuffer->GetAsSurface();
if (surf) {
WriteSnapshotToDumpFile(this, surf);
}
}
#endif
EffectChain effectChain(this);
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
AddBlendModeEffect(effectChain);
mBuffer->SetPaintWillResample(MayResample());
mBuffer->Composite(effectChain,
GetEffectiveOpacity(),
GetEffectiveTransform(),
GetEffectFilter(),
clipRect,
&visibleRegion);
mBuffer->BumpFlashCounter();
mCompositeManager->GetCompositor()->MakeCurrent();
}
CompositableHost*
PaintedLayerComposite::GetCompositableHost()
{
if (mBuffer && mBuffer->IsAttached()) {
return mBuffer.get();
}
return nullptr;
}
void
PaintedLayerComposite::CleanupResources()
{
if (mBuffer) {
mBuffer->Detach(this);
}
mBuffer = nullptr;
}
void
PaintedLayerComposite::GenEffectChain(EffectChain& aEffect)
{
aEffect.mLayerRef = this;
aEffect.mPrimaryEffect = mBuffer->GenEffect(GetEffectFilter());
}
void
PaintedLayerComposite::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
PaintedLayer::PrintInfo(aStream, aPrefix);
if (mBuffer && mBuffer->IsAttached()) {
aStream << "\n";
nsAutoCString pfx(aPrefix);
pfx += " ";
mBuffer->PrintInfo(aStream, pfx.get());
}
}
} /* layers */
} /* mozilla */