author Mike Hommey <>
Sat, 12 Oct 2013 08:29:46 +0900
changeset 150649 1954202491f15f673717fef76eecaaee762af9db
parent 145758 e0d08a8a1c045db566d3b1a6c6ea9a413fb291cf
child 162898 1e18486ef2ced20749a013cc5b98e1c7c43d6310
permissions -rw-r--r--
Bug 925993 - Ensure clang-plugin is built before everything else; r=gps

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */


#include "2D.h"

namespace mozilla {
namespace gfx {

class DrawTargetCairo;

class SourceSurfaceCairo : public SourceSurface
  // Create a SourceSurfaceCairo. The surface will not be copied, but simply
  // referenced.
  // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
  // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
  // we're destroyed.
  SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
                     const SurfaceFormat& aFormat,
                     DrawTargetCairo* aDrawTarget = nullptr);
  virtual ~SourceSurfaceCairo();

  virtual SurfaceType GetType() const { return SURFACE_CAIRO; }
  virtual IntSize GetSize() const;
  virtual SurfaceFormat GetFormat() const;
  virtual TemporaryRef<DataSourceSurface> GetDataSurface();

  cairo_surface_t* GetSurface() const;

private: // methods
  friend class DrawTargetCairo;
  void DrawTargetWillChange();

private: // data
  IntSize mSize;
  SurfaceFormat mFormat;
  cairo_surface_t* mSurface;
  DrawTargetCairo* mDrawTarget;

class DataSourceSurfaceCairo : public DataSourceSurface
  DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
  virtual ~DataSourceSurfaceCairo();
  virtual unsigned char *GetData();
  virtual int32_t Stride();

  virtual SurfaceType GetType() const { return SURFACE_CAIRO_IMAGE; }
  virtual IntSize GetSize() const;
  virtual SurfaceFormat GetFormat() const;

  cairo_surface_t* GetSurface() const;

  cairo_surface_t* mImageSurface;