Backed out changeset aa8e746be488 (bug 944579) for bustage.

This commit is contained in:
Ryan VanderMeulen 2014-01-16 11:41:40 -05:00
Родитель a0390ff1f0
Коммит 105102a22c
2 изменённых файлов: 0 добавлений и 65 удалений

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

@ -997,12 +997,6 @@ class GFX2D_API Factory
public:
static bool HasSSE2();
/* Make sure that the given dimensions don't overflow a 32-bit signed int
* using 4 bytes per pixel; optionally, make sure that either dimension
* doesn't exceed the given limit.
*/
static bool CheckSurfaceSize(const IntSize &sz, int32_t limit = 0);
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize);
static TemporaryRef<SourceSurface>

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

@ -51,8 +51,6 @@
#include "Logging.h"
#include "mozilla/CheckedInt.h"
#ifdef PR_LOGGING
PRLogModuleInfo *
GetGFX2DLog()
@ -183,58 +181,9 @@ Factory::HasSSE2()
#endif
}
bool
Factory::CheckSurfaceSize(const IntSize &sz, int32_t limit)
{
if (sz.width < 0 || sz.height < 0) {
gfxDebug() << "Surface width or height < 0!";
return false;
}
// reject images with sides bigger than limit
if (limit && (sz.width > limit || sz.height > limit)) {
gfxDebug() << "Surface size too large (exceeds caller's limit)!";
return false;
}
// make sure the surface area doesn't overflow a int32_t
CheckedInt<int32_t> tmp = sz.width;
tmp *= sz.height;
if (!tmp.isValid()) {
gfxDebug() << "Surface size too large (would overflow)!";
return false;
}
// assuming 4 bytes per pixel, make sure the allocation size
// doesn't overflow a int32_t either
CheckedInt<int32_t> stride = sz.width;
stride *= 4;
// When aligning the stride to 16 bytes, it can grow by up to 15 bytes.
stride += 16 - 1;
if (!stride.isValid()) {
gfxDebug() << "Surface size too large (stride overflows int32_t)!";
return false;
}
CheckedInt<int32_t> numBytes = GetAlignedStride<16>(sz.width * 4);
numBytes *= aSize.height;
if (!numBytes.isValid()) {
gfxDebug() << "Surface size too large (allocation size would overflow int32_t)!";
return false;
}
return true;
}
TemporaryRef<DrawTarget>
Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat)
{
if (!CheckSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<DrawTarget> retVal;
switch (aBackend) {
#ifdef WIN32
@ -324,10 +273,6 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
int32_t aStride,
SurfaceFormat aFormat)
{
if (!CheckSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<DrawTarget> retVal;
switch (aBackend) {
@ -698,10 +643,6 @@ TemporaryRef<DataSourceSurface>
Factory::CreateDataSourceSurface(const IntSize &aSize,
SurfaceFormat aFormat)
{
if (!CheckSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<SourceSurfaceAlignedRawData> newSurf = new SourceSurfaceAlignedRawData();
if (newSurf->Init(aSize, aFormat)) {
return newSurf;