2011-11-02 19:55:03 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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 http://mozilla.org/MPL/2.0/. */
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_SOURCESURFACESKIA_H_
|
|
|
|
#define MOZILLA_GFX_SOURCESURFACESKIA_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "skia/SkCanvas.h"
|
|
|
|
#include "skia/SkBitmap.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
class DrawTargetSkia;
|
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
class SourceSurfaceSkia : public DataSourceSurface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SourceSurfaceSkia();
|
|
|
|
~SourceSurfaceSkia();
|
|
|
|
|
|
|
|
virtual SurfaceType GetType() const { return SURFACE_SKIA; }
|
|
|
|
virtual IntSize GetSize() const;
|
|
|
|
virtual SurfaceFormat GetFormat() const;
|
|
|
|
|
|
|
|
SkBitmap& GetBitmap() { return mBitmap; }
|
|
|
|
|
|
|
|
bool InitFromData(unsigned char* aData,
|
|
|
|
const IntSize &aSize,
|
|
|
|
int32_t aStride,
|
|
|
|
SurfaceFormat aFormat);
|
|
|
|
|
2013-05-29 16:49:40 +00:00
|
|
|
bool InitFromCanvas(SkCanvas* aCanvas,
|
2011-11-02 19:55:03 +00:00
|
|
|
SurfaceFormat aFormat,
|
|
|
|
DrawTargetSkia* aOwner);
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
virtual unsigned char *GetData();
|
|
|
|
|
|
|
|
virtual int32_t Stride() { return mStride; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetSkia;
|
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
void DrawTargetWillChange();
|
2011-11-18 04:00:38 +00:00
|
|
|
void DrawTargetDestroyed();
|
2011-11-02 19:55:03 +00:00
|
|
|
void MarkIndependent();
|
2013-06-18 16:49:05 +00:00
|
|
|
void MaybeUnlock();
|
2011-11-02 19:55:03 +00:00
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
SkBitmap mBitmap;
|
|
|
|
SurfaceFormat mFormat;
|
|
|
|
IntSize mSize;
|
|
|
|
int32_t mStride;
|
2013-06-29 02:59:19 +00:00
|
|
|
RefPtr<DrawTargetSkia> mDrawTarget;
|
2013-06-18 16:49:05 +00:00
|
|
|
bool mLocked;
|
2011-11-02 19:55:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */
|