Backed out 2 changesets (bug 1299164) for win vm bc4 bustage a=backout

Backed out changeset 53dc795121e1 (bug 1299164)
Backed out changeset c39ec15e7e21 (bug 1299164)
This commit is contained in:
Wes Kocher 2016-09-02 11:38:22 -07:00
Родитель cf040c01ca
Коммит 647b0985cc
17 изменённых файлов: 32 добавлений и 135 удалений

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

@ -369,10 +369,6 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
// get image bytes
nsresult rv;
if (aImageBuffer) {
if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
return NS_ERROR_INVALID_ARG;
}
rv = ImageEncoder::GetInputStream(
aSize.width,
aSize.height,
@ -421,10 +417,6 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
imgIEncoder::INPUT_FORMAT_HOSTARGB,
aOptions);
} else {
if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
return NS_ERROR_INVALID_ARG;
}
RefPtr<gfx::DataSourceSurface> dataSurface;
RefPtr<layers::Image> image(aImage);
dataSurface = GetBRGADataSourceSurfaceSync(image.forget());
@ -447,10 +439,12 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
imgStream = do_QueryInterface(aEncoder);
}
} else {
if (BufferSizeFromDimensions(aSize.width, aSize.height, 4) == 0) {
CheckedInt32 requiredBytes = CheckedInt32(aSize.width) * CheckedInt32(aSize.height) * 4;
if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
return NS_ERROR_INVALID_ARG;
}
// no context, so we have to encode an empty image
// note that if we didn't have a current context, the spec says we're
// supposed to just return transparent black pixels of the canvas

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

@ -5243,13 +5243,8 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
matrix._22, matrix._31, matrix._32));
} else {
IntSize dtSize = IntSize::Ceil(sw, sh);
if (!Factory::AllowedSurfaceSize(dtSize)) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
drawDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(dtSize,
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize::Ceil(sw, sh),
SurfaceFormat::B8G8R8A8);
if (!drawDT || !drawDT->IsValid()) {
aError.Throw(NS_ERROR_FAILURE);
@ -5275,12 +5270,6 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
return;
}
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
if (!data || !Factory::AllowedSurfaceSize(data->GetSize())) {
gfxCriticalError() << "Unexpected invalid data source surface " <<
(data ? data->GetSize() : IntSize(0,0));
aError.Throw(NS_ERROR_FAILURE);
return;
}
DataSourceSurface::MappedSurface rawData;
if (NS_WARN_IF(!data->Map(DataSourceSurface::READ, &rawData))) {

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

@ -109,8 +109,7 @@ ImageBitmapRenderingContext::MatchWithIntrinsicSize()
temp->GetSize(),
map.GetStride(),
temp->GetFormat());
if (!dt || !dt->IsValid()) {
gfxWarning() << "ImageBitmapRenderingContext::MatchWithIntrinsicSize failed";
if (!dt) {
return nullptr;
}

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

@ -3786,13 +3786,9 @@ PluginInstanceChild::PaintRectToSurface(const nsIntRect& aRect,
// Copy helper surface content to target
dt = CreateDrawTargetForSurface(aSurface);
}
if (dt && dt->IsValid()) {
RefPtr<SourceSurface> surface =
gfxPlatform::GetSourceSurfaceForSurface(dt, renderSurface);
dt->CopySurface(surface, aRect, aRect.TopLeft());
} else {
gfxWarning() << "PluginInstanceChild::PaintRectToSurface failure";
}
RefPtr<SourceSurface> surface =
gfxPlatform::GetSourceSurfaceForSurface(dt, renderSurface);
dt->CopySurface(surface, aRect, aRect.TopLeft());
}
}

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

