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>
|
2015-07-29 20:31:40 +00:00
|
|
|
#include "skia/include/core/SkCanvas.h"
|
2016-10-25 02:40:59 +00:00
|
|
|
#include "skia/include/core/SkImage.h"
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-11-11 20:14:00 +00:00
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
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:
|
2014-02-24 13:23:37 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia)
|
2011-11-02 19:55:03 +00:00
|
|
|
SourceSurfaceSkia();
|
|
|
|
~SourceSurfaceSkia();
|
|
|
|
|
2014-01-10 18:55:24 +00:00
|
|
|
virtual SurfaceType GetType() const { return SurfaceType::SKIA; }
|
2011-11-02 19:55:03 +00:00
|
|
|
virtual IntSize GetSize() const;
|
|
|
|
virtual SurfaceFormat GetFormat() const;
|
|
|
|
|
2016-10-25 02:40:59 +00:00
|
|
|
sk_sp<SkImage>& GetImage() { return mImage; }
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
bool InitFromData(unsigned char* aData,
|
|
|
|
const IntSize &aSize,
|
|
|
|
int32_t aStride,
|
|
|
|
SurfaceFormat aFormat);
|
|
|
|
|
2016-11-14 22:16:18 +00:00
|
|
|
bool InitFromImage(const sk_sp<SkImage>& aImage,
|
2016-10-25 02:40:59 +00:00
|
|
|
SurfaceFormat aFormat = SurfaceFormat::UNKNOWN,
|
|
|
|
DrawTargetSkia* aOwner = nullptr);
|
2011-11-02 19:55:03 +00:00
|
|
|
|
2016-10-25 02:40:59 +00:00
|
|
|
virtual uint8_t* GetData();
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
virtual int32_t Stride() { return mStride; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetSkia;
|
2015-05-26 07:00:19 +00:00
|
|
|
|
2011-11-02 19:55:03 +00:00
|
|
|
void DrawTargetWillChange();
|
|
|
|
|
2016-10-25 02:40:59 +00:00
|
|
|
sk_sp<SkImage> mImage;
|
2011-11-02 19:55:03 +00:00
|
|
|
SurfaceFormat mFormat;
|
|
|
|
IntSize mSize;
|
|
|
|
int32_t mStride;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DrawTargetSkia> mDrawTarget;
|
2011-11-02 19:55:03 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2011-11-02 19:55:03 +00:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */
|