Backed out changeset 5c6803c30303 (bug 1311512) for mass asserting. r=backout

This commit is contained in:
Sebastian Hengst 2017-01-07 00:08:26 +01:00
Родитель d0c224741e
Коммит 9506ca8115
9 изменённых файлов: 29 добавлений и 338 удалений

Просмотреть файл

@ -75,6 +75,31 @@ EnsureSurfaceStored(DrawEventRecorderPrivate *aRecorder, SourceSurface *aSurface
return; return;
} }
class SourceSurfaceRecording : public SourceSurface
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceRecording)
SourceSurfaceRecording(SourceSurface *aFinalSurface, DrawEventRecorderPrivate *aRecorder)
: mFinalSurface(aFinalSurface), mRecorder(aRecorder)
{
mRecorder->AddStoredObject(this);
}
~SourceSurfaceRecording()
{
mRecorder->RemoveStoredObject(this);
mRecorder->RecordEvent(RecordedSourceSurfaceDestruction(this));
}
virtual SurfaceType GetType() const { return SurfaceType::RECORDING; }
virtual IntSize GetSize() const { return mFinalSurface->GetSize(); }
virtual SurfaceFormat GetFormat() const { return mFinalSurface->GetFormat(); }
virtual already_AddRefed<DataSourceSurface> GetDataSurface() { return mFinalSurface->GetDataSurface(); }
RefPtr<SourceSurface> mFinalSurface;
RefPtr<DrawEventRecorderPrivate> mRecorder;
};
class GradientStopsRecording : public GradientStops class GradientStopsRecording : public GradientStops
{ {
public: public:

Просмотреть файл

@ -331,31 +331,6 @@ private:
RefPtr<DrawTarget> mFinalDT; RefPtr<DrawTarget> mFinalDT;
}; };
class SourceSurfaceRecording : public SourceSurface
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceRecording)
SourceSurfaceRecording(SourceSurface *aFinalSurface, DrawEventRecorderPrivate *aRecorder)
: mFinalSurface(aFinalSurface), mRecorder(aRecorder)
{
mRecorder->AddStoredObject(this);
}
~SourceSurfaceRecording()
{
mRecorder->RemoveStoredObject(this);
mRecorder->RecordEvent(RecordedSourceSurfaceDestruction(this));
}
virtual SurfaceType GetType() const { return SurfaceType::RECORDING; }
virtual IntSize GetSize() const { return mFinalSurface->GetSize(); }
virtual SurfaceFormat GetFormat() const { return mFinalSurface->GetFormat(); }
virtual already_AddRefed<DataSourceSurface> GetDataSurface() { return mFinalSurface->GetDataSurface(); }
RefPtr<SourceSurface> mFinalSurface;
RefPtr<DrawEventRecorderPrivate> mRecorder;
};
} // namespace gfx } // namespace gfx
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -1,99 +0,0 @@
/* -*- 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 "InlineTranslator.h"
#include "gfxContext.h"
#include "nsDeviceContext.h"
#include "mozilla/gfx/RecordedEvent.h"
#include "mozilla/gfx/RecordingTypes.h"
#include "mozilla/UniquePtr.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace gfx {
InlineTranslator::InlineTranslator(DrawTarget* aDT, Matrix aMatrix)
{
mBaseDT = aDT;
mBaseTransform = aMatrix;
}
bool
InlineTranslator::TranslateRecording(std::istream& aRecording)
{
uint32_t magicInt;
ReadElement(aRecording, magicInt);
if (magicInt != mozilla::gfx::kMagicInt) {
return false;
}
uint16_t majorRevision;
ReadElement(aRecording, majorRevision);
if (majorRevision != kMajorRevision) {
return false;
}
uint16_t minorRevision;
ReadElement(aRecording, minorRevision);
if (minorRevision > kMinorRevision) {
return false;
}
int32_t eventType;
ReadElement(aRecording, eventType);
while (aRecording.good()) {
UniquePtr<RecordedEvent> recordedEvent(
RecordedEvent::LoadEventFromStream(aRecording,
static_cast<RecordedEvent::EventType>(eventType)));
// Make sure that the whole event was read from the stream successfully.
if (!aRecording.good() || !recordedEvent) {
return false;
}
if (recordedEvent->GetType() == RecordedEvent::SETTRANSFORM) {
RecordedSetTransform* event = static_cast<RecordedSetTransform*>(recordedEvent.get());
mBaseDT->SetTransform(event->mTransform * mBaseTransform);
} else {
if (!recordedEvent->PlayEvent(this)) {
return false;
}
}
ReadElement(aRecording, eventType);
}
return true;
}
already_AddRefed<DrawTarget>
InlineTranslator::CreateDrawTarget(ReferencePtr aRefPtr,
const gfx::IntSize &aSize,
gfx::SurfaceFormat aFormat)
{
RefPtr<DrawTarget> drawTarget = mBaseDT;
return drawTarget.forget();
}
FontType
InlineTranslator::GetDesiredFontType()
{
switch (mBaseDT->GetBackendType()) {
case BackendType::DIRECT2D:
return FontType::DWRITE;
case BackendType::CAIRO:
return FontType::CAIRO;
case BackendType::SKIA:
return FontType::SKIA;
default:
return FontType::CAIRO;
}
}
} // namespace gfx
} // namespace mozilla

Просмотреть файл

@ -1,167 +0,0 @@
/* -*- 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/. */
#ifndef mozilla_layout_InlineTranslator_h
#define mozilla_layout_InlineTranslator_h
#include <istream>
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Filters.h"
#include "mozilla/gfx/RecordedEvent.h"
#include "nsRefPtrHashtable.h"
namespace mozilla {
namespace gfx {
using gfx::Translator;
using gfx::ReferencePtr;
using gfx::DrawTarget;
using gfx::Path;
using gfx::SourceSurface;
using gfx::FilterNode;
using gfx::GradientStops;
using gfx::ScaledFont;
using gfx::NativeFontResource;
class InlineTranslator final : public Translator
{
public:
explicit InlineTranslator(DrawTarget* aDT, Matrix aMatrix);
bool TranslateRecording(std::istream& aRecording);
DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final
{
return mBaseDT;
}
Path* LookupPath(ReferencePtr aRefPtr) final
{
Path* result = mPaths.GetWeak(aRefPtr);
MOZ_ASSERT(result);
return result;
}
SourceSurface* LookupSourceSurface(ReferencePtr aRefPtr) final
{
SourceSurface* result = mSourceSurfaces.GetWeak(aRefPtr);
MOZ_ASSERT(result);
return result;
}
FilterNode* LookupFilterNode(ReferencePtr aRefPtr) final
{
FilterNode* result = mFilterNodes.GetWeak(aRefPtr);
MOZ_ASSERT(result);
return result;
}
GradientStops* LookupGradientStops(ReferencePtr aRefPtr) final
{
GradientStops* result = mGradientStops.GetWeak(aRefPtr);
MOZ_ASSERT(result);
return result;
}
ScaledFont* LookupScaledFont(ReferencePtr aRefPtr) final
{
ScaledFont* result = mScaledFonts.GetWeak(aRefPtr);
MOZ_ASSERT(result);
return result;
}
NativeFontResource* LookupNativeFontResource(uint64_t aKey) final
{
NativeFontResource* result = mNativeFontResources.GetWeak(aKey);
MOZ_ASSERT(result);
return result;
}
void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget *aDT) final { }
void AddPath(ReferencePtr aRefPtr, Path *aPath) final
{
mPaths.Put(aRefPtr, aPath);
}
void AddSourceSurface(ReferencePtr aRefPtr, SourceSurface *aSurface) final
{
mSourceSurfaces.Put(aRefPtr, aSurface);
}
void AddFilterNode(ReferencePtr aRefPtr, FilterNode *aFilter) final
{
mFilterNodes.Put(aRefPtr, aFilter);
}
void AddGradientStops(ReferencePtr aRefPtr, GradientStops *aStops) final
{
mGradientStops.Put(aRefPtr, aStops);
}
void AddScaledFont(ReferencePtr aRefPtr, ScaledFont *aScaledFont) final
{
mScaledFonts.Put(aRefPtr, aScaledFont);
}
void AddNativeFontResource(uint64_t aKey,
NativeFontResource *aScaledFontResouce) final
{
mNativeFontResources.Put(aKey, aScaledFontResouce);
}
void RemoveDrawTarget(ReferencePtr aRefPtr) final { }
void RemovePath(ReferencePtr aRefPtr) final
{
mPaths.Remove(aRefPtr);
}
void RemoveSourceSurface(ReferencePtr aRefPtr) final
{
mSourceSurfaces.Remove(aRefPtr);
}
void RemoveFilterNode(ReferencePtr aRefPtr) final
{
mFilterNodes.Remove(aRefPtr);
}
void RemoveGradientStops(ReferencePtr aRefPtr) final
{
mGradientStops.Remove(aRefPtr);
}
void RemoveScaledFont(ReferencePtr aRefPtr) final
{
mScaledFonts.Remove(aRefPtr);
}
already_AddRefed<DrawTarget> CreateDrawTarget(ReferencePtr aRefPtr,
const gfx::IntSize &aSize,
gfx::SurfaceFormat aFormat) final;
mozilla::gfx::DrawTarget* GetReferenceDrawTarget() final { return mBaseDT; }
mozilla::gfx::FontType GetDesiredFontType() final;
private:
RefPtr<DrawTarget> mBaseDT;
Matrix mBaseTransform;
nsRefPtrHashtable<nsPtrHashKey<void>, Path> mPaths;
nsRefPtrHashtable<nsPtrHashKey<void>, SourceSurface> mSourceSurfaces;
nsRefPtrHashtable<nsPtrHashKey<void>, FilterNode> mFilterNodes;
nsRefPtrHashtable<nsPtrHashKey<void>, GradientStops> mGradientStops;
nsRefPtrHashtable<nsPtrHashKey<void>, ScaledFont> mScaledFonts;
nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
};
} // namespace gfx
} // namespace mozilla
#endif // mozilla_layout_InlineTranslator_h

