tor-browser

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

SharedRGBImage.h (1738B)


      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 SHAREDRGBIMAGE_H_
      8 #define SHAREDRGBIMAGE_H_
      9 
     10 #include <stddef.h>  // for size_t
     11 #include <stdint.h>  // for uint8_t
     12 
     13 #include "ImageContainer.h"  // for ISharedImage, Image, etc
     14 #include "gfxTypes.h"
     15 #include "mozilla/RefPtr.h"     // for RefPtr
     16 #include "mozilla/gfx/Point.h"  // for IntSize
     17 #include "mozilla/gfx/Types.h"  // for SurfaceFormat
     18 #include "nsCOMPtr.h"           // for already_AddRefed
     19 
     20 namespace mozilla {
     21 namespace layers {
     22 
     23 class ImageClient;
     24 class TextureClient;
     25 
     26 /**
     27 * Stores RGB data in shared memory
     28 * It is assumed that the image width and stride are equal
     29 */
     30 class SharedRGBImage : public Image {
     31 public:
     32  explicit SharedRGBImage(ImageClient* aCompositable);
     33  explicit SharedRGBImage(TextureClientRecycleAllocator* aRecycleAllocator);
     34 
     35 protected:
     36  virtual ~SharedRGBImage();
     37 
     38 public:
     39  TextureClient* GetTextureClient(KnowsCompositor* aKnowsCompositor) override;
     40 
     41  gfx::IntSize GetSize() const override;
     42 
     43  already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
     44 
     45  bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
     46 
     47 private:
     48  TextureClientRecycleAllocator* RecycleAllocator();
     49 
     50  gfx::IntSize mSize;
     51  RefPtr<TextureClient> mTextureClient;
     52  RefPtr<ImageClient> mCompositable;
     53  RefPtr<TextureClientRecycleAllocator> mRecycleAllocator;
     54  RefPtr<gfx::SourceSurface> mSourceSurface;
     55 };
     56 
     57 }  // namespace layers
     58 }  // namespace mozilla
     59 
     60 #endif