@ -265,7 +265,7 @@ BufferSizeFromStrideAndHeight(int32_t aStride,
int32_t aHeight,
int32_t aExtraBytes)
{
if (MOZ_UNLIKELY(aHeight <= 0) || MOZ_UNLIKELY(aStride <= 0)) {
if (MOZ_UNLIKELY(aHeight <= 0)) {
return 0;
}
@ -279,29 +279,7 @@ BufferSizeFromStrideAndHeight(int32_t aStride,
CheckedInt32 requiredBytes =
CheckedInt32(aStride) * CheckedInt32(aHeight) + CheckedInt32(aExtraBytes);
if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
gfxWarning() << "Buffer size too big; returning zero " << aStride << ", " << aHeight << ", " << aExtraBytes;
return 0;
}
return requiredBytes.value();
}
size_t
BufferSizeFromDimensions(int32_t aWidth,
int32_t aHeight,
int32_t aDepth,
int32_t aExtraBytes)
{
if (MOZ_UNLIKELY(aHeight <= 0) ||
MOZ_UNLIKELY(aWidth <= 0) ||
MOZ_UNLIKELY(aDepth <= 0)) {
return 0;
}
// Similar to BufferSizeFromStrideAndHeight, but with an extra parameter.
CheckedInt32 requiredBytes = CheckedInt32(aWidth) * CheckedInt32(aHeight) * CheckedInt32(aDepth) + CheckedInt32(aExtraBytes);
if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
gfxWarning() << "Buffer size too big; returning zero " << aWidth << ", " << aHeight << ", " << aDepth << ", " << aExtraBytes;
gfxWarning() << "Buffer size too big; returning zero";
return 0;
}
return requiredBytes.value();

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

@ -92,22 +92,6 @@ BufferSizeFromStrideAndHeight(int32_t aStride,
int32_t aHeight,
int32_t aExtraBytes = 0);
/**
* Multiplies aWidth, aHeight, aDepth and makes sure the result is limited to
* something sane. To keep things consistent, this should always be used
* wherever we allocate a buffer based on surface dimensions.
*
* @param aExtra Optional argument to specify an additional number of trailing
* bytes (useful for creating intermediate surfaces for filters, for
* example).
*
* @return The result of the multiplication if it is acceptable, or else zero.
*/
size_t
BufferSizeFromDimensions(int32_t aWidth,
int32_t aHeight,
int32_t aDepth,
int32_t aExtraBytes = 0);
/**
* Copy aSrcRect from aSrc to aDest starting at aDestPoint.
* @returns false if the copy is not successful or the aSrc's size is empty.

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

@ -735,11 +735,6 @@ Factory::PurgeAllCaches()
already_AddRefed<DrawTarget>
Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
if (!AllowedSurfaceSize(aSize)) {
gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size (Cairo) " << aSize;
return nullptr;
}
RefPtr<DrawTarget> retVal;
#ifdef USE_CAIRO
@ -775,11 +770,6 @@ Factory::CreateSourceSurfaceForCairoSurface(cairo_surface_t* aSurface, const Int
already_AddRefed<DrawTarget>
Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize)
{
if (!AllowedSurfaceSize(aSize)) {
gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "Failed to allocate a surface due to invalid size (CG) " << aSize;
return nullptr;
}
RefPtr<DrawTarget> retVal;
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
@ -809,7 +799,7 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData,
SourceSurfaceDeallocator aDeallocator /* = nullptr */,
void* aClosure /* = nullptr */)
{
if (!AllowedSurfaceSize(aSize) || aStride <= 0) {
if (aSize.width <= 0 || aSize.height <= 0) {
return nullptr;
}
if (!aDeallocator && aClosure) {
@ -853,8 +843,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
int32_t aStride,
bool aZero)
{
if (!AllowedSurfaceSize(aSize) ||
aStride < aSize.width * BytesPerPixel(aFormat)) {
if (aStride < aSize.width * BytesPerPixel(aFormat)) {
gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) << "CreateDataSourceSurfaceWithStride failed with bad stride " << aStride << ", " << aSize << ", " << aFormat;
return nullptr;
}

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

@ -65,20 +65,20 @@ ImageHalfScaler::ScaleForSize(const IntSize &aSize)
return;
}
delete [] mDataStorage;
IntSize internalSurfSize;
internalSurfSize.width = max(scaleSize.width, mOrigSize.width / 2);
internalSurfSize.height = max(scaleSize.height, mOrigSize.height / 2);
size_t bufLen = 0;
mStride = GetAlignedStride<16>(internalSurfSize.width, 4);
if (mStride > 0) {
// Allocate 15 bytes extra to make sure we can get 16 byte alignment. We
// should add tools for this, see bug 751696.
bufLen = BufferSizeFromStrideAndHeight(mStride, internalSurfSize.height, 15);
mStride = internalSurfSize.width * 4;
if (mStride % 16) {
mStride += 16 - (mStride % 16);
}
delete [] mDataStorage;
// Allocate 15 bytes extra to make sure we can get 16 byte alignment. We
// should add tools for this, see bug 751696.
size_t bufLen = BufferSizeFromStrideAndHeight(mStride, internalSurfSize.height, 15);
if (bufLen == 0) {
mSize.SizeTo(0, 0);
mDataStorage = nullptr;

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

@ -80,8 +80,7 @@ private:
friend class Factory;
// If we have a custom deallocator, the |aData| will be released using the
// custom deallocator and |aClosure| in dtor. The assumption is that the
// caller will check for valid size and stride before making this call.
// custom deallocator and |aClosure| in dtor.
void InitWrappingData(unsigned char *aData,
const IntSize &aSize,
int32_t aStride,

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

@ -5,7 +5,6 @@
#include "TextureDIB.h"
#include "gfx2DGlue.h"
#include "mozilla/gfx/DataSurfaceHelpers.h" // For BufferSizeFromDimensions
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/ipc/ProtocolUtils.h"
@ -434,7 +433,7 @@ DIBTextureHost::UpdatedInternal(const nsIntRegion* aRegion)
RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(imgSurf->Data(), imgSurf->Stride(), mSize, mFormat);
if (!surf || !mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
mTextureSource = nullptr;
}
@ -474,20 +473,14 @@ TextureHostFileMapping::UpdatedInternal(const nsIntRegion* aRegion)
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
}
uint8_t* data = nullptr;
int32_t totalBytes = BufferSizeFromDimensions(mSize.width, mSize.height, BytesPerPixel(mFormat));
if (totalBytes > 0) {
data = (uint8_t*)::MapViewOfFile(mFileMapping, FILE_MAP_READ, 0, 0, totalBytes);
}
uint8_t* data = (uint8_t*)::MapViewOfFile(mFileMapping, FILE_MAP_READ, 0, 0, mSize.width * mSize.height * BytesPerPixel(mFormat));
if (data) {
RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(data, mSize.width * BytesPerPixel(mFormat), mSize, mFormat);
if (surf) {
surf->AddUserData(&kFileMappingKey, data, UnmapFileData);
if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
mTextureSource = nullptr;
}
} else {
surf->AddUserData(&kFileMappingKey, data, UnmapFileData);
if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
mTextureSource = nullptr;
}
} else {

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

@ -140,13 +140,9 @@ GrallocTextureHostBasic::Lock()
mCropSize,
mFormat);
}
if (surf) {
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
mTextureSource->Update(surf, nullptr);
return true;
}
mMappedBuffer = nullptr;
return false;
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
mTextureSource->Update(surf, nullptr);
return true;
}
bool

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

@ -89,9 +89,7 @@ CanvasLayerComposite::RenderLayer(const IntRect& aClipRect)
#ifdef MOZ_DUMP_PAINTING
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = mCompositableHost->GetAsSurface();
if (surf) {
WriteSnapshotToDumpFile(this, surf);
}
WriteSnapshotToDumpFile(this, surf);
}
#endif

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

