Skip to content
Snippets Groups Projects
Commit 063258e3 authored by Lee Salzman's avatar Lee Salzman
Browse files

Bug 1771349 - Add some null checks to DrawTargetRecording. r=aosmond,gfx-reviewers

parent 081d6959
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
#include "Blur.h"
#include "Logging.h"
#include "PathHelpers.h"
#include "SourceSurfaceRawData.h"
#include "Tools.h"
#include "BufferEdgePad.h"
......@@ -206,9 +207,9 @@ already_AddRefed<SourceSurface> DrawTarget::IntoLuminanceSource(
}
// Create alpha channel mask for output
RefPtr<DataSourceSurface> destMaskSurface =
Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
if (!destMaskSurface) {
RefPtr<SourceSurfaceAlignedRawData> destMaskSurface =
new SourceSurfaceAlignedRawData;
if (!destMaskSurface->Init(size, SurfaceFormat::A8, false, 0)) {
return nullptr;
}
DataSourceSurface::MappedSurface destMap;
......
......@@ -235,6 +235,10 @@ void DrawTargetRecording::StrokeLine(const Point& aBegin, const Point& aEnd,
void DrawTargetRecording::Fill(const Path* aPath, const Pattern& aPattern,
const DrawOptions& aOptions) {
if (!aPath) {
return;
}
RefPtr<PathRecording> pathRecording = EnsurePathStored(aPath);
EnsurePatternDependenciesStored(aPattern);
......@@ -262,6 +266,10 @@ void DrawTargetRecording::FillGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const DrawOptions& aOptions) {
if (!aFont) {
return;
}
EnsurePatternDependenciesStored(aPattern);
UserDataKey* userDataKey = reinterpret_cast<UserDataKey*>(mRecorder.get());
......@@ -320,6 +328,10 @@ void DrawTargetRecording::Mask(const Pattern& aSource, const Pattern& aMask,
void DrawTargetRecording::MaskSurface(const Pattern& aSource,
SourceSurface* aMask, Point aOffset,
const DrawOptions& aOptions) {
if (!aMask) {
return;
}
EnsurePatternDependenciesStored(aSource);
EnsureSurfaceStoredRecording(mRecorder, aMask, "MaskSurface");
......@@ -369,6 +381,10 @@ void DrawTargetRecording::DrawSurface(SourceSurface* aSurface,
const Rect& aDest, const Rect& aSource,
const DrawSurfaceOptions& aSurfOptions,
const DrawOptions& aOptions) {
if (!aSurface) {
return;
}
EnsureSurfaceStoredRecording(mRecorder, aSurface, "DrawSurface");
mRecorder->RecordEvent(RecordedDrawSurface(this, aSurface, aDest, aSource,
......@@ -385,6 +401,10 @@ void DrawTargetRecording::DrawSurfaceWithShadow(SourceSurface* aSurface,
const Point& aDest,
const ShadowOptions& aShadow,
CompositionOp aOp) {
if (!aSurface) {
return;
}
EnsureSurfaceStoredRecording(mRecorder, aSurface, "DrawSurfaceWithShadow");
mRecorder->RecordEvent(
......@@ -394,6 +414,10 @@ void DrawTargetRecording::DrawSurfaceWithShadow(SourceSurface* aSurface,
void DrawTargetRecording::DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
const Point& aDestPoint,
const DrawOptions& aOptions) {
if (!aNode) {
return;
}
MOZ_ASSERT(mRecorder->HasStoredObject(aNode));
mRecorder->RecordEvent(
......@@ -416,6 +440,10 @@ void DrawTargetRecording::ClearRect(const Rect& aRect) {
void DrawTargetRecording::CopySurface(SourceSurface* aSurface,
const IntRect& aSourceRect,
const IntPoint& aDestination) {
if (!aSurface) {
return;
}
EnsureSurfaceStoredRecording(mRecorder, aSurface, "CopySurface");
mRecorder->RecordEvent(
......@@ -423,6 +451,10 @@ void DrawTargetRecording::CopySurface(SourceSurface* aSurface,
}
void DrawTargetRecording::PushClip(const Path* aPath) {
if (!aPath) {
return;
}
RefPtr<PathRecording> pathRecording = EnsurePathStored(aPath);
mRecorder->RecordEvent(RecordedPushClip(this, pathRecording));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment