Bug 1706464 [wpt PR 28605] - Off-thread CSS paint: handle no-op animation, a=testonly
[gecko.git] / gfx / 2d / ImageScaling.h
blob446b5287c6a932230fc6dcc50d206ecf6cc785d0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _MOZILLA_GFX_IMAGESCALING_H
8 #define _MOZILLA_GFX_IMAGESCALING_H
10 #include "Types.h"
12 #include <vector>
13 #include "Point.h"
15 namespace mozilla {
16 namespace gfx {
18 class ImageHalfScaler {
19 public:
20 ImageHalfScaler(uint8_t* aData, int32_t aStride, const IntSize& aSize)
21 : mOrigData(aData),
22 mOrigStride(aStride),
23 mOrigSize(aSize),
24 mDataStorage(nullptr),
25 mData(nullptr),
26 mStride(0) {}
28 ~ImageHalfScaler() { delete[] mDataStorage; }
30 void ScaleForSize(const IntSize& aSize);
32 uint8_t* GetScaledData() const { return mData; }
33 IntSize GetSize() const { return mSize; }
34 uint32_t GetStride() const { return mStride; }
36 private:
37 void HalfImage2D(uint8_t* aSource, int32_t aSourceStride,
38 const IntSize& aSourceSize, uint8_t* aDest,
39 uint32_t aDestStride);
40 void HalfImageVertical(uint8_t* aSource, int32_t aSourceStride,
41 const IntSize& aSourceSize, uint8_t* aDest,
42 uint32_t aDestStride);
43 void HalfImageHorizontal(uint8_t* aSource, int32_t aSourceStride,
44 const IntSize& aSourceSize, uint8_t* aDest,
45 uint32_t aDestStride);
47 // This is our SSE2 scaling function. Our destination must always be 16-byte
48 // aligned and use a 16-byte aligned stride.
49 void HalfImage2D_SSE2(uint8_t* aSource, int32_t aSourceStride,
50 const IntSize& aSourceSize, uint8_t* aDest,
51 uint32_t aDestStride);
52 void HalfImageVertical_SSE2(uint8_t* aSource, int32_t aSourceStride,
53 const IntSize& aSourceSize, uint8_t* aDest,
54 uint32_t aDestStride);
55 void HalfImageHorizontal_SSE2(uint8_t* aSource, int32_t aSourceStride,
56 const IntSize& aSourceSize, uint8_t* aDest,
57 uint32_t aDestStride);
59 void HalfImage2D_C(uint8_t* aSource, int32_t aSourceStride,
60 const IntSize& aSourceSize, uint8_t* aDest,
61 uint32_t aDestStride);
62 void HalfImageVertical_C(uint8_t* aSource, int32_t aSourceStride,
63 const IntSize& aSourceSize, uint8_t* aDest,
64 uint32_t aDestStride);
65 void HalfImageHorizontal_C(uint8_t* aSource, int32_t aSourceStride,
66 const IntSize& aSourceSize, uint8_t* aDest,
67 uint32_t aDestStride);
69 uint8_t* mOrigData;
70 int32_t mOrigStride;
71 IntSize mOrigSize;
73 uint8_t* mDataStorage;
74 // Guaranteed 16-byte aligned
75 uint8_t* mData;
76 IntSize mSize;
77 // Guaranteed 16-byte aligned
78 uint32_t mStride;
81 } // namespace gfx
82 } // namespace mozilla
84 #endif