зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1279628, part 2 - Replace all gfxASurface::CheckSurfaceSize calls with Factory::CheckSurfaceSize and remove gfxASurface::CheckSurfaceSize. r=mstange
--HG-- extra : rebase_source : 314cf522b5760e63e176418ae170301fafa80f89
This commit is contained in:
Родитель
8b002c52bd
Коммит
8ea6b72d47
|
@ -49,7 +49,6 @@
|
|||
#include "ImageRegion.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxFont.h"
|
||||
|
@ -4913,8 +4912,8 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
|
|||
|
||||
// protect against too-large surfaces that will cause allocation
|
||||
// or overflow issues
|
||||
if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(int32_t(aW), int32_t(aH)),
|
||||
0xffff)) {
|
||||
if (!Factory::CheckSurfaceSize(gfx::IntSize(int32_t(aW), int32_t(aH)),
|
||||
0xffff)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -5114,7 +5113,7 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& aElem,
|
|||
|
||||
// protect against too-large surfaces that will cause allocation
|
||||
// or overflow issues
|
||||
if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(aW, aH), 0xffff)) {
|
||||
if (!Factory::CheckSurfaceSize(gfx::IntSize(aW, aH), 0xffff)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -761,10 +761,6 @@ protected:
|
|||
*/
|
||||
bool mIsCapturedFrameInvalid;
|
||||
|
||||
// This is stored after GetThebesSurface has been called once to avoid
|
||||
// excessive ThebesSurface initialization overhead.
|
||||
RefPtr<gfxASurface> mThebesSurface;
|
||||
|
||||
/**
|
||||
* We also have a device space pathbuilder. The reason for this is as
|
||||
* follows, when a path is being built, but the transform changes, we
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
{ 0xb84f2fed, 0x9d4b, 0x430b, \
|
||||
{ 0xbd, 0xfb, 0x85, 0x57, 0x8a, 0xc2, 0xb4, 0x4b } }
|
||||
|
||||
class gfxASurface;
|
||||
class nsDisplayListBuilder;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -352,49 +352,6 @@ gfxASurface::CairoStatus()
|
|||
return cairo_surface_status(mSurface);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
gfxASurface::CheckSurfaceSize(const IntSize& sz, int32_t limit)
|
||||
{
|
||||
if (sz.width < 0 || sz.height < 0) {
|
||||
NS_WARNING("Surface width or height < 0!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// reject images with sides bigger than limit
|
||||
if (limit && (sz.width > limit || sz.height > limit)) {
|
||||
NS_WARNING("Surface size too large (exceeds caller's limit)!");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// CoreGraphics is limited to images < 32K in *height*,
|
||||
// so clamp all surfaces on the Mac to that height
|
||||
if (sz.height > SHRT_MAX) {
|
||||
NS_WARNING("Surface size too large (exceeds CoreGraphics limit)!");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// make sure the surface area doesn't overflow a int32_t
|
||||
CheckedInt<int32_t> tmp = sz.width;
|
||||
tmp *= sz.height;
|
||||
if (!tmp.isValid()) {
|
||||
NS_WARNING("Surface size too large (would overflow)!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// assuming 4-byte stride, make sure the allocation size
|
||||
// doesn't overflow a int32_t either
|
||||
tmp *= 4;
|
||||
if (!tmp.isValid()) {
|
||||
NS_WARNING("Allocation too large (would overflow)!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
int32_t
|
||||
gfxASurface::FormatStrideForWidth(gfxImageFormat format, int32_t width)
|
||||
|
|
|
@ -101,12 +101,6 @@ public:
|
|||
|
||||
int CairoStatus();
|
||||
|
||||
/* 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 mozilla::gfx::IntSize& sz, int32_t limit = 0);
|
||||
|
||||
/* Provide a stride value that will respect all alignment requirements of
|
||||
* the accelerated image-rendering code.
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef GFX_SHARED_MEMORYSURFACE_H
|
||||
#define GFX_SHARED_MEMORYSURFACE_H
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/ipc/Shmem.h"
|
||||
#include "mozilla/ipc/SharedMemory.h"
|
||||
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
{
|
||||
SharedImageInfo* shmInfo = GetShmInfoPtr(aShmem);
|
||||
mozilla::gfx::IntSize size(shmInfo->width, shmInfo->height);
|
||||
if (!gfxASurface::CheckSurfaceSize(size))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(size))
|
||||
return nullptr;
|
||||
|
||||
gfxImageFormat format = shmInfo->format;
|
||||
|
@ -164,7 +165,7 @@ private:
|
|||
gfxImageFormat aFormat,
|
||||
SharedMemory::SharedMemoryType aShmType)
|
||||
{
|
||||
if (!gfxASurface::CheckSurfaceSize(aSize))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(aSize))
|
||||
return nullptr;
|
||||
|
||||
Shmem shmem;
|
||||
|
|
|
@ -69,7 +69,7 @@ gfxImageSurface::InitWithData(unsigned char *aData, const IntSize& aSize,
|
|||
mFormat = aFormat;
|
||||
mStride = aStride;
|
||||
|
||||
if (!CheckSurfaceSize(aSize))
|
||||
if (!Factory::CheckSurfaceSize(aSize))
|
||||
MakeInvalid();
|
||||
|
||||
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
|
||||
|
@ -125,7 +125,7 @@ gfxImageSurface::AllocateAndInit(long aStride, int32_t aMinimalAllocation,
|
|||
if (aMinimalAllocation < mSize.height * mStride)
|
||||
aMinimalAllocation = mSize.height * mStride;
|
||||
|
||||
if (!CheckSurfaceSize(mSize))
|
||||
if (!Factory::CheckSurfaceSize(mSize))
|
||||
MakeInvalid();
|
||||
|
||||
// if we have a zero-sized surface, just leave mData nullptr
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/HelpersCairo.h"
|
||||
|
||||
#include "cairo-quartz.h"
|
||||
|
@ -20,7 +21,7 @@ gfxQuartzSurface::gfxQuartzSurface(const mozilla::gfx::IntSize& desiredSize,
|
|||
gfxImageFormat format)
|
||||
: mCGContext(nullptr), mSize(desiredSize)
|
||||
{
|
||||
if (!CheckSurfaceSize(desiredSize))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(desiredSize))
|
||||
MakeInvalid();
|
||||
|
||||
unsigned int width = static_cast<unsigned int>(mSize.width);
|
||||
|
@ -43,7 +44,7 @@ gfxQuartzSurface::gfxQuartzSurface(CGContextRef context,
|
|||
const mozilla::gfx::IntSize& size)
|
||||
: mCGContext(context), mSize(size)
|
||||
{
|
||||
if (!CheckSurfaceSize(size))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(size))
|
||||
MakeInvalid();
|
||||
|
||||
unsigned int width = static_cast<unsigned int>(mSize.width);
|
||||
|
@ -77,7 +78,7 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
|
|||
gfxImageFormat format)
|
||||
: mCGContext(nullptr), mSize(aSize.width, aSize.height)
|
||||
{
|
||||
if (!CheckSurfaceSize(aSize))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(aSize))
|
||||
MakeInvalid();
|
||||
|
||||
cairo_format_t cformat = GfxFormatToCairoFormat(format);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "gfxWindowsSurface.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/HelpersCairo.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
|
||||
|
@ -50,7 +51,7 @@ gfxWindowsSurface::gfxWindowsSurface(const mozilla::gfx::IntSize& realSize, gfxI
|
|||
mOwnsDC(false), mForPrinting(false), mWnd(nullptr)
|
||||
{
|
||||
mozilla::gfx::IntSize size(realSize);
|
||||
if (!CheckSurfaceSize(size))
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(size))
|
||||
MakeInvalid(size);
|
||||
|
||||
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#include "nsTArray.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
||||
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
|
||||
|
@ -37,7 +39,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual,
|
|||
, mGLXPixmap(None)
|
||||
#endif
|
||||
{
|
||||
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
"Bad size");
|
||||
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, size.width, size.height);
|
||||
|
@ -52,7 +54,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
|
|||
, mGLXPixmap(None)
|
||||
#endif
|
||||
{
|
||||
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
"Bad Size");
|
||||
|
||||
cairo_surface_t *surf =
|
||||
|
@ -94,7 +96,7 @@ static Drawable
|
|||
CreatePixmap(Screen *screen, const gfx::IntSize& size, unsigned int depth,
|
||||
Drawable relatedDrawable)
|
||||
{
|
||||
if (!gfxASurface::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT))
|
||||
if (!Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT))
|
||||
return None;
|
||||
|
||||
if (relatedDrawable == None) {
|
||||
|
|
|
@ -852,7 +852,7 @@ nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize,
|
|||
*aResultOverflows = surfaceSize.width != ceil(aSize.width) ||
|
||||
surfaceSize.height != ceil(aSize.height);
|
||||
|
||||
if (!gfxASurface::CheckSurfaceSize(surfaceSize)) {
|
||||
if (!Factory::CheckSurfaceSize(surfaceSize)) {
|
||||
surfaceSize.width = std::min(NS_SVG_OFFSCREEN_MAX_DIMENSION,
|
||||
surfaceSize.width);
|
||||
surfaceSize.height = std::min(NS_SVG_OFFSCREEN_MAX_DIMENSION,
|
||||
|
|
|
@ -60,7 +60,7 @@ class GeneralPattern;
|
|||
|
||||
// maximum dimension of an offscreen surface - choose so that
|
||||
// the surface size doesn't overflow a 32-bit signed int using
|
||||
// 4 bytes per pixel; in line with gfxASurface::CheckSurfaceSize
|
||||
// 4 bytes per pixel; in line with Factory::CheckSurfaceSize
|
||||
// In fact Macs can't even manage that
|
||||
#define NS_SVG_OFFSCREEN_MAX_DIMENSION 4096
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxXlibSurface.h"
|
||||
#include "gfxContext.h"
|
||||
#include "nsImageToPixbuf.h"
|
||||
|
|
|
@ -60,7 +60,6 @@ extern PRLogModuleInfo *gWidgetDrawLog;
|
|||
|
||||
#endif /* MOZ_LOGGING */
|
||||
|
||||
class gfxASurface;
|
||||
class gfxPattern;
|
||||
class nsPluginNativeWindowGtk;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
class nsIWidget;
|
||||
class nsIPrintSettings;
|
||||
class gfxASurface;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx{
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
@class UIWindow;
|
||||
@class UIView;
|
||||
@class ChildView;
|
||||
class gfxASurface;
|
||||
|
||||
class nsWindow :
|
||||
public nsBaseWidget
|
||||
|
|
Загрузка…
Ссылка в новой задаче