Bug 1318283 - Debug patch - r=milan

This commit is contained in:
Edwin Flores 2016-11-28 19:32:49 +00:00
Родитель 92086b33cd
Коммит 3af4985263
2 изменённых файлов: 122 добавлений и 6 удалений

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

@ -565,7 +565,7 @@ public:
explicit AdjustedTarget(CanvasRenderingContext2D* aCtx,
const gfx::Rect *aBounds = nullptr)
{
mTarget = aCtx->mTarget;
mTarget = (DrawTarget*)aCtx->mTarget;
// All rects in this function are in the device space of ctx->mTarget.
@ -1720,7 +1720,7 @@ CanvasRenderingContext2D::SetErrorState()
gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
}
mTarget = sErrorTarget;
mTarget = (DrawTarget*)sErrorTarget;
mBufferProvider = nullptr;
// clear transforms, clips, etc.
@ -1975,7 +1975,7 @@ CanvasRenderingContext2D::InitializeWithDrawTarget(nsIDocShell* aShell,
IntSize size = aTarget->GetSize();
SetDimensions(size.width, size.height);
mTarget = aTarget;
mTarget = (DrawTarget*)aTarget;
mBufferProvider = new PersistentBufferProviderBasic(aTarget);
if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
@ -3154,6 +3154,8 @@ CanvasRenderingContext2D::BeginPath()
void
CanvasRenderingContext2D::Fill(const CanvasWindingRule& aWinding)
{
auto autoNotNull = mTarget.MakeAuto();
EnsureUserSpacePath(aWinding);
if (!mPath) {
@ -4758,6 +4760,8 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
uint8_t aOptional_argc,
ErrorResult& aError)
{
auto autoNotNull = mTarget.MakeAuto();
if (mDrawObserver) {
mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::DrawImage);
}
@ -5019,7 +5023,7 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
AdjustedTarget tempTarget(this, bounds.IsEmpty() ? nullptr : &bounds);
if (!tempTarget) {
gfxDevCrash(LogReason::InvalidDrawTarget) << "Invalid adjusted target in Canvas2D " << gfx::hexa(mTarget) << ", " << NeedToDrawShadow() << NeedToApplyFilter();
gfxDevCrash(LogReason::InvalidDrawTarget) << "Invalid adjusted target in Canvas2D " << gfx::hexa((DrawTarget*)mTarget) << ", " << NeedToDrawShadow() << NeedToApplyFilter();
return;
}
tempTarget->DrawSurface(srcSurf,

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

@ -47,6 +47,118 @@ class TextMetrics;
class CanvasFilterChainObserver;
class CanvasPath;
template<class T>
struct MaybeNotNull
{
MOZ_IMPLICIT MaybeNotNull() : mWrapped(nullptr), mEnsure(false) {}
MOZ_IMPLICIT MaybeNotNull(T&& aValue) : mWrapped(aValue), mEnsure(false) {}
~MaybeNotNull() {}
void BeginNotNull() {
mEnsure = true;
}
void EndNotNull() {
mEnsure = false;
}
void MaybeCheckWrapped() {
if (mEnsure && !mWrapped) {
MOZ_CRASH("GFX: Setting mTarget to nullptr?");
}
}
typename T::element_type* operator->() const {
return mWrapped.get();
}
already_AddRefed<typename T::element_type> forget() {
already_AddRefed<typename T::element_type>&& ret = mWrapped.forget();
MaybeCheckWrapped();
return Move(ret);
}
MOZ_IMPLICIT operator bool () {
return mWrapped;
}
operator T&() {
return mWrapped;
}
operator typename T::element_type*() {
return mWrapped.get();
}
bool operator!() const {
return !mWrapped;
}
MaybeNotNull& operator=(decltype(nullptr)) {
mWrapped = nullptr;
MaybeCheckWrapped();
return *this;
}
template<class U>
MaybeNotNull& operator=(U& aOther){
mWrapped = aOther;
MaybeCheckWrapped();
return *this;
}
template<class U>
MaybeNotNull& operator=(U&& aOther){
mWrapped = aOther;
MaybeCheckWrapped();
return *this;
}
struct AutoNotNull
{
MOZ_IMPLICIT AutoNotNull(MaybeNotNull* aMaybe) : mMaybe(aMaybe)
{
mMaybe->BeginNotNull();
}
~AutoNotNull()
{
mMaybe->EndNotNull();
}
MaybeNotNull* mMaybe;
};
AutoNotNull MakeAuto()
{
return AutoNotNull(this);
}
T mWrapped;
bool mEnsure;
};
template<class T, class U>
bool operator!=(const MaybeNotNull<T>& aT, const U& aU) {
return aT.mWrapped != aU;
}
template<class T, class U>
bool operator==(const MaybeNotNull<T>& aT, const U& aU) {
return aT.mWrapped == aU;
}
template<class T, class U>
bool operator||(const MaybeNotNull<T>& aT, const U& aU) {
return aT.mWrapped || aU;
}
template<class T, class U>
bool operator||(const T& aT, const MaybeNotNull<U>& aU) {
return aT || aU.mWrapped;
}
extern const mozilla::gfx::Float SIGMA_MAX;
template<typename T> class Optional;
@ -686,7 +798,7 @@ protected:
* Check if the target is valid after calling EnsureTarget.
*/
bool IsTargetValid() const {
return mTarget && mTarget != sErrorTarget;
return !!mTarget && mTarget != sErrorTarget;
}
/**
@ -771,7 +883,7 @@ protected:
// This is created lazily so it is necessary to call EnsureTarget before
// accessing it. In the event of an error it will be equal to
// sErrorTarget.
RefPtr<mozilla::gfx::DrawTarget> mTarget;
MaybeNotNull<RefPtr<mozilla::gfx::DrawTarget>> mTarget;
RefPtr<mozilla::layers::PersistentBufferProvider> mBufferProvider;