зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1478815 part 1 - Add a PadEdges operation to DrawTarget. r=bas
This commit adds an operation to perform 'edge padding' on a draw target. By default this is performed using LockBits, but it's overriden in DrawTargetTiled and DrawTargetCapture to propagate the call so it functions correctly. This helps TiledContentClient move from applying this operation on a per texture client basis, to being able to do it on the DrawTargetTiled after painting. This in turn helps move all paint thread operations into DrawTargetCapture. MozReview-Commit-ID: 2ncOTxGXQfk --HG-- rename : gfx/layers/BufferEdgePad.cpp => gfx/2d/BufferEdgePad.cpp rename : gfx/layers/BufferEdgePad.h => gfx/2d/BufferEdgePad.h extra : rebase_source : a3315644fe31f2a432935dcbfdb9969c58b691e1 extra : source : 699c954992f87db7fc792f5562090de42a8162cb
This commit is contained in:
Родитель
9271849643
Коммит
53537230f9
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "nsRegionFwd.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK)
|
||||
#ifndef MOZ_ENABLE_FREETYPE
|
||||
#define MOZ_ENABLE_FREETYPE
|
||||
|
@ -1296,6 +1298,11 @@ public:
|
|||
*/
|
||||
virtual void Blur(const AlphaBoxBlur& aBlur);
|
||||
|
||||
/**
|
||||
* Performs an in-place edge padding operation.
|
||||
*/
|
||||
virtual void PadEdges(const IntRegion& aRegion);
|
||||
|
||||
/**
|
||||
* Create a SourceSurface optimized for use with this DrawTarget from
|
||||
* existing bitmap data in memory.
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "BufferEdgePad.h"
|
||||
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "2D.h" // for DrawTarget
|
||||
#include "Point.h" // for IntSize
|
||||
#include "Types.h" // for SurfaceFormat
|
||||
|
||||
#include "nsRegion.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace gfx;
|
||||
namespace gfx {
|
||||
|
||||
void
|
||||
PadDrawTargetOutFromRegion(RefPtr<DrawTarget> aDrawTarget, nsIntRegion &aRegion)
|
||||
PadDrawTargetOutFromRegion(DrawTarget* aDrawTarget, const nsIntRegion &aRegion)
|
||||
{
|
||||
struct LockedBits {
|
||||
uint8_t *data;
|
||||
|
@ -89,5 +96,5 @@ PadDrawTargetOutFromRegion(RefPtr<DrawTarget> aDrawTarget, nsIntRegion &aRegion)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
|
@ -4,18 +4,19 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef MOZILLA_LAYERS_BUFFER_EDGE_PAD_H
|
||||
#define MOZILLA_LAYERS_BUFFER_EDGE_PAD_H
|
||||
#ifndef MOZILLA_GFX_BUFFER_EDGE_PAD_H
|
||||
#define MOZILLA_GFX_BUFFER_EDGE_PAD_H
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsRegionFwd.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
namespace gfx {
|
||||
|
||||
void PadDrawTargetOutFromRegion(RefPtr<gfx::DrawTarget> aDrawTarget, nsIntRegion &aRegion);
|
||||
class DrawTarget;
|
||||
|
||||
void PadDrawTargetOutFromRegion(DrawTarget* aDrawTarget, const nsIntRegion &aRegion);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_LAYERS_BUFFER_EDGE_PAD_H
|
||||
#endif // MOZILLA_GFX_BUFFER_EDGE_PAD_H
|
|
@ -45,7 +45,8 @@ enum class CommandType : int8_t {
|
|||
SETTRANSFORM,
|
||||
SETPERMITSUBPIXELAA,
|
||||
FLUSH,
|
||||
BLUR
|
||||
BLUR,
|
||||
PADEDGES,
|
||||
};
|
||||
|
||||
class DrawingCommand
|
||||
|
|
|
@ -1126,6 +1126,40 @@ private:
|
|||
AlphaBoxBlur mBlur;
|
||||
};
|
||||
|
||||
class PadEdgesCommand : public DrawingCommand
|
||||
{
|
||||
public:
|
||||
explicit PadEdgesCommand(const IntRegion& aRegion)
|
||||
: mRegion(aRegion)
|
||||
{}
|
||||
|
||||
CommandType GetType() const override
|
||||
{
|
||||
return PadEdgesCommand::Type;
|
||||
}
|
||||
|
||||
void CloneInto(CaptureCommandList* aList) override
|
||||
{
|
||||
CLONE_INTO(PadEdgesCommand)(IntRegion(mRegion));
|
||||
}
|
||||
|
||||
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
|
||||
{
|
||||
aDT->PadEdges(mRegion);
|
||||
}
|
||||
|
||||
void Log(TreeLog& aStream) const override
|
||||
{
|
||||
aStream << "[PADEDGES]";
|
||||
}
|
||||
|
||||
static const bool AffectsSnapshot = true;
|
||||
static const CommandType Type = CommandType::PADEDGES;
|
||||
|
||||
private:
|
||||
IntRegion mRegion;
|
||||
};
|
||||
|
||||
#undef CLONE_INTO
|
||||
|
||||
} // namespace gfx
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "DrawTargetCapture.h"
|
||||
|
||||
#include "BufferEdgePad.h"
|
||||
|
||||
#ifdef BUILD_ARM_NEON
|
||||
#include "mozilla/arm.h"
|
||||
#include "LuminanceNEON.h"
|
||||
|
@ -288,5 +290,11 @@ DrawTarget::Blur(const AlphaBoxBlur& aBlur)
|
|||
ReleaseBits(data);
|
||||
}
|
||||
|
||||
void
|
||||
DrawTarget::PadEdges(const IntRegion& aRegion)
|
||||
{
|
||||
PadDrawTargetOutFromRegion(this, aRegion);
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -343,6 +343,12 @@ DrawTargetCaptureImpl::Blur(const AlphaBoxBlur& aBlur)
|
|||
AppendCommand(BlurCommand)(aBlur);
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetCaptureImpl::PadEdges(const IntRegion& aRegion)
|
||||
{
|
||||
AppendCommand(PadEdgesCommand)(aRegion);
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetCaptureImpl::ReplayToDrawTarget(DrawTarget* aDT, const Matrix& aTransform)
|
||||
{
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
bool aCopyBackground) override;
|
||||
virtual void PopLayer() override;
|
||||
virtual void Blur(const AlphaBoxBlur& aBlur) override;
|
||||
virtual void PadEdges(const IntRegion& aRegion) override;
|
||||
|
||||
virtual void SetTransform(const Matrix &aTransform) override;
|
||||
|
||||
|
|
|
@ -387,5 +387,28 @@ DrawTargetTiled::PopLayer()
|
|||
mPushedLayers.pop_back();
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetTiled::PadEdges(const IntRegion& aRegion)
|
||||
{
|
||||
for (size_t i = 0; i < mTiles.size(); i++) {
|
||||
if (mTiles[i].mClippedOut) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto tileRect = RoundedOut(Rect(mTiles[i].mTileOrigin.x,
|
||||
mTiles[i].mTileOrigin.y,
|
||||
mTiles[i].mDrawTarget->GetSize().width,
|
||||
mTiles[i].mDrawTarget->GetSize().height));
|
||||
|
||||
// We only need to pad edges on tiles that intersect the edge of the region
|
||||
if (aRegion.Intersects(tileRect) && !aRegion.Contains(tileRect)) {
|
||||
IntRegion padRegion = aRegion;
|
||||
padRegion.MoveBy(-mTiles[i].mTileOrigin);
|
||||
padRegion.AndWith(IntRect(0, 0, mTiles[i].mDrawTarget->GetSize().width, mTiles[i].mDrawTarget->GetSize().height));
|
||||
mTiles[i].mDrawTarget->PadEdges(padRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
CompositionOp = CompositionOp::OP_OVER) override;
|
||||
virtual void PopLayer() override;
|
||||
|
||||
virtual void PadEdges(const IntRegion& aRegion) override;
|
||||
|
||||
virtual void SetTransform(const Matrix &aTransform) override;
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ elif CONFIG['CPU_ARCH'].startswith('mips'):
|
|||
UNIFIED_SOURCES += [
|
||||
'BezierUtils.cpp',
|
||||
'Blur.cpp',
|
||||
'BufferEdgePad.cpp',
|
||||
'CaptureCommandList.cpp',
|
||||
'DataSourceSurface.cpp',
|
||||
'DataSurfaceHelpers.cpp',
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "gfxPlatform.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/layers/BufferEdgePad.h"
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/layers/SyncObject.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "base/process_util.h"
|
||||
#include "chrome/common/mach_ipc_mac.h"
|
||||
#include "mozilla/ipc/SharedMemoryBasic.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
@ -211,7 +212,7 @@ TextureSync::Shutdown()
|
|||
void
|
||||
TextureSync::UpdateTextureLocks(base::ProcessId aProcessId)
|
||||
{
|
||||
if (aProcessId == getpid()) {
|
||||
if (aProcessId == base::GetCurrentProcId()) {
|
||||
DispatchCheckTexturesForUnlock();
|
||||
return;
|
||||
}
|
||||
|
@ -224,7 +225,7 @@ TextureSync::UpdateTextureLocks(base::ProcessId aProcessId)
|
|||
bool
|
||||
TextureSync::WaitForTextures(base::ProcessId aProcessId, const nsTArray<uint64_t>& textureIds)
|
||||
{
|
||||
if (aProcessId == getpid()) {
|
||||
if (aProcessId == base::GetCurrentProcId()) {
|
||||
bool success = WaitForTextureIdsToUnlock(aProcessId, MakeSpan<uint64_t>(textureIds));
|
||||
if (!success) {
|
||||
LOG_ERROR("Failed waiting for textures to unlock.\n");
|
||||
|
@ -243,7 +244,7 @@ TextureSync::WaitForTextures(base::ProcessId aProcessId, const nsTArray<uint64_t
|
|||
reqTextureIds[i] = textureIds[i];
|
||||
}
|
||||
|
||||
req->pid = getpid();
|
||||
req->pid = base::GetCurrentProcId();
|
||||
bool dataWasSet = smsg.SetData(req, messageSize);
|
||||
|
||||
if (!dataWasSet) {
|
||||
|
|
|
@ -125,7 +125,6 @@ EXPORTS.mozilla.layers += [
|
|||
'basic/MacIOSurfaceTextureHostBasic.h',
|
||||
'basic/TextureHostBasic.h',
|
||||
'BSPTree.h',
|
||||
'BufferEdgePad.h',
|
||||
'BufferTexture.h',
|
||||
'CanvasRenderer.h',
|
||||
'client/CanvasClient.h',
|
||||
|
@ -354,7 +353,6 @@ UNIFIED_SOURCES += [
|
|||
'basic/BasicPaintedLayer.cpp',
|
||||
'basic/TextureHostBasic.cpp',
|
||||
'BSPTree.cpp',
|
||||
'BufferEdgePad.cpp',
|
||||
'BufferTexture.cpp',
|
||||
'BufferUnrotate.cpp',
|
||||
'CanvasRenderer.cpp',
|
||||
|
|
|
@ -289,7 +289,7 @@ void nsRegion::SimplifyOutwardByArea(uint32_t aThreshold)
|
|||
|
||||
typedef void (*visit_fn)(void *closure, VisitSide side, int x1, int y1, int x2, int y2);
|
||||
|
||||
void nsRegion::VisitEdges (visit_fn visit, void *closure)
|
||||
void nsRegion::VisitEdges (visit_fn visit, void *closure) const
|
||||
{
|
||||
if (mBands.IsEmpty()) {
|
||||
visit(closure, VisitSide::LEFT, mBounds.X(), mBounds.Y(), mBounds.X(), mBounds.YMost());
|
||||
|
@ -310,7 +310,7 @@ void nsRegion::VisitEdges (visit_fn visit, void *closure)
|
|||
|
||||
if (band != bandFinal) {
|
||||
do {
|
||||
Band& topBand = *band;
|
||||
const Band& topBand = *band;
|
||||
band++;
|
||||
|
||||
for (const Strip& strip : band->mStrips) {
|
||||
|
@ -320,7 +320,7 @@ void nsRegion::VisitEdges (visit_fn visit, void *closure)
|
|||
|
||||
if (band->top == topBand.bottom) {
|
||||
// Two bands touching each other vertically.
|
||||
Band& bottomBand = *band;
|
||||
const Band& bottomBand = *band;
|
||||
auto topStrip = std::begin(topBand.mStrips);
|
||||
auto bottomStrip = std::begin(bottomBand.mStrips);
|
||||
|
||||
|
|
|
@ -1949,7 +1949,7 @@ public:
|
|||
* are the coordinates of the line. (x1 == x2) || (y1 == y2)
|
||||
*/
|
||||
typedef void(*visitFn)(void *closure, VisitSide side, int x1, int y1, int x2, int y2);
|
||||
void VisitEdges(visitFn, void *closure);
|
||||
void VisitEdges(visitFn, void *closure) const;
|
||||
|
||||
nsCString ToString() const;
|
||||
|
||||
|
@ -2564,7 +2564,7 @@ public:
|
|||
}
|
||||
|
||||
typedef void (*visitFn)(void *closure, VisitSide side, int x1, int y1, int x2, int y2);
|
||||
void VisitEdges (visitFn visit, void *closure)
|
||||
void VisitEdges (visitFn visit, void *closure) const
|
||||
{
|
||||
mImpl.VisitEdges (visit, closure);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче