mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1033310: Handle CreateDataSourceSurface* returning nullptr. f=nsilva, r=bschouten
This commit is contained in:
parent
d057e5365c
commit
4455d895e8
@ -297,11 +297,10 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
|
||||
Factory::CreateDataSourceSurfaceWithStride(IntSize(aSize.width, aSize.height),
|
||||
SurfaceFormat::B8G8R8A8,
|
||||
4 * aSize.width);
|
||||
|
||||
if (!emptyCanvas) {
|
||||
NS_ERROR("Failded to create DataSourceSurface");
|
||||
if (NS_WARN_IF(!emptyCanvas)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ClearDataSourceSurface(emptyCanvas);
|
||||
DataSourceSurface::MappedSurface map;
|
||||
if (!emptyCanvas->Map(DataSourceSurface::MapType::WRITE, &map)) {
|
||||
|
@ -1491,7 +1491,7 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
|
||||
surf = Factory::CreateDataSourceSurfaceWithStride(IntSize(mWidth, mHeight),
|
||||
surfFormat,
|
||||
mWidth * 4);
|
||||
if (!surf) {
|
||||
if (NS_WARN_IF(!surf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1097,7 +1097,8 @@ public:
|
||||
/**
|
||||
* This creates a simple data source surface for a certain size. It allocates
|
||||
* new memory for the surface. This memory is freed when the surface is
|
||||
* destroyed.
|
||||
* destroyed. The caller is responsible for handing the case where nullptr
|
||||
* is returned.
|
||||
*/
|
||||
static TemporaryRef<DataSourceSurface>
|
||||
CreateDataSourceSurface(const IntSize &aSize, SurfaceFormat aFormat);
|
||||
@ -1106,7 +1107,8 @@ public:
|
||||
* This creates a simple data source surface for a certain size with a
|
||||
* specific stride, which must be large enough to fit all pixels.
|
||||
* It allocates new memory for the surface. This memory is freed when
|
||||
* the surface is destroyed.
|
||||
* the surface is destroyed. The caller is responsible for handling the case
|
||||
* where nullptr is returned.
|
||||
*/
|
||||
static TemporaryRef<DataSourceSurface>
|
||||
CreateDataSourceSurfaceWithStride(const IntSize &aSize, SurfaceFormat aFormat, int32_t aStride);
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DrawTargetTiled.h"
|
||||
#include "Logging.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -62,6 +63,9 @@ public:
|
||||
virtual TemporaryRef<DataSourceSurface> GetDataSurface()
|
||||
{
|
||||
RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurface(GetSize(), GetFormat());
|
||||
if (MOZ2D_WARN_IF(!surf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface mappedSurf;
|
||||
surf->Map(DataSourceSurface::MapType::WRITE, &mappedSurf);
|
||||
|
@ -694,6 +694,7 @@ Factory::CreateDataSourceSurface(const IntSize &aSize,
|
||||
SurfaceFormat aFormat)
|
||||
{
|
||||
if (!CheckSurfaceSize(aSize)) {
|
||||
gfxWarning() << "CreateDataSourceSurface failed with bad size";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -702,6 +703,7 @@ Factory::CreateDataSourceSurface(const IntSize &aSize,
|
||||
return newSurf.forget();
|
||||
}
|
||||
|
||||
gfxWarning() << "CreateDataSourceSurface failed in init";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -711,6 +713,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
|
||||
int32_t aStride)
|
||||
{
|
||||
if (aStride < aSize.width * BytesPerPixel(aFormat)) {
|
||||
gfxWarning() << "CreateDataSourceSurfaceWithStride failed with bad stride";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -719,6 +722,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
|
||||
return newSurf.forget();
|
||||
}
|
||||
|
||||
gfxWarning() << "CreateDataSourceSurfaceWithStride failed to initialize";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "Blur.h"
|
||||
#include <map>
|
||||
#include "FilterProcessing.h"
|
||||
#include "Logging.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
@ -493,8 +494,7 @@ GetDataSurfaceInRect(SourceSurface *aSurface,
|
||||
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(aDestRect.Size(), format);
|
||||
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1194,7 +1194,7 @@ ApplyMorphology(const IntRect& aSourceRect, DataSourceSurface* aInput,
|
||||
tmp = aInput;
|
||||
} else {
|
||||
tmp = Factory::CreateDataSourceSurface(tmpRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!tmp) {
|
||||
if (MOZ2D_WARN_IF(!tmp)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1213,7 +1213,7 @@ ApplyMorphology(const IntRect& aSourceRect, DataSourceSurface* aInput,
|
||||
dest = tmp;
|
||||
} else {
|
||||
dest = Factory::CreateDataSourceSurface(destRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!dest) {
|
||||
if (MOZ2D_WARN_IF(!dest)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1311,7 +1311,7 @@ Premultiply(DataSourceSurface* aSurface)
|
||||
IntSize size = aSurface->GetSize();
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1336,7 +1336,7 @@ Unpremultiply(DataSourceSurface* aSurface)
|
||||
IntSize size = aSurface->GetSize();
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1423,7 +1423,7 @@ FilterNodeFloodSoftware::Render(const IntRect& aRect)
|
||||
SurfaceFormat format = FormatForColor(mColor);
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(aRect.Size(), format);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1552,7 +1552,7 @@ FilterNodeTileSoftware::Render(const IntRect& aRect)
|
||||
// same format as our input filter, and we do not actually know the
|
||||
// input format before we call GetInputDataSourceSurface.
|
||||
target = Factory::CreateDataSourceSurface(aRect.Size(), input->GetFormat());
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -1709,7 +1709,7 @@ FilterNodeComponentTransferSoftware::Render(const IntRect& aRect)
|
||||
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(aRect.Size(), format);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2372,7 +2372,7 @@ FilterNodeConvolveMatrixSoftware::DoRender(const IntRect& aRect,
|
||||
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
ClearDataSourceSurface(target);
|
||||
@ -2519,7 +2519,7 @@ FilterNodeDisplacementMapSoftware::Render(const IntRect& aRect)
|
||||
GetInputDataSourceSurface(IN_DISPLACEMENT_MAP_IN2, aRect, NEED_COLOR_CHANNELS);
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!input || !map || !target) {
|
||||
if (MOZ2D_WARN_IF(!(input && map && target))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2777,7 +2777,7 @@ FilterNodeCompositeSoftware::Render(const IntRect& aRect)
|
||||
GetInputDataSourceSurface(IN_COMPOSITE_IN_START, aRect, NEED_COLOR_CHANNELS);
|
||||
RefPtr<DataSourceSurface> dest =
|
||||
Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!dest) {
|
||||
if (MOZ2D_WARN_IF(!dest)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2870,12 +2870,18 @@ FilterNodeBlurXYSoftware::Render(const IntRect& aRect)
|
||||
|
||||
if (input->GetFormat() == SurfaceFormat::A8) {
|
||||
target = Factory::CreateDataSourceSurface(srcRect.Size(), SurfaceFormat::A8);
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
CopyRect(input, target, IntRect(IntPoint(), input->GetSize()), IntPoint());
|
||||
AlphaBoxBlur blur(r, target->Stride(), sigmaXY.width, sigmaXY.height);
|
||||
blur.Blur(target->GetData());
|
||||
} else {
|
||||
RefPtr<DataSourceSurface> channel0, channel1, channel2, channel3;
|
||||
FilterProcessing::SeparateColorChannels(input, channel0, channel1, channel2, channel3);
|
||||
if (MOZ2D_WARN_IF(!(channel0 && channel1 && channel2))) {
|
||||
return nullptr;
|
||||
}
|
||||
AlphaBoxBlur blur(r, channel0->Stride(), sigmaXY.width, sigmaXY.height);
|
||||
blur.Blur(channel0->GetData());
|
||||
blur.Blur(channel1->GetData());
|
||||
@ -3384,7 +3390,7 @@ FilterNodeLightingSoftware<LightType, LightingType>::DoRender(const IntRect& aRe
|
||||
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FilterProcessing.h"
|
||||
#include "Logging.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -13,6 +14,9 @@ FilterProcessing::ExtractAlpha(DataSourceSurface* aSource)
|
||||
{
|
||||
IntSize size = aSource->GetSize();
|
||||
RefPtr<DataSourceSurface> alpha = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
|
||||
if (MOZ2D_WARN_IF(!alpha)) {
|
||||
return nullptr;
|
||||
}
|
||||
uint8_t* sourceData = aSource->GetData();
|
||||
int32_t sourceStride = aSource->Stride();
|
||||
uint8_t* alphaData = alpha->GetData();
|
||||
@ -122,6 +126,10 @@ FilterProcessing::SeparateColorChannels(DataSourceSurface* aSource,
|
||||
aChannel1 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
|
||||
aChannel2 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
|
||||
aChannel3 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
|
||||
if (MOZ2D_WARN_IF(!(aChannel0 && aChannel1 && aChannel2 && aChannel3))) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* sourceData = aSource->GetData();
|
||||
int32_t sourceStride = aSource->Stride();
|
||||
uint8_t* channel0Data = aChannel0->GetData();
|
||||
@ -146,6 +154,9 @@ FilterProcessing::CombineColorChannels(DataSourceSurface* aChannel0, DataSourceS
|
||||
IntSize size = aChannel0->GetSize();
|
||||
RefPtr<DataSourceSurface> result =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (MOZ2D_WARN_IF(!result)) {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t resultStride = result->Stride();
|
||||
uint8_t* resultData = result->GetData();
|
||||
int32_t channelStride = aChannel0->Stride();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define FILTER_PROCESSING_SCALAR
|
||||
|
||||
#include "FilterProcessingSIMD-inl.h"
|
||||
#include "Logging.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -35,7 +36,7 @@ ApplyBlending_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
|
||||
IntSize size = aInput1->GetSize();
|
||||
RefPtr<DataSourceSurface> target =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (!target) {
|
||||
if (MOZ2D_WARN_IF(!target)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,25 @@ typedef Log<LOG_WARNING> WarningLog;
|
||||
#define gfxWarning if (1) ; else NoLog
|
||||
#endif
|
||||
|
||||
// See nsDebug.h and the NS_WARN_IF macro
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef DEBUG
|
||||
inline bool MOZ2D_warn_if_impl(bool aCondition, const char* aExpr,
|
||||
const char* aFile, int32_t aLine)
|
||||
{
|
||||
if (MOZ_UNLIKELY(aCondition)) {
|
||||
gfxWarning() << aExpr << " at " << aFile << ":" << aLine;
|
||||
}
|
||||
return aCondition;
|
||||
}
|
||||
#define MOZ2D_WARN_IF(condition) \
|
||||
MOZ2D_warn_if_impl(condition, #condition, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MOZ2D_WARN_IF(condition) (bool)(condition)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const int INDENT_PER_LEVEL = 2;
|
||||
|
||||
class TreeLog
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "Tools.h"
|
||||
#include "Filters.h"
|
||||
#include "Logging.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -396,6 +397,7 @@ RecordedDrawTargetCreation::RecordToStream(ostream &aStream) const
|
||||
|
||||
RecordedDrawTargetCreation::RecordedDrawTargetCreation(istream &aStream)
|
||||
: RecordedEvent(DRAWTARGETCREATION)
|
||||
, mExistingData(nullptr)
|
||||
{
|
||||
ReadElement(aStream, mRefPtr);
|
||||
ReadElement(aStream, mBackendType);
|
||||
@ -405,6 +407,12 @@ RecordedDrawTargetCreation::RecordedDrawTargetCreation(istream &aStream)
|
||||
|
||||
if (mHasExistingData) {
|
||||
RefPtr<DataSourceSurface> dataSurf = Factory::CreateDataSourceSurface(mSize, mFormat);
|
||||
if (!dataSurf) {
|
||||
gfxWarning() << "RecordedDrawTargetCreation had to reset mHasExistingData";
|
||||
mHasExistingData = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int y = 0; y < mSize.height; y++) {
|
||||
aStream.read((char*)dataSurf->GetData() + y * dataSurf->Stride(),
|
||||
BytesPerPixel(mFormat) * mSize.width);
|
||||
|
@ -458,6 +458,10 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
|
||||
tempSurf = Factory::CreateDataSourceSurfaceWithStride(dest->GetSize(),
|
||||
readFormatGFX,
|
||||
stride);
|
||||
if (NS_WARN_IF(!tempSurf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
readSurf = tempSurf;
|
||||
}
|
||||
MOZ_ASSERT(readAlignment);
|
||||
@ -523,7 +527,7 @@ YInvertImageSurface(DataSourceSurface* aSurf)
|
||||
Factory::CreateDataSourceSurfaceWithStride(aSurf->GetSize(),
|
||||
aSurf->GetFormat(),
|
||||
aSurf->Stride());
|
||||
if (!temp) {
|
||||
if (NS_WARN_IF(!temp)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -568,7 +572,7 @@ ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, SurfaceFormat aFo
|
||||
Factory::CreateDataSourceSurfaceWithStride(size, SurfaceFormat::B8G8R8A8,
|
||||
GetAlignedStride<4>(size.width * BytesPerPixel(SurfaceFormat::B8G8R8A8)));
|
||||
|
||||
if (!surf) {
|
||||
if (NS_WARN_IF(!surf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -620,6 +624,9 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
Factory::CreateDataSourceSurfaceWithStride(aSize,
|
||||
SurfaceFormat::R8G8B8A8,
|
||||
stride);
|
||||
if (NS_WARN_IF(isurf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GLint oldrb, oldfb, oldprog, oldTexUnit, oldTex;
|
||||
GLuint rb, fb;
|
||||
|
@ -82,6 +82,11 @@ SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
|
||||
|
||||
int32_t stride = gfx::GetAlignedStride<4>(size.width * BytesPerPixel(format));
|
||||
mData = gfx::Factory::CreateDataSourceSurfaceWithStride(size, format, stride);
|
||||
// Leave the extra return for clarity, in case we decide more code should
|
||||
// be added after this check, that should run even if mData is null.
|
||||
if (NS_WARN_IF(!mData)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SharedSurface_Basic::~SharedSurface_Basic()
|
||||
@ -98,6 +103,11 @@ SharedSurface_Basic::~SharedSurface_Basic()
|
||||
void
|
||||
SharedSurface_Basic::Fence()
|
||||
{
|
||||
// The constructor can fail to get us mData, we should deal with it:
|
||||
if (NS_WARN_IF(!mData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mGL->MakeCurrent();
|
||||
ScopedBindFramebuffer autoFB(mGL, mFB);
|
||||
ReadPixelsIntoDataSurface(mGL, mData);
|
||||
|
@ -142,6 +142,12 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
|
||||
resultSurf = sharedSurf_Basic->GetData();
|
||||
} else {
|
||||
RefPtr<DataSourceSurface> data = GetTempSurface(readSize, format);
|
||||
// There will already be a warning from inside of GetTempSurface, but
|
||||
// it doesn't hurt to complain:
|
||||
if (NS_WARN_IF(!data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Readback handles Flush/MarkDirty.
|
||||
mGLContext->Screen()->Readback(sharedSurf, data);
|
||||
if (needsPremult) {
|
||||
|
@ -145,9 +145,7 @@ D3D9SurfaceImage::GetAsSourceSurface()
|
||||
|
||||
HRESULT hr;
|
||||
RefPtr<gfx::DataSourceSurface> surface = gfx::Factory::CreateDataSourceSurface(mSize, gfx::SurfaceFormat::B8G8R8X8);
|
||||
|
||||
if (!surface) {
|
||||
NS_WARNING("Failed to created SourceSurface for D3D9SurfaceImage.");
|
||||
if (NS_WARN_IF(!surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -356,8 +356,7 @@ GrallocImage::GetAsSourceSurface()
|
||||
|
||||
RefPtr<gfx::DataSourceSurface> surface =
|
||||
gfx::Factory::CreateDataSourceSurface(GetSize(), gfx::SurfaceFormat::R5G6B5);
|
||||
if (!surface) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -590,8 +590,7 @@ PlanarYCbCrImage::GetAsSourceSurface()
|
||||
}
|
||||
|
||||
RefPtr<gfx::DataSourceSurface> surface = gfx::Factory::CreateDataSourceSurface(size, format);
|
||||
if (!surface) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -609,8 +608,7 @@ RemoteBitmapImage::GetAsSourceSurface()
|
||||
? gfx::SurfaceFormat::B8G8R8X8
|
||||
: gfx::SurfaceFormat::B8G8R8A8;
|
||||
RefPtr<gfx::DataSourceSurface> newSurf = gfx::Factory::CreateDataSourceSurface(mSize, fmt);
|
||||
if (!newSurf) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!newSurf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,9 @@ MacIOSurfaceImage::GetAsSourceSurface()
|
||||
|
||||
RefPtr<gfx::DataSourceSurface> dataSurface
|
||||
= gfx::Factory::CreateDataSourceSurface(gfx::IntSize(ioWidth, ioHeight), gfx::SurfaceFormat::B8G8R8A8);
|
||||
if (!dataSurface)
|
||||
if (NS_WARN_IF(!dataSurface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gfx::DataSourceSurface::MappedSurface mappedSurface;
|
||||
if (!dataSurface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface))
|
||||
|
@ -276,8 +276,7 @@ YCbCrImageDataDeserializer::ToDataSourceSurface()
|
||||
{
|
||||
RefPtr<DataSourceSurface> result =
|
||||
Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::B8G8R8X8);
|
||||
if (!result) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!result)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
|
||||
RefPtr<DataSourceSurface> source = snapshot->GetDataSurface();
|
||||
RefPtr<DataSourceSurface> temp =
|
||||
Factory::CreateDataSourceSurface(RoundOut(transformBounds).Size(), SurfaceFormat::B8G8R8A8);
|
||||
if (!temp) {
|
||||
if (NS_WARN_IF(!temp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ TextRenderer::RenderText(const string& aText, const IntPoint& aOrigin,
|
||||
// Create a surface to draw our glyphs to.
|
||||
RefPtr<DataSourceSurface> textSurf =
|
||||
Factory::CreateDataSourceSurface(IntSize(maxWidth, numLines * sCellHeight), sTextureFormat);
|
||||
if (!textSurf) {
|
||||
if (NS_WARN_IF(!textSurf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -147,8 +147,7 @@ TextRenderer::EnsureInitialized()
|
||||
}
|
||||
|
||||
mGlyphBitmaps = Factory::CreateDataSourceSurface(IntSize(sTextureWidth, sTextureHeight), sTextureFormat);
|
||||
if (!mGlyphBitmaps) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!mGlyphBitmaps)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Note that this may still fail to set mGlyphBitmaps to a valid value
|
||||
// if the underlying CreateDataSourceSurface fails for some reason.
|
||||
void EnsureInitialized();
|
||||
|
||||
RefPtr<Compositor> mCompositor;
|
||||
|
@ -483,6 +483,9 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
||||
|
||||
if (!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
RefPtr<gfx::DataSourceSurface> surf = yuvDeserializer.ToDataSourceSurface();
|
||||
if (NS_WARN_IF(!surf)) {
|
||||
return false;
|
||||
}
|
||||
if (!mFirstSource) {
|
||||
mFirstSource = mCompositor->CreateDataTextureSource(mFlags);
|
||||
}
|
||||
@ -575,6 +578,9 @@ BufferTextureHost::GetAsSurface()
|
||||
return nullptr;
|
||||
}
|
||||
result = yuvDeserializer.ToDataSourceSurface();
|
||||
if (NS_WARN_IF(!result)) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
ImageDataDeserializer deserializer(GetBuffer(), GetBufferSize());
|
||||
if (!deserializer.IsValid()) {
|
||||
|
@ -471,9 +471,7 @@ RemoteDXGITextureImage::GetAsSourceSurface()
|
||||
mFormat == RemoteImageData::BGRX32
|
||||
? gfx::SurfaceFormat::B8G8R8X8
|
||||
: gfx::SurfaceFormat::B8G8R8A8);
|
||||
|
||||
if (!surface) {
|
||||
NS_WARNING("Failed to create SourceSurface for DXGI texture.");
|
||||
if (NS_WARN_IF(!surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1493,8 +1493,7 @@ CompositorOGL::CopyToTarget(DrawTarget* aTarget, const nsIntPoint& aTopLeft, con
|
||||
|
||||
RefPtr<DataSourceSurface> source =
|
||||
Factory::CreateDataSourceSurface(rect.Size(), gfx::SurfaceFormat::B8G8R8A8);
|
||||
if (!source) {
|
||||
NS_WARNING("Failed to create SourceSurface.");
|
||||
if (NS_WARN_IF(!source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,6 +263,9 @@ MapSrcAndCreateMappedDest(DataSourceSurface* srcSurf,
|
||||
Factory::CreateDataSourceSurfaceWithStride(srcSurf->GetSize(),
|
||||
srcSurf->GetFormat(),
|
||||
srcMap.mStride);
|
||||
if (NS_WARN_IF(!destSurf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface destMap;
|
||||
if (!destSurf->Map(DataSourceSurface::MapType::WRITE, &destMap)) {
|
||||
|
@ -866,6 +866,9 @@ RasterImage::CopyFrame(uint32_t aWhichFrame,
|
||||
IntSize size(mSize.width, mSize.height);
|
||||
RefPtr<DataSourceSurface> surf =
|
||||
Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
|
||||
if (NS_WARN_IF(!surf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface mapping;
|
||||
DebugOnly<bool> success =
|
||||
|
@ -204,6 +204,10 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
|
||||
RefPtr<DataSourceSurface> dataSurface =
|
||||
Factory::CreateDataSourceSurface(IntSize(aScaledWidth, aScaledHeight),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (NS_WARN_IF(!dataSurface)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface map;
|
||||
if (!dataSurface->Map(DataSourceSurface::MapType::WRITE, &map)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -271,6 +275,10 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
RefPtr<DataSourceSurface> dataSurface =
|
||||
Factory::CreateDataSourceSurface(IntSize(aWidth, aHeight),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (NS_WARN_IF(!dataSurface)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface map;
|
||||
if (!dataSurface->Map(DataSourceSurface::MapType::WRITE, &map)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user