gfx/2d/SourceSurfaceCairo.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/SourceSurfaceCairo.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
    1.10 +#define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
    1.11 +
    1.12 +#include "2D.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +namespace gfx {
    1.16 +
    1.17 +class DrawTargetCairo;
    1.18 +
    1.19 +class SourceSurfaceCairo : public SourceSurface
    1.20 +{
    1.21 +public:
    1.22 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo)
    1.23 +  // Create a SourceSurfaceCairo. The surface will not be copied, but simply
    1.24 +  // referenced.
    1.25 +  // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
    1.26 +  // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
    1.27 +  // we're destroyed.
    1.28 +  SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
    1.29 +                     const SurfaceFormat& aFormat,
    1.30 +                     DrawTargetCairo* aDrawTarget = nullptr);
    1.31 +  virtual ~SourceSurfaceCairo();
    1.32 +
    1.33 +  virtual SurfaceType GetType() const { return SurfaceType::CAIRO; }
    1.34 +  virtual IntSize GetSize() const;
    1.35 +  virtual SurfaceFormat GetFormat() const;
    1.36 +  virtual TemporaryRef<DataSourceSurface> GetDataSurface();
    1.37 +
    1.38 +  cairo_surface_t* GetSurface() const;
    1.39 +
    1.40 +private: // methods
    1.41 +  friend class DrawTargetCairo;
    1.42 +  void DrawTargetWillChange();
    1.43 +
    1.44 +private: // data
    1.45 +  IntSize mSize;
    1.46 +  SurfaceFormat mFormat;
    1.47 +  cairo_surface_t* mSurface;
    1.48 +  DrawTargetCairo* mDrawTarget;
    1.49 +};
    1.50 +
    1.51 +class DataSourceSurfaceCairo : public DataSourceSurface
    1.52 +{
    1.53 +public:
    1.54 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo)
    1.55 +  DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
    1.56 +  virtual ~DataSourceSurfaceCairo();
    1.57 +  virtual unsigned char *GetData();
    1.58 +  virtual int32_t Stride();
    1.59 +
    1.60 +  virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; }
    1.61 +  virtual IntSize GetSize() const;
    1.62 +  virtual SurfaceFormat GetFormat() const;
    1.63 +
    1.64 +  cairo_surface_t* GetSurface() const;
    1.65 +
    1.66 +private:
    1.67 +  cairo_surface_t* mImageSurface;
    1.68 +};
    1.69 +
    1.70 +}
    1.71 +}
    1.72 +
    1.73 +#endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H

mercurial