Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/2d/ImageScaling.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef _MOZILLA_GFX_IMAGESCALING_H
8
#define _MOZILLA_GFX_IMAGESCALING_H
9
10
#include "Types.h"
11
12
#include <vector>
13
#include "Point.h"
14
15
namespace mozilla {
16
namespace gfx {
17
18
class ImageHalfScaler
19
{
20
public:
21
  ImageHalfScaler(uint8_t *aData, int32_t aStride, const IntSize &aSize)
22
    : mOrigData(aData), mOrigStride(aStride), mOrigSize(aSize)
23
    , mDataStorage(nullptr)
24
    , mData(nullptr)
25
    , mStride(0)
26
0
  {
27
0
  }
28
29
  ~ImageHalfScaler()
30
0
  {
31
0
    delete [] mDataStorage;
32
0
  }
33
34
  void ScaleForSize(const IntSize &aSize);
35
36
0
  uint8_t *GetScaledData() const { return mData; }
37
0
  IntSize GetSize() const { return mSize; }
38
0
  uint32_t GetStride() const { return mStride; }
39
40
private:
41
  void HalfImage2D(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
42
                   uint8_t *aDest, uint32_t aDestStride);
43
  void HalfImageVertical(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
44
                         uint8_t *aDest, uint32_t aDestStride);
45
  void HalfImageHorizontal(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
46
                           uint8_t *aDest, uint32_t aDestStride);
47
48
  // This is our SSE2 scaling function. Our destination must always be 16-byte
49
  // aligned and use a 16-byte aligned stride.
50
  void HalfImage2D_SSE2(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
51
                        uint8_t *aDest, uint32_t aDestStride);
52
  void HalfImageVertical_SSE2(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
53
                              uint8_t *aDest, uint32_t aDestStride);
54
  void HalfImageHorizontal_SSE2(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
55
                                uint8_t *aDest, uint32_t aDestStride);
56
57
  void HalfImage2D_C(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
58
                     uint8_t *aDest, uint32_t aDestStride);
59
  void HalfImageVertical_C(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
60
                           uint8_t *aDest, uint32_t aDestStride);
61
  void HalfImageHorizontal_C(uint8_t *aSource, int32_t aSourceStride, const IntSize &aSourceSize,
62
                             uint8_t *aDest, uint32_t aDestStride);
63
64
  uint8_t *mOrigData;
65
  int32_t mOrigStride;
66
  IntSize mOrigSize;
67
68
  uint8_t *mDataStorage;
69
  // Guaranteed 16-byte aligned
70
  uint8_t *mData;
71
  IntSize mSize;
72
  // Guaranteed 16-byte aligned
73
  uint32_t mStride;
74
};
75
76
} // namespace gfx
77
} // namespace mozilla
78
79
#endif