2017-10-28 02:10:06 +03:00
|
|
|
/* -*- 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
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2012-05-10 08:31:14 +04:00
|
|
|
|
|
|
|
#ifndef _MOZILLA_GFX_IMAGESCALING_H
|
|
|
|
#define _MOZILLA_GFX_IMAGESCALING_H
|
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "Point.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class ImageHalfScaler {
|
|
|
|
public:
|
2019-05-01 11:47:10 +03:00
|
|
|
ImageHalfScaler(uint8_t* aData, int32_t aStride, const IntSize& aSize)
|
2018-04-13 16:01:28 +03:00
|
|
|
: mOrigData(aData),
|
|
|
|
mOrigStride(aStride),
|
|
|
|
mOrigSize(aSize),
|
2012-08-14 22:06:12 +04:00
|
|
|
mDataStorage(nullptr),
|
2018-06-16 17:42:33 +03:00
|
|
|
mData(nullptr),
|
|
|
|
mStride(0) {}
|
2012-05-10 08:31:14 +04:00
|
|
|
|
|
|
|
~ImageHalfScaler() { delete[] mDataStorage; }
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void ScaleForSize(const IntSize& aSize);
|
2012-05-10 08:31:14 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
uint8_t* GetScaledData() const { return mData; }
|
2012-05-10 08:31:14 +04:00
|
|
|
IntSize GetSize() const { return mSize; }
|
|
|
|
uint32_t GetStride() const { return mStride; }
|
|
|
|
|
|
|
|
private:
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImage2D(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageVertical(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageHorizontal(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
|
|
|
|
|
|
|
// This is our SSE2 scaling function. Our destination must always be 16-byte
|
|
|
|
// aligned and use a 16-byte aligned stride.
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImage2D_SSE2(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageVertical_SSE2(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageHorizontal_SSE2(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImage2D_C(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageVertical_C(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
2019-05-01 11:47:10 +03:00
|
|
|
void HalfImageHorizontal_C(uint8_t* aSource, int32_t aSourceStride,
|
|
|
|
const IntSize& aSourceSize, uint8_t* aDest,
|
2012-05-10 08:31:14 +04:00
|
|
|
uint32_t aDestStride);
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
uint8_t* mOrigData;
|
2012-05-10 08:31:14 +04:00
|
|
|
int32_t mOrigStride;
|
|
|
|
IntSize mOrigSize;
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
uint8_t* mDataStorage;
|
2012-05-10 08:31:14 +04:00
|
|
|
// Guaranteed 16-byte aligned
|
2019-05-01 11:47:10 +03:00
|
|
|
uint8_t* mData;
|
2012-05-10 08:31:14 +04:00
|
|
|
IntSize mSize;
|
|
|
|
// Guaranteed 16-byte aligned
|
|
|
|
uint32_t mStride;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2012-05-10 08:31:14 +04:00
|
|
|
|
|
|
|
#endif
|