michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_SOURCESURFACESKIA_H_ michael@0: #define MOZILLA_GFX_SOURCESURFACESKIA_H_ michael@0: michael@0: #include "2D.h" michael@0: #include michael@0: #include "skia/SkCanvas.h" michael@0: #include "skia/SkBitmap.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class DrawTargetSkia; michael@0: michael@0: class SourceSurfaceSkia : public DataSourceSurface michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia) michael@0: SourceSurfaceSkia(); michael@0: ~SourceSurfaceSkia(); michael@0: michael@0: virtual SurfaceType GetType() const { return SurfaceType::SKIA; } michael@0: virtual IntSize GetSize() const; michael@0: virtual SurfaceFormat GetFormat() const; michael@0: michael@0: SkBitmap& GetBitmap() { return mBitmap; } michael@0: michael@0: bool InitFromData(unsigned char* aData, michael@0: const IntSize &aSize, michael@0: int32_t aStride, michael@0: SurfaceFormat aFormat); michael@0: michael@0: bool InitFromCanvas(SkCanvas* aCanvas, michael@0: SurfaceFormat aFormat, michael@0: DrawTargetSkia* aOwner); michael@0: michael@0: virtual unsigned char *GetData(); michael@0: michael@0: virtual int32_t Stride() { return mStride; } michael@0: michael@0: private: michael@0: friend class DrawTargetSkia; michael@0: michael@0: void DrawTargetWillChange(); michael@0: void MaybeUnlock(); michael@0: michael@0: SkBitmap mBitmap; michael@0: SurfaceFormat mFormat; michael@0: IntSize mSize; michael@0: int32_t mStride; michael@0: RefPtr mDrawTarget; michael@0: bool mLocked; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */