tor-browser

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

gmp-video-plane.h (3673B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* Copyright (c) 2011, The WebRTC project authors. All rights reserved.
      3 * Copyright (c) 2014, Mozilla
      4 *
      5 * Redistribution and use in source and binary forms, with or without
      6 * modification, are permitted provided that the following conditions are
      7 * met:
      8 *
      9 ** Redistributions of source code must retain the above copyright
     10 *  notice, this list of conditions and the following disclaimer.
     11 *
     12 ** Redistributions in binary form must reproduce the above copyright
     13 *  notice, this list of conditions and the following disclaimer in
     14 *  the documentation and/or other materials provided with the
     15 *  distribution.
     16 *
     17 ** Neither the name of Google nor the names of its contributors may
     18 *  be used to endorse or promote products derived from this software
     19 *  without specific prior written permission.
     20 *
     21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 */
     33 
     34 #ifndef GMP_VIDEO_PLANE_h_
     35 #define GMP_VIDEO_PLANE_h_
     36 
     37 #include <stdint.h>
     38 
     39 #include "gmp-errors.h"
     40 
     41 // The implementation backing this interface uses shared memory for the
     42 // buffer(s). This means it can only be used by the "owning" process.
     43 // At first the process which created the object owns it. When the object
     44 // is passed to an interface the creator loses ownership and must Destroy()
     45 // the object. Further attempts to use it may fail due to not being able to
     46 // access the underlying buffer(s).
     47 //
     48 // Methods that create or destroy shared memory must be called on the main
     49 // thread. They are marked below.
     50 class GMPPlane {
     51 public:
     52  // MAIN THREAD ONLY
     53  // CreateEmptyPlane - set allocated size, actual plane size and stride:
     54  // If current size is smaller than current size, then a buffer of sufficient
     55  // size will be allocated.
     56  virtual GMPErr CreateEmptyPlane(int32_t aAllocatedSize, int32_t aStride,
     57                                  int32_t aPlaneSize) = 0;
     58 
     59  // MAIN THREAD ONLY
     60  // Copy the entire plane data.
     61  virtual GMPErr Copy(const GMPPlane& aPlane) = 0;
     62 
     63  // MAIN THREAD ONLY
     64  // Copy buffer: If current size is smaller
     65  // than current size, then a buffer of sufficient size will be allocated.
     66  virtual GMPErr Copy(int32_t aSize, int32_t aStride,
     67                      const uint8_t* aBuffer) = 0;
     68 
     69  // Swap plane data.
     70  virtual void Swap(GMPPlane& aPlane) = 0;
     71 
     72  // Get allocated size.
     73  virtual int32_t AllocatedSize() const = 0;
     74 
     75  // Set actual size.
     76  virtual void ResetSize() = 0;
     77 
     78  // Return true is plane size is zero, false if not.
     79  virtual bool IsZeroSize() const = 0;
     80 
     81  // Get stride value.
     82  virtual int32_t Stride() const = 0;
     83 
     84  // Return data pointer.
     85  virtual const uint8_t* Buffer() const = 0;
     86 
     87  // Overloading with non-const.
     88  virtual uint8_t* Buffer() = 0;
     89 
     90  // MAIN THREAD ONLY IF OWNING PROCESS
     91  // Call this when done with the object. This may delete it.
     92  virtual void Destroy() = 0;
     93 };
     94 
     95 #endif  // GMP_VIDEO_PLANE_h_