Bug 1381973 - Lazily create the reference DT in DrawTargetCapture. r=dvander
This commit is contained in:
18
gfx/2d/2D.h
18
gfx/2d/2D.h
@@ -1231,14 +1231,6 @@ public:
|
|||||||
virtual already_AddRefed<DrawTarget>
|
virtual already_AddRefed<DrawTarget>
|
||||||
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const = 0;
|
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a DrawTarget that captures the drawing commands and can be replayed
|
|
||||||
* onto a compatible DrawTarget afterwards.
|
|
||||||
*
|
|
||||||
* @param aSize Size of the area this DT will capture.
|
|
||||||
*/
|
|
||||||
virtual already_AddRefed<DrawTargetCapture> CreateCaptureDT(const IntSize& aSize);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a draw target optimized for drawing a shadow.
|
* Create a draw target optimized for drawing a shadow.
|
||||||
*
|
*
|
||||||
@@ -1497,6 +1489,16 @@ public:
|
|||||||
static already_AddRefed<DrawTarget>
|
static already_AddRefed<DrawTarget>
|
||||||
CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
|
CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DrawTarget that captures the drawing commands and can be replayed
|
||||||
|
* onto a compatible DrawTarget afterwards.
|
||||||
|
*
|
||||||
|
* @param aSize Size of the area this DT will capture.
|
||||||
|
*/
|
||||||
|
static already_AddRefed<DrawTargetCapture>
|
||||||
|
CreateCaptureDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
|
||||||
|
|
||||||
|
|
||||||
static already_AddRefed<DrawTarget>
|
static already_AddRefed<DrawTarget>
|
||||||
CreateWrapAndRecordDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT);
|
CreateWrapAndRecordDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT);
|
||||||
|
|
||||||
|
|||||||
@@ -175,19 +175,6 @@ ComputeLinearRGBLuminanceMask(const uint8_t *aSourceData,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<DrawTargetCapture>
|
|
||||||
DrawTarget::CreateCaptureDT(const IntSize& aSize)
|
|
||||||
{
|
|
||||||
RefPtr<DrawTargetCaptureImpl> dt = new DrawTargetCaptureImpl();
|
|
||||||
|
|
||||||
if (!dt->Init(aSize, this)) {
|
|
||||||
gfxWarning() << "Failed to initialize Capture DrawTarget!";
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dt.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DrawTarget::DrawCapturedDT(DrawTargetCapture *aCaptureDT,
|
DrawTarget::DrawCapturedDT(DrawTargetCapture *aCaptureDT,
|
||||||
const Matrix& aTransform)
|
const Matrix& aTransform)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "DrawTargetCapture.h"
|
#include "DrawTargetCapture.h"
|
||||||
#include "DrawCommand.h"
|
#include "DrawCommand.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
@@ -22,6 +23,31 @@ DrawTargetCaptureImpl::~DrawTargetCaptureImpl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawTargetCaptureImpl::DrawTargetCaptureImpl(BackendType aBackend,
|
||||||
|
const IntSize& aSize,
|
||||||
|
SurfaceFormat aFormat)
|
||||||
|
: mSize(aSize)
|
||||||
|
{
|
||||||
|
RefPtr<DrawTarget> screenRefDT =
|
||||||
|
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||||
|
|
||||||
|
if (aBackend == screenRefDT->GetBackendType()) {
|
||||||
|
mRefDT = screenRefDT;
|
||||||
|
} else {
|
||||||
|
// If you got here, we have to create a new ref DT to create
|
||||||
|
// backend specific assets like paths / gradients. Try to
|
||||||
|
// create the same backend type as the screen ref dt.
|
||||||
|
gfxWarning() << "Creating a RefDT in DrawTargetCapture.";
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
mFormat = aFormat;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DrawTargetCaptureImpl::Init(const IntSize& aSize, DrawTarget* aRefDT)
|
DrawTargetCaptureImpl::Init(const IntSize& aSize, DrawTarget* aRefDT)
|
||||||
{
|
{
|
||||||
@@ -39,7 +65,7 @@ DrawTargetCaptureImpl::Init(const IntSize& aSize, DrawTarget* aRefDT)
|
|||||||
already_AddRefed<SourceSurface>
|
already_AddRefed<SourceSurface>
|
||||||
DrawTargetCaptureImpl::Snapshot()
|
DrawTargetCaptureImpl::Snapshot()
|
||||||
{
|
{
|
||||||
RefPtr<DrawTarget> dt = mRefDT->CreateSimilarDrawTarget(mSize, mRefDT->GetFormat());
|
RefPtr<DrawTarget> dt = mRefDT->CreateSimilarDrawTarget(mSize, mFormat);
|
||||||
|
|
||||||
ReplayToDrawTarget(dt, Matrix());
|
ReplayToDrawTarget(dt, Matrix());
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ class DrawingCommand;
|
|||||||
class DrawTargetCaptureImpl : public DrawTargetCapture
|
class DrawTargetCaptureImpl : public DrawTargetCapture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawTargetCaptureImpl()
|
DrawTargetCaptureImpl(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat);
|
||||||
{}
|
|
||||||
|
|
||||||
bool Init(const IntSize& aSize, DrawTarget* aRefDT);
|
bool Init(const IntSize& aSize, DrawTarget* aRefDT);
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ public:
|
|||||||
bool ContainsOnlyColoredGlyphs(RefPtr<ScaledFont>& aScaledFont, Color& aColor, std::vector<Glyph>& aGlyphs) override;
|
bool ContainsOnlyColoredGlyphs(RefPtr<ScaledFont>& aScaledFont, Color& aColor, std::vector<Glyph>& aGlyphs) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~DrawTargetCaptureImpl();
|
virtual ~DrawTargetCaptureImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -166,7 +165,6 @@ private:
|
|||||||
return reinterpret_cast<T*>(nextDrawLocation + sizeof(uint32_t));
|
return reinterpret_cast<T*>(nextDrawLocation + sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
RefPtr<DrawTarget> mRefDT;
|
RefPtr<DrawTarget> mRefDT;
|
||||||
|
|
||||||
IntSize mSize;
|
IntSize mSize;
|
||||||
|
|
||||||
std::vector<uint8_t> mDrawCommandStorage;
|
std::vector<uint8_t> mDrawCommandStorage;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* -*- 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
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "DrawTargetCapture.h"
|
||||||
#include "DrawTargetDual.h"
|
#include "DrawTargetDual.h"
|
||||||
#include "DrawTargetTiled.h"
|
#include "DrawTargetTiled.h"
|
||||||
#include "DrawTargetWrapAndRecord.h"
|
#include "DrawTargetWrapAndRecord.h"
|
||||||
@@ -418,6 +419,12 @@ Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT
|
|||||||
return MakeAndAddRef<DrawTargetRecording>(aRecorder, aDT, aSize);
|
return MakeAndAddRef<DrawTargetRecording>(aRecorder, aDT, aSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<DrawTargetCapture>
|
||||||
|
Factory::CreateCaptureDrawTarget(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
|
||||||
|
{
|
||||||
|
return MakeAndAddRef<DrawTargetCaptureImpl>(aBackend, aSize, aFormat);
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<DrawTarget>
|
already_AddRefed<DrawTarget>
|
||||||
Factory::CreateDrawTargetForData(BackendType aBackend,
|
Factory::CreateDrawTargetForData(BackendType aBackend,
|
||||||
unsigned char *aData,
|
unsigned char *aData,
|
||||||
|
|||||||
@@ -204,16 +204,14 @@ ClientPaintedLayer::PaintOffMainThread()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<DrawTarget> refDT =
|
|
||||||
Factory::CreateDrawTarget(gfxPlatform::GetPlatform()->GetDefaultContentBackend(),
|
|
||||||
target->GetSize(), target->GetFormat());
|
|
||||||
|
|
||||||
// We don't clear the rect here like WRPaintedBlobLayers do
|
// We don't clear the rect here like WRPaintedBlobLayers do
|
||||||
// because ContentClient already clears the surface for us during BeginPaint.
|
// because ContentClient already clears the surface for us during BeginPaint.
|
||||||
RefPtr<DrawTargetCapture> captureDT = refDT->CreateCaptureDT(target->GetSize());
|
RefPtr<DrawTargetCapture> captureDT =
|
||||||
|
Factory::CreateCaptureDrawTarget(target->GetBackendType(),
|
||||||
|
target->GetSize(),
|
||||||
|
target->GetFormat());
|
||||||
captureDT->SetTransform(target->GetTransform());
|
captureDT->SetTransform(target->GetTransform());
|
||||||
|
|
||||||
SetAntialiasingFlags(this, refDT);
|
|
||||||
SetAntialiasingFlags(this, captureDT);
|
SetAntialiasingFlags(this, captureDT);
|
||||||
SetAntialiasingFlags(this, target);
|
SetAntialiasingFlags(this, target);
|
||||||
|
|
||||||
|
|||||||
@@ -398,8 +398,12 @@ BulletRenderer::BuildGlyphForText(nsDisplayItem* aItem, bool disableSubpixelAA)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(IsTextType());
|
MOZ_ASSERT(IsTextType());
|
||||||
|
|
||||||
|
RefPtr<DrawTarget> screenTarget = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||||
RefPtr<DrawTargetCapture> capture =
|
RefPtr<DrawTargetCapture> capture =
|
||||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreateCaptureDT(IntSize());
|
Factory::CreateCaptureDrawTarget(screenTarget->GetBackendType(),
|
||||||
|
IntSize(),
|
||||||
|
screenTarget->GetFormat());
|
||||||
|
|
||||||
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(capture);
|
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(capture);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5119,8 +5119,11 @@ nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame
|
|||||||
|
|
||||||
if (gfxPrefs::LayersAllowTextLayers() &&
|
if (gfxPrefs::LayersAllowTextLayers() &&
|
||||||
CanUseAdvancedLayer(aBuilder->GetWidgetLayerManager())) {
|
CanUseAdvancedLayer(aBuilder->GetWidgetLayerManager())) {
|
||||||
|
RefPtr<DrawTarget> screenTarget = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||||
RefPtr<DrawTargetCapture> capture =
|
RefPtr<DrawTargetCapture> capture =
|
||||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreateCaptureDT(IntSize());
|
Factory::CreateCaptureDrawTarget(screenTarget->GetBackendType(),
|
||||||
|
IntSize(),
|
||||||
|
screenTarget->GetFormat());
|
||||||
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(capture);
|
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(capture);
|
||||||
|
|
||||||
// TODO: Paint() checks mDisableSubpixelAA, we should too.
|
// TODO: Paint() checks mDisableSubpixelAA, we should too.
|
||||||
|
|||||||
Reference in New Issue
Block a user