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:
|
2014-01-24 18:33:07 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkROLockPixelsPixelRef)
|
2013-12-13 19:45:58 +00:00
|
|
|
SkROLockPixelsPixelRef(const SkImageInfo&);
|
2011-07-07 13:42:37 +00:00
|
|
|
virtual ~SkROLockPixelsPixelRef();
|
|
|
|
|
|
|
|
protected:
|
2014-01-06 17:08:27 +00:00
|
|
|
virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
|
|
|
|
virtual void onUnlockPixels() SK_OVERRIDE;
|
|
|
|
virtual bool onLockPixelsAreWritable() const SK_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:
|
2014-01-24 18:33:07 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkGrPixelRef)
|
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
|
2013-06-26 19:18:23 +00:00
|
|
|
virtual GrTexture* getTexture() SK_OVERRIDE;
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-28 20:02:39 +00:00
|
|
|
// overrides from SkPixelRef
|
|
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
|
2014-06-11 13:09:50 +00:00
|
|
|
virtual SkPixelRef* deepCopy(SkColorType, const SkIRect* subset) SK_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
|