tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ConvolutionFilter.h (1631B)


      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_CONVOLUTION_FILTER_H_
      8 #define MOZILLA_GFX_CONVOLUTION_FILTER_H_
      9 
     10 #include "mozilla/UniquePtr.h"
     11 #include "Types.h"
     12 
     13 namespace skia {
     14 class SkConvolutionFilter1D;
     15 }
     16 
     17 namespace mozilla {
     18 namespace gfx {
     19 
     20 class ConvolutionFilter final {
     21 public:
     22  ConvolutionFilter();
     23  ~ConvolutionFilter();
     24 
     25  int32_t MaxFilter() const;
     26  int32_t NumValues() const;
     27 
     28  bool GetFilterOffsetAndLength(int32_t aRowIndex, int32_t* aResultOffset,
     29                                int32_t* aResultLength);
     30 
     31  void ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
     32                            SurfaceFormat aFormat);
     33  void ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
     34                          int32_t aRowIndex, int32_t aRowSize,
     35                          SurfaceFormat aFormat);
     36 
     37  enum class ResizeMethod { BOX, LANCZOS3 };
     38 
     39  bool ComputeResizeFilter(ResizeMethod aResizeMethod, int32_t aSrcSize,
     40                           int32_t aDstSize);
     41 
     42  static inline size_t PadBytesForSIMD(size_t aBytes) {
     43    return (aBytes + 31) & ~31;
     44  }
     45 
     46  const skia::SkConvolutionFilter1D& GetSkiaFilter() const {
     47    return *mFilter.get();
     48  }
     49 
     50 private:
     51  UniquePtr<skia::SkConvolutionFilter1D> mFilter;
     52 };
     53 
     54 }  // namespace gfx
     55 }  // namespace mozilla
     56 
     57 #endif /* MOZILLA_GFX_CONVOLUTION_FILTER_H_ */