gfx/2d/SourceSurfaceSkia.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/SourceSurfaceSkia.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     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_SOURCESURFACESKIA_H_
    1.10 +#define MOZILLA_GFX_SOURCESURFACESKIA_H_
    1.11 +
    1.12 +#include "2D.h"
    1.13 +#include <vector>
    1.14 +#include "skia/SkCanvas.h"
    1.15 +#include "skia/SkBitmap.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace gfx {
    1.19 +
    1.20 +class DrawTargetSkia;
    1.21 +
    1.22 +class SourceSurfaceSkia : public DataSourceSurface
    1.23 +{
    1.24 +public:
    1.25 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia)
    1.26 +  SourceSurfaceSkia();
    1.27 +  ~SourceSurfaceSkia();
    1.28 +
    1.29 +  virtual SurfaceType GetType() const { return SurfaceType::SKIA; }
    1.30 +  virtual IntSize GetSize() const;
    1.31 +  virtual SurfaceFormat GetFormat() const;
    1.32 +
    1.33 +  SkBitmap& GetBitmap() { return mBitmap; }
    1.34 +
    1.35 +  bool InitFromData(unsigned char* aData,
    1.36 +                    const IntSize &aSize,
    1.37 +                    int32_t aStride,
    1.38 +                    SurfaceFormat aFormat);
    1.39 +
    1.40 +  bool InitFromCanvas(SkCanvas* aCanvas,
    1.41 +                      SurfaceFormat aFormat,
    1.42 +                      DrawTargetSkia* aOwner);
    1.43 +
    1.44 +  virtual unsigned char *GetData();
    1.45 +
    1.46 +  virtual int32_t Stride() { return mStride; }
    1.47 +
    1.48 +private:
    1.49 +  friend class DrawTargetSkia;
    1.50 +
    1.51 +  void DrawTargetWillChange();
    1.52 +  void MaybeUnlock();
    1.53 +
    1.54 +  SkBitmap mBitmap;
    1.55 +  SurfaceFormat mFormat;
    1.56 +  IntSize mSize;
    1.57 +  int32_t mStride;
    1.58 +  RefPtr<DrawTargetSkia> mDrawTarget;
    1.59 +  bool mLocked;
    1.60 +};
    1.61 +
    1.62 +}
    1.63 +}
    1.64 +
    1.65 +#endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */

mercurial