/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"SurfacePipe.h"
#include <algorithm> // for min
#include"Decoder.h"
namespace mozilla { namespace image {
usingnamespace gfx;
using std::min;
Maybe<SurfaceInvalidRect> AbstractSurfaceSink::TakeInvalidRect() { if (mInvalidRect.IsEmpty()) { return Nothing();
}
// If we're vertically flipping the output, we need to flip the invalid rect. // Since we're dealing with an axis-aligned rect, only the y coordinate needs // to change.
int32_t invalidY = mFlipVertically ? InputSize().height - (mRow + 1) : mRow;
mInvalidRect.UnionRect(mInvalidRect,
OrientedIntRect(0, invalidY, InputSize().width, 1));
// Allocate the frame. // XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want // to allocate the frame directly here and get rid of Decoder::AllocateFrame // altogether.
nsresult rv = aConfig.mDecoder->AllocateFrame(surfaceSize, aConfig.mFormat,
aConfig.mAnimParams); if (NS_FAILED(rv)) { return rv;
}
uint8_t* SurfaceSink::GetRowPointer() const { // If we're flipping vertically, reverse the order in which we traverse the // rows.
uint32_t row = mFlipVertically ? InputSize().height - (mRow + 1) : mRow;
// Allocate the frame. // XXX(seth): Once every Decoder subclass uses SurfacePipe, we probably want // to allocate the frame directly here and get rid of Decoder::AllocateFrame // altogether.
nsresult rv =
aConfig.mDecoder->AllocateFrame(mSurfaceSize, aConfig.mFormat, Nothing()); if (NS_FAILED(rv)) { return rv;
}
// The filters above us need the unoriented size as the input. auto inputSize =
aConfig.mOrientation.ToUnoriented(aConfig.mOutputSize).ToUnknownSize();
mBuffer.reset(new (fallible) uint8_t[inputSize.width * sizeof(uint32_t)]); if (MOZ_UNLIKELY(!mBuffer)) { return NS_ERROR_OUT_OF_MEMORY;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.