2017-10-28 02:10:06 +03:00
|
|
|
/* -*- 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
|
2014-08-01 20:01:47 +04:00
|
|
|
* 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 "DrawTargetCapture.h"
|
|
|
|
#include "DrawCommand.h"
|
2018-02-02 18:59:35 +03:00
|
|
|
#include "DrawCommands.h"
|
2017-07-27 01:43:00 +03:00
|
|
|
#include "gfxPlatform.h"
|
2017-10-31 22:02:31 +03:00
|
|
|
#include "SourceSurfaceCapture.h"
|
2017-12-07 05:21:49 +03:00
|
|
|
#include "FilterNodeCapture.h"
|
2014-08-01 20:01:47 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
|
|
|
|
DrawTargetCaptureImpl::~DrawTargetCaptureImpl()
|
|
|
|
{
|
2017-10-31 22:02:31 +03:00
|
|
|
if (mSnapshot && !mSnapshot->hasOneRef()) {
|
|
|
|
mSnapshot->DrawTargetWillDestroy();
|
|
|
|
mSnapshot = nullptr;
|
|
|
|
}
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2018-07-27 00:33:07 +03:00
|
|
|
DrawTargetCaptureImpl::DrawTargetCaptureImpl(gfx::DrawTarget* aTarget, size_t aFlushBytes)
|
|
|
|
: mSnapshot(nullptr),
|
|
|
|
mStride(0),
|
|
|
|
mSurfaceAllocationSize(0),
|
|
|
|
mFlushBytes(aFlushBytes)
|
|
|
|
{
|
|
|
|
mSize = aTarget->GetSize();
|
|
|
|
mFormat = aTarget->GetFormat();
|
|
|
|
SetPermitSubpixelAA(aTarget->GetPermitSubpixelAA());
|
|
|
|
|
|
|
|
mRefDT = aTarget;
|
|
|
|
}
|
|
|
|
|
2017-07-27 01:43:00 +03:00
|
|
|
DrawTargetCaptureImpl::DrawTargetCaptureImpl(BackendType aBackend,
|
|
|
|
const IntSize& aSize,
|
|
|
|
SurfaceFormat aFormat)
|
2017-10-31 22:02:29 +03:00
|
|
|
: mSize(aSize),
|
2017-10-31 22:02:31 +03:00
|
|
|
mSnapshot(nullptr),
|
2017-10-31 22:02:29 +03:00
|
|
|
mStride(0),
|
2018-07-27 00:33:07 +03:00
|
|
|
mSurfaceAllocationSize(0),
|
|
|
|
mFlushBytes(0)
|
2017-07-27 01:43:00 +03:00
|
|
|
{
|
|
|
|
RefPtr<DrawTarget> screenRefDT =
|
|
|
|
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
|
|
|
|
2017-08-14 23:52:11 +03:00
|
|
|
mFormat = aFormat;
|
2017-11-30 00:58:43 +03:00
|
|
|
SetPermitSubpixelAA(IsOpaque(mFormat));
|
2017-07-27 01:43:00 +03:00
|
|
|
if (aBackend == screenRefDT->GetBackendType()) {
|
|
|
|
mRefDT = screenRefDT;
|
|
|
|
} else {
|
2017-10-31 22:02:29 +03:00
|
|
|
// This situation can happen if a blur operation decides to
|
|
|
|
// use an unaccelerated path even if the system backend is
|
|
|
|
// Direct2D.
|
|
|
|
//
|
|
|
|
// We don't really want to encounter the reverse scenario:
|
|
|
|
// we shouldn't pick an accelerated backend if the system
|
|
|
|
// backend is skia.
|
|
|
|
if (aBackend == BackendType::DIRECT2D1_1) {
|
|
|
|
gfxWarning() << "Creating a RefDT in DrawTargetCapture.";
|
|
|
|
}
|
2017-07-27 01:43:00 +03:00
|
|
|
|
|
|
|
// Create a 1x1 size ref dt to create assets
|
|
|
|
// If we have to snapshot, we'll just create the real DT
|
|
|
|
IntSize size(1, 1);
|
|
|
|
mRefDT = Factory::CreateDrawTarget(aBackend, size, mFormat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
bool
|
|
|
|
DrawTargetCaptureImpl::Init(const IntSize& aSize, DrawTarget* aRefDT)
|
|
|
|
{
|
|
|
|
if (!aRefDT) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mRefDT = aRefDT;
|
|
|
|
|
|
|
|
mSize = aSize;
|
2017-07-14 20:55:03 +03:00
|
|
|
mFormat = aRefDT->GetFormat();
|
2017-11-30 00:58:43 +03:00
|
|
|
SetPermitSubpixelAA(IsOpaque(mFormat));
|
2014-08-01 20:01:47 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:29 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::InitForData(int32_t aStride, size_t aSurfaceAllocationSize)
|
|
|
|
{
|
2018-07-27 00:33:07 +03:00
|
|
|
MOZ_ASSERT(!mFlushBytes);
|
2017-10-31 22:02:29 +03:00
|
|
|
mStride = aStride;
|
|
|
|
mSurfaceAllocationSize = aSurfaceAllocationSize;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<SourceSurface>
|
2014-08-01 20:01:47 +04:00
|
|
|
DrawTargetCaptureImpl::Snapshot()
|
|
|
|
{
|
2017-10-31 22:02:31 +03:00
|
|
|
if (!mSnapshot) {
|
|
|
|
mSnapshot = new SourceSurfaceCapture(this);
|
2017-10-31 22:02:29 +03:00
|
|
|
}
|
2014-08-01 20:01:47 +04:00
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
RefPtr<SourceSurface> surface = mSnapshot;
|
|
|
|
return surface.forget();
|
|
|
|
}
|
2014-08-01 20:01:47 +04:00
|
|
|
|
2017-11-21 18:41:08 +03:00
|
|
|
already_AddRefed<SourceSurface>
|
|
|
|
DrawTargetCaptureImpl::IntoLuminanceSource(LuminanceType aLuminanceType,
|
|
|
|
float aOpacity)
|
|
|
|
{
|
|
|
|
RefPtr<SourceSurface> surface = new SourceSurfaceCapture(this, aLuminanceType, aOpacity);
|
|
|
|
return surface.forget();
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
already_AddRefed<SourceSurface>
|
|
|
|
DrawTargetCaptureImpl::OptimizeSourceSurface(SourceSurface *aSurface) const
|
|
|
|
{
|
|
|
|
// If the surface is a recording, make sure it gets resolved on the paint thread.
|
|
|
|
if (aSurface->GetType() == SurfaceType::CAPTURE) {
|
|
|
|
RefPtr<SourceSurface> surface = aSurface;
|
|
|
|
return surface.forget();
|
|
|
|
}
|
|
|
|
return mRefDT->OptimizeSourceSurface(aSurface);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2016-07-01 11:58:13 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::DetachAllSnapshots()
|
2017-10-31 22:02:31 +03:00
|
|
|
{
|
|
|
|
MarkChanged();
|
|
|
|
}
|
2016-07-01 11:58:13 +03:00
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
#define AppendCommand(arg) new (AppendToCommandList<arg>()) arg
|
2018-02-02 18:59:35 +03:00
|
|
|
#define ReuseOrAppendCommand(arg) new (ReuseOrAppendToCommandList<arg>()) arg
|
2014-08-01 20:01:47 +04:00
|
|
|
|
2017-09-13 22:15:16 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::SetPermitSubpixelAA(bool aPermitSubpixelAA)
|
|
|
|
{
|
2018-02-02 18:24:10 +03:00
|
|
|
// Save memory by eliminating state changes with no effect
|
|
|
|
if (mPermitSubpixelAA == aPermitSubpixelAA) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-02 18:59:35 +03:00
|
|
|
ReuseOrAppendCommand(SetPermitSubpixelAACommand)(aPermitSubpixelAA);
|
2017-09-13 22:15:16 +03:00
|
|
|
|
|
|
|
// Have to update mPermitSubpixelAA for this DT
|
|
|
|
// because some code paths query the current setting
|
|
|
|
// to determine subpixel AA eligibility.
|
|
|
|
DrawTarget::SetPermitSubpixelAA(aPermitSubpixelAA);
|
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::DrawSurface(SourceSurface *aSurface,
|
|
|
|
const Rect &aDest,
|
|
|
|
const Rect &aSource,
|
|
|
|
const DrawSurfaceOptions &aSurfOptions,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
aSurface->GuaranteePersistance();
|
|
|
|
AppendCommand(DrawSurfaceCommand)(aSurface, aDest, aSource, aSurfOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
|
|
|
const Point &aDest,
|
|
|
|
const Color &aColor,
|
|
|
|
const Point &aOffset,
|
|
|
|
Float aSigma,
|
|
|
|
CompositionOp aOperator)
|
|
|
|
{
|
|
|
|
aSurface->GuaranteePersistance();
|
|
|
|
AppendCommand(DrawSurfaceWithShadowCommand)(aSurface, aDest, aColor, aOffset, aSigma, aOperator);
|
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::DrawFilter(FilterNode *aNode,
|
|
|
|
const Rect &aSourceRect,
|
|
|
|
const Point &aDestPoint,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
// @todo XXX - this won't work properly long term yet due to filternodes not
|
|
|
|
// being immutable.
|
|
|
|
AppendCommand(DrawFilterCommand)(aNode, aSourceRect, aDestPoint, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::ClearRect(const Rect &aRect)
|
|
|
|
{
|
|
|
|
AppendCommand(ClearRectCommand)(aRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::MaskSurface(const Pattern &aSource,
|
|
|
|
SourceSurface *aMask,
|
|
|
|
Point aOffset,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
aMask->GuaranteePersistance();
|
|
|
|
AppendCommand(MaskSurfaceCommand)(aSource, aMask, aOffset, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::CopySurface(SourceSurface* aSurface,
|
|
|
|
const IntRect& aSourceRect,
|
|
|
|
const IntPoint& aDestination)
|
|
|
|
{
|
|
|
|
aSurface->GuaranteePersistance();
|
|
|
|
AppendCommand(CopySurfaceCommand)(aSurface, aSourceRect, aDestination);
|
Bug 1478815 part 8 - Remove buffer operations for ContentClient. r=nical
This commit moves ContentClient from creating a CapturedBufferState for
buffer operations, to performing all of those operations on the
DrawTarget(Capture). Creating a DrawTargetCapture is now performed
by the RotatedBuffer when we BeginPaint, all operations are performed
on this capture, and then it's returned to the ClientPaintedLayer
as a PaintTask.
This commit is an involved refactoring of ContentClient and RotatedBuffer
to get this all to work. Here are the major parts:
1. RotatedBuffer is refactored to always perform operations on a single
DrawTarget, which may be a single DT, dual DT, or capture.
2. RotatedBuffer adds BeginCapture and EndCapture methods to switch
which DT is used in operations
3. ContentClient uses the RB capture methods when we are async painting
4. CC::BeginPaint is refactored to only perform capturing on a single
RotatedBuffer. This is because we can't have the output of one
PaintTask be the input of a different PaintTask due to the design
of the Snapshot API.
a. This can occur, today, by doing a FinalizeFrame only to later
fail to Unrotate the buffer, causing a new RB to be created
and painted into
b. The previous PaintThread code worked because it used the
buffer operations which didn't use Snapshot's
c. This is fixed by not doing FinalizeFrame on a buffer if we
realize we cannot unrotate it, and switching to initializing
a buffer using the front buffer which should be up to date.
d. I don't like touching this code, but it passes reftests,
might be a performance improvement, and I've tested it on
known regressions from the last time I messed up this code.
5. CC::PrepareForPaint is inlined into BeginPaint because dual draw
targets can be cleared correctly from a previous commit
6. The code paths in ClientPaintedLayer are unified because we no
longer need to special case this beyond setting the correct
ContentClient flag.
7. CapturedPaintState and CapturedBufferState are removed in favor
of PaintTask. Additionally EndLayer is no longer needed as all
quadrants of a rotated buffer are in the same capture, so we
don't need special case flushing code.
MozReview-Commit-ID: 9UI40dwran
--HG--
extra : rebase_source : 809d9816970648468de972c30b0c230c2f21e27b
extra : source : 405ad351821813333c0e989b93e2aeb49ba8552c
2018-07-26 19:23:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::CopyRect(const IntRect &aSourceRect,
|
|
|
|
const IntPoint &aDestination)
|
|
|
|
{
|
|
|
|
AppendCommand(CopyRectCommand)(aSourceRect, aDestination);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::FillRect(const Rect& aRect,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(FillRectCommand)(aRect, aPattern, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::StrokeRect(const Rect& aRect,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(StrokeRectCommand)(aRect, aPattern, aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::StrokeLine(const Point& aStart,
|
|
|
|
const Point& aEnd,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(StrokeLineCommand)(aStart, aEnd, aPattern, aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::Stroke(const Path* aPath,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(StrokeCommand)(aPath, aPattern, aStrokeOptions, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::Fill(const Path* aPath,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(FillCommand)(aPath, aPattern, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::FillGlyphs(ScaledFont* aFont,
|
|
|
|
const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions)
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
2017-11-03 04:42:56 +03:00
|
|
|
AppendCommand(FillGlyphsCommand)(aFont, aBuffer, aPattern, aOptions);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2017-07-15 03:48:00 +03:00
|
|
|
void DrawTargetCaptureImpl::StrokeGlyphs(ScaledFont* aFont,
|
|
|
|
const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions)
|
2017-07-15 03:48:00 +03:00
|
|
|
{
|
2017-11-03 04:42:56 +03:00
|
|
|
AppendCommand(StrokeGlyphsCommand)(aFont, aBuffer, aPattern, aStrokeOptions, aOptions);
|
2017-07-15 03:48:00 +03:00
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::Mask(const Pattern &aSource,
|
|
|
|
const Pattern &aMask,
|
|
|
|
const DrawOptions &aOptions)
|
|
|
|
{
|
|
|
|
AppendCommand(MaskCommand)(aSource, aMask, aOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PushClip(const Path* aPath)
|
|
|
|
{
|
|
|
|
AppendCommand(PushClipCommand)(aPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PushClipRect(const Rect& aRect)
|
|
|
|
{
|
|
|
|
AppendCommand(PushClipRectCommand)(aRect);
|
|
|
|
}
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PushLayer(bool aOpaque,
|
|
|
|
Float aOpacity,
|
|
|
|
SourceSurface* aMask,
|
|
|
|
const Matrix& aMaskTransform,
|
|
|
|
const IntRect& aBounds,
|
|
|
|
bool aCopyBackground)
|
|
|
|
{
|
2017-09-20 20:23:01 +03:00
|
|
|
// Have to update mPermitSubpixelAA for this DT
|
|
|
|
// because some code paths query the current setting
|
|
|
|
// to determine subpixel AA eligibility.
|
|
|
|
PushedLayer layer(GetPermitSubpixelAA());
|
|
|
|
mPushedLayers.push_back(layer);
|
|
|
|
DrawTarget::SetPermitSubpixelAA(aOpaque);
|
|
|
|
|
2018-03-19 21:32:12 +03:00
|
|
|
if (aMask) {
|
|
|
|
aMask->GuaranteePersistance();
|
|
|
|
}
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
AppendCommand(PushLayerCommand)(aOpaque,
|
|
|
|
aOpacity,
|
|
|
|
aMask,
|
|
|
|
aMaskTransform,
|
|
|
|
aBounds,
|
|
|
|
aCopyBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PopLayer()
|
|
|
|
{
|
2017-09-20 20:23:01 +03:00
|
|
|
MOZ_ASSERT(mPushedLayers.size());
|
|
|
|
DrawTarget::SetPermitSubpixelAA(mPushedLayers.back().mOldPermitSubpixelAA);
|
|
|
|
mPushedLayers.pop_back();
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
AppendCommand(PopLayerCommand)();
|
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PopClip()
|
|
|
|
{
|
|
|
|
AppendCommand(PopClipCommand)();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::SetTransform(const Matrix& aTransform)
|
|
|
|
{
|
2018-02-02 18:24:10 +03:00
|
|
|
// Save memory by eliminating state changes with no effect
|
|
|
|
if (mTransform.ExactlyEquals(aTransform)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-02 18:59:35 +03:00
|
|
|
ReuseOrAppendCommand(SetTransformCommand)(aTransform);
|
2017-06-29 01:22:59 +03:00
|
|
|
|
|
|
|
// Have to update the transform for this DT
|
|
|
|
// because some code paths query the current transform
|
|
|
|
// to render specific things.
|
|
|
|
DrawTarget::SetTransform(aTransform);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:30 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::Blur(const AlphaBoxBlur& aBlur)
|
|
|
|
{
|
|
|
|
// gfxAlphaBoxBlur should not use this if it takes the accelerated path.
|
|
|
|
MOZ_ASSERT(GetBackendType() == BackendType::SKIA);
|
|
|
|
|
|
|
|
AppendCommand(BlurCommand)(aBlur);
|
|
|
|
}
|
|
|
|
|
2018-08-01 20:44:33 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::PadEdges(const IntRegion& aRegion)
|
|
|
|
{
|
|
|
|
AppendCommand(PadEdgesCommand)(aRegion);
|
|
|
|
}
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::ReplayToDrawTarget(DrawTarget* aDT, const Matrix& aTransform)
|
|
|
|
{
|
2017-10-31 22:02:30 +03:00
|
|
|
for (CaptureCommandList::iterator iter(mCommands); !iter.Done(); iter.Next()) {
|
|
|
|
DrawingCommand* cmd = iter.Get();
|
|
|
|
cmd->ExecuteOnDT(aDT, &aTransform);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::MarkChanged()
|
|
|
|
{
|
|
|
|
if (!mSnapshot) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mSnapshot->hasOneRef()) {
|
|
|
|
mSnapshot = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSnapshot->DrawTargetWillChange();
|
|
|
|
mSnapshot = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:32 +03:00
|
|
|
already_AddRefed<DrawTarget>
|
|
|
|
DrawTargetCaptureImpl::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
|
|
|
|
{
|
|
|
|
return MakeAndAddRef<DrawTargetCaptureImpl>(GetBackendType(), aSize, aFormat);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:32 +03:00
|
|
|
RefPtr<DrawTarget>
|
|
|
|
DrawTargetCaptureImpl::CreateSimilarRasterTarget(const IntSize& aSize, SurfaceFormat aFormat) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mRefDT->IsCaptureDT());
|
|
|
|
return mRefDT->CreateSimilarDrawTarget(aSize, aFormat);
|
|
|
|
}
|
|
|
|
|
2017-12-07 05:21:49 +03:00
|
|
|
already_AddRefed<FilterNode>
|
|
|
|
DrawTargetCaptureImpl::CreateFilter(FilterType aType)
|
|
|
|
{
|
|
|
|
if (mRefDT->GetBackendType() == BackendType::DIRECT2D1_1) {
|
|
|
|
return MakeRefPtr<FilterNodeCapture>(aType).forget();
|
|
|
|
} else {
|
|
|
|
return mRefDT->CreateFilter(aType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-01 01:47:51 +03:00
|
|
|
bool
|
|
|
|
DrawTargetCaptureImpl::IsEmpty() const
|
|
|
|
{
|
|
|
|
return mCommands.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2018-02-06 07:00:45 +03:00
|
|
|
void
|
|
|
|
DrawTargetCaptureImpl::Dump()
|
|
|
|
{
|
|
|
|
TreeLog output;
|
|
|
|
output << "DrawTargetCapture(" << (void*)(this) << ")\n";
|
|
|
|
TreeAutoIndent indent(output);
|
|
|
|
mCommands.Log(output);
|
|
|
|
output << "\n";
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|