tor-browser

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

ImageConversion.h (2039B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef ImageToI420Converter_h
      7 #define ImageToI420Converter_h
      8 
      9 #include "mozilla/AlreadyAddRefed.h"
     10 #include "mozilla/gfx/Point.h"
     11 #include "nsError.h"
     12 
     13 namespace mozilla {
     14 
     15 namespace gfx {
     16 class SourceSurface;
     17 enum class SurfaceFormat : int8_t;
     18 }  // namespace gfx
     19 
     20 namespace layers {
     21 class Image;
     22 }  // namespace layers
     23 
     24 /**
     25 * Gets a SourceSurface from given image.
     26 */
     27 already_AddRefed<gfx::SourceSurface> GetSourceSurface(layers::Image* aImage);
     28 
     29 /**
     30 * Converts aImage to an I420 image and writes it to the given buffers.
     31 */
     32 nsresult ConvertToI420(layers::Image* aImage, uint8_t* aDestY, int aDestStrideY,
     33                       uint8_t* aDestU, int aDestStrideU, uint8_t* aDestV,
     34                       int aDestStrideV, const gfx::IntSize& aDestSize);
     35 
     36 /**
     37 * Converts aImage to an NV12 image and writes it to the given buffers.
     38 */
     39 nsresult ConvertToNV12(layers::Image* aImage, uint8_t* aDestY, int aDestStrideY,
     40                       uint8_t* aDestUV, int aDestStrideUV,
     41                       gfx::IntSize aDestSize);
     42 
     43 /**
     44 * Converts aImage into an RGBA image in a specified format and writes it to the
     45 * given buffer.
     46 */
     47 nsresult ConvertToRGBA(layers::Image* aImage,
     48                       const gfx::SurfaceFormat& aDestFormat,
     49                       uint8_t* aDestBuffer, int aDestStride);
     50 
     51 /*
     52 * Convert the RGBA image data from SRGB color into DisplayP3 color.
     53 * aSrcBuffer and aDestBuffer can be the same.
     54 */
     55 nsresult ConvertSRGBBufferToDisplayP3(uint8_t* aSrcBuffer,
     56                                      const gfx::SurfaceFormat& aSrcFormat,
     57                                      uint8_t* aDestBuffer, int aWidth,
     58                                      int aHeight);
     59 
     60 }  // namespace mozilla
     61 
     62 #endif /* ImageToI420Converter_h */