Просмотреть файл

@ -698,12 +698,12 @@ public:
virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
virtual std::string GetName() const { return "SetTransform"; } virtual std::string GetName() const { return "SetTransform"; }
Matrix mTransform;
private: private:
friend class RecordedEvent; friend class RecordedEvent;
MOZ_IMPLICIT RecordedSetTransform(std::istream &aStream); MOZ_IMPLICIT RecordedSetTransform(std::istream &aStream);
Matrix mTransform;
}; };
class RecordedDrawSurface : public RecordedDrawingEvent { class RecordedDrawSurface : public RecordedDrawingEvent {

Просмотреть файл

@ -24,12 +24,10 @@ EXPORTS.mozilla.gfx += [
'CriticalSection.h', 'CriticalSection.h',
'DataSurfaceHelpers.h', 'DataSurfaceHelpers.h',
'DrawEventRecorder.h', 'DrawEventRecorder.h',
'DrawTargetRecording.h',
'DrawTargetTiled.h', 'DrawTargetTiled.h',
'Filters.h', 'Filters.h',
'Helpers.h', 'Helpers.h',
'HelpersCairo.h', 'HelpersCairo.h',
'InlineTranslator.h',
'IterableArena.h', 'IterableArena.h',
'JobScheduler.h', 'JobScheduler.h',
'JobScheduler_posix.h', 'JobScheduler_posix.h',
@ -181,7 +179,6 @@ UNIFIED_SOURCES += [
SOURCES += [ SOURCES += [
'Factory.cpp', # Need to suppress warnings in Skia header files. 'Factory.cpp', # Need to suppress warnings in Skia header files.
'InlineTranslator.cpp',
] ]
if CONFIG['CLANG_CXX']: if CONFIG['CLANG_CXX']:

Просмотреть файл

@ -110,8 +110,8 @@ BasicCanvasLayer::Paint(DrawTarget* aDT,
if (needsYFlip) { if (needsYFlip) {
oldTM = aDT->GetTransform(); oldTM = aDT->GetTransform();
aDT->SetTransform(Matrix(oldTM). aDT->SetTransform(Matrix(oldTM).
PreTranslate(0.0f, mBounds.height). PreTranslate(0.0f, mBounds.height).
PreScale(1.0f, -1.0f)); PreScale(1.0f, -1.0f));
} }
FillRectWithMask(aDT, aDeviceOffset, FillRectWithMask(aDT, aDeviceOffset,

Просмотреть файл

@ -12,8 +12,6 @@
#include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/layers/ISurfaceAllocator.h"
#include "AutoMaskData.h" #include "AutoMaskData.h"
#include "mozilla/gfx/InlineTranslator.h"
#include "mozilla/gfx/DrawTargetRecording.h"
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -124,10 +122,6 @@ FillRectWithMask(DrawTarget* aDT,
const Matrix* aMaskTransform, const Matrix* aMaskTransform,
const Matrix* aSurfaceTransform) const Matrix* aSurfaceTransform)
{ {
MOZ_ASSERT((aMaskSource && aMaskTransform) ||
(!aMaskSource && !aMaskTransform),
"Either both or neither must be specified");
if (aMaskSource && aMaskTransform) { if (aMaskSource && aMaskTransform) {
aDT->PushClipRect(aRect); aDT->PushClipRect(aRect);
Matrix oldTransform = aDT->GetTransform(); Matrix oldTransform = aDT->GetTransform();
@ -144,35 +138,6 @@ FillRectWithMask(DrawTarget* aDT,
aDT->SetTransform(*aMaskTransform); aDT->SetTransform(*aMaskTransform);
aDT->MaskSurface(source, aMaskSource, Point(0, 0), aOptions); aDT->MaskSurface(source, aMaskSource, Point(0, 0), aOptions);
aDT->SetTransform(oldTransform);
aDT->PopClip();
return;
}
if (aSurface->GetType() == SurfaceType::RECORDING) {
MOZ_ASSERT(aOptions.mAlpha == 1.0 &&
aOptions.mCompositionOp == CompositionOp::OP_OVER);
aDT->PushClipRect(aRect);
Matrix oldTransform = aDT->GetTransform();
Matrix transform = oldTransform;
if (aSurfaceTransform) {
transform = (*aSurfaceTransform) * transform;
}
InlineTranslator* translator = new InlineTranslator(aDT, transform);
SourceSurfaceRecording* ss = static_cast<SourceSurfaceRecording*>(aSurface);
DrawEventRecorderMemory* mr = static_cast<DrawEventRecorderMemory*>(ss->mRecorder.get());
size_t size = mr->RecordingSize();
char* buffer = new char[size];
mr->CopyRecording(buffer, size);
std::istringstream recording(std::string(buffer, size));
translator->TranslateRecording(recording);
aDT->SetTransform(oldTransform); aDT->SetTransform(oldTransform);
aDT->PopClip(); aDT->PopClip();
return; return;

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsDisplayList.h" #include "nsDisplayList.h"
#include "nsHTMLCanvasFrame.h" #include "nsHTMLCanvasFrame.h"
#include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/HTMLCanvasElement.h"
#include "mozilla/gfx/DrawEventRecorder.h"
#include "nsICanvasRenderingContextInternal.h" #include "nsICanvasRenderingContextInternal.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include <algorithm> #include <algorithm>
@ -630,12 +629,8 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a
HTMLCanvasElement* canvas = mCurrentCanvasList[i]; HTMLCanvasElement* canvas = mCurrentCanvasList[i];
nsIntSize size = canvas->GetSize(); nsIntSize size = canvas->GetSize();
RefPtr<mozilla::gfx::DrawEventRecorder> recorder =
new mozilla::gfx::DrawEventRecorderMemory();
RefPtr<DrawTarget> canvasTarget = RefPtr<DrawTarget> canvasTarget =
drawTarget->CreateSimilarDrawTarget(size, drawTarget->GetFormat()); drawTarget->CreateSimilarDrawTarget(size, drawTarget->GetFormat());
canvasTarget =
mozilla::gfx::Factory::CreateRecordingDrawTarget(recorder, canvasTarget);
if (!canvasTarget) { if (!canvasTarget) {
continue; continue;
} }