2011-11-02 23:55:03 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04: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 23:55:03 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_SOURCESURFACESKIA_H_
|
|
|
|
#define MOZILLA_GFX_SOURCESURFACESKIA_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include <vector>
|
2015-07-29 23:31:40 +03:00
|
|
|
#include "skia/include/core/SkCanvas.h"
|
|
|
|
#include "skia/include/core/SkBitmap.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-11-11 23:14:00 +03:00
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
namespace gfx {
|
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
class DrawTargetSkia;
|
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
class SourceSurfaceSkia : public DataSourceSurface
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceSkia)
|
2011-11-02 23:55:03 +04:00
|
|
|
SourceSurfaceSkia();
|
|
|
|
~SourceSurfaceSkia();
|
|
|
|
|
2014-01-10 22:55:24 +04:00
|
|
|
virtual SurfaceType GetType() const { return SurfaceType::SKIA; }
|
2011-11-02 23:55:03 +04:00
|
|
|
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 20:49:40 +04:00
|
|
|
bool InitFromCanvas(SkCanvas* aCanvas,
|
2015-05-26 10:00:19 +03:00
|
|
|
SurfaceFormat aFormat,
|
|
|
|
DrawTargetSkia* aOwner);
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2016-02-03 21:49:36 +03:00
|
|
|
void InitFromBitmap(const SkBitmap& aBitmap);
|
|
|
|
|
2016-01-21 17:51:40 +03:00
|
|
|
#ifdef USE_SKIA_GPU
|
2014-11-11 23:14:00 +03:00
|
|
|
/**
|
|
|
|
* NOTE: While wrapping a Texture for SkiaGL, the texture *must* be created
|
|
|
|
* with the same GLcontext of DrawTargetSkia
|
|
|
|
*/
|
2016-01-21 17:51:40 +03:00
|
|
|
bool InitFromGrTexture(GrTexture* aTexture,
|
|
|
|
const IntSize &aSize,
|
|
|
|
SurfaceFormat aFormat);
|
|
|
|
#endif
|
2014-11-11 23:14:00 +03:00
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
virtual unsigned char *GetData();
|
|
|
|
|
|
|
|
virtual int32_t Stride() { return mStride; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetSkia;
|
2015-05-26 10:00:19 +03:00
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
void DrawTargetWillChange();
|
2013-06-18 20:49:05 +04:00
|
|
|
void MaybeUnlock();
|
2011-11-02 23:55:03 +04:00
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
SkBitmap mBitmap;
|
|
|
|
SurfaceFormat mFormat;
|
|
|
|
IntSize mSize;
|
|
|
|
int32_t mStride;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTargetSkia> mDrawTarget;
|
2013-06-18 20:49:05 +04:00
|
|
|
bool mLocked;
|
2011-11-02 23:55:03 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2011-11-02 23:55:03 +04:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */
|