2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-28 20:02:39 +00:00
|
|
|
#ifndef SkGrPixelRef_DEFINED
|
|
|
|
#define SkGrPixelRef_DEFINED
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2011-07-07 13:42:37 +00:00
|
|
|
#include "SkBitmap.h"
|
2010-12-22 21:39:39 +00:00
|
|
|
#include "SkPixelRef.h"
|
2011-08-16 15:13:54 +00:00
|
|
|
#include "GrTexture.h"
|
|
|
|
#include "GrRenderTarget.h"
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2011-07-07 13:42:37 +00:00
|
|
|
/**
|
|
|
|
* Common baseclass that implements onLockPixels() by calling onReadPixels().
|
|
|
|
* Since it has a copy, it always returns false for onLockPixelsAreWritable().
|
|
|
|
*/
|
2012-02-08 20:27:16 +00:00
|
|
|
class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
|
2011-07-07 13:42:37 +00:00
|
|
|
public:
|
2013-12-13 19:45:58 +00:00
|
|
|
SkROLockPixelsPixelRef(const SkImageInfo&);
|
2011-07-07 13:42:37 +00:00
|
|
|
virtual ~SkROLockPixelsPixelRef();
|
|
|
|
|
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
bool onNewLockPixels(LockRec*) override;
|
|
|
|
void onUnlockPixels() override;
|
|
|
|
bool onLockPixelsAreWritable() const override; // return false;
|
2011-07-07 13:42:37 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkBitmap fBitmap;
|
|
|
|
typedef SkPixelRef INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-06-28 20:02:39 +00:00
|
|
|
* PixelRef that wraps a GrSurface
|
2011-07-07 13:42:37 +00:00
|
|
|
*/
|
2012-06-28 20:02:39 +00:00
|
|
|
class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef {
|
2010-12-22 21:39:39 +00:00
|
|
|
public:
|
2012-08-28 15:07:11 +00:00
|
|
|
/**
|
2014-10-08 15:40:09 +00:00
|
|
|
* Constructs a pixel ref around a GrSurface.
|
2012-08-28 15:07:11 +00:00
|
|
|
*/
|
2014-10-08 15:40:09 +00:00
|
|
|
SkGrPixelRef(const SkImageInfo&, GrSurface*);
|
2012-06-28 20:02:39 +00:00
|
|
|
virtual ~SkGrPixelRef();
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
// override from SkPixelRef
|
2015-03-26 01:17:31 +00:00
|
|
|
GrTexture* getTexture() override;
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-28 20:02:39 +00:00
|
|
|
// overrides from SkPixelRef
|
2016-01-11 19:14:17 +00:00
|
|
|
bool onReadPixels(SkBitmap* dst, SkColorType, const SkIRect* subset) override;
|
2015-06-15 16:48:15 +00:00
|
|
|
SkPixelRef* deepCopy(SkColorType, SkColorProfileType,
|
|
|
|
const SkIRect* subset) override;
|
|
|
|
void onNotifyPixelsChanged() override;
|
2011-12-02 19:11:17 +00:00
|
|
|
|
2011-04-05 17:08:27 +00:00
|
|
|
private:
|
2012-06-28 20:02:39 +00:00
|
|
|
GrSurface* fSurface;
|
2011-07-07 13:42:37 +00:00
|
|
|
typedef SkROLockPixelsPixelRef INHERITED;
|
2011-04-05 17:08:27 +00:00
|
|
|
};
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
#endif
|