@ -99,9 +99,7 @@ ImageLayerComposite::RenderLayer(const IntRect& aClipRect)
#ifdef MOZ_DUMP_PAINTING
if (gfxEnv::DumpCompositorTextures()) {
RefPtr<gfx::DataSourceSurface> surf = mImageHost->GetAsSurface();
if (surf) {
WriteSnapshotToDumpFile(this, surf);
}
WriteSnapshotToDumpFile(this, surf);
}
#endif

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

@ -123,10 +123,6 @@ already_AddRefed<gfxASurface>
gfxAndroidPlatform::CreateOffscreenSurface(const IntSize& aSize,
gfxImageFormat aFormat)
{
if (!Factory::AllowedSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<gfxASurface> newSurface;
newSurface = new gfxImageSurface(aSize, aFormat);

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

@ -142,10 +142,6 @@ already_AddRefed<gfxASurface>
gfxPlatformGtk::CreateOffscreenSurface(const IntSize& aSize,
gfxImageFormat aFormat)
{
if (!Factory::AllowedSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<gfxASurface> newSurface;
bool needsClear = true;
#ifdef MOZ_X11

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

@ -116,10 +116,6 @@ already_AddRefed<gfxASurface>
gfxPlatformMac::CreateOffscreenSurface(const IntSize& aSize,
gfxImageFormat aFormat)
{
if (!Factory::AllowedSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<gfxASurface> newSurface =
new gfxQuartzSurface(aSize, aFormat);
return newSurface.forget();

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

@ -585,10 +585,6 @@ already_AddRefed<gfxASurface>
gfxWindowsPlatform::CreateOffscreenSurface(const IntSize& aSize,
gfxImageFormat aFormat)
{
if (!Factory::AllowedSurfaceSize(aSize)) {
return nullptr;
}
RefPtr<gfxASurface> surf = nullptr;
#ifdef CAIRO_HAS_WIN32_SURFACE