2010-12-22 21:39:39 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-28 14:26:00 +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:
|
|
|
|
SkROLockPixelsPixelRef();
|
|
|
|
virtual ~SkROLockPixelsPixelRef();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// override from SkPixelRef
|
|
|
|
virtual void* onLockPixels(SkColorTable** ptr);
|
|
|
|
virtual void onUnlockPixels();
|
|
|
|
virtual bool onLockPixelsAreWritable() const; // return false;
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Constructs a pixel ref around a GrSurface. If the caller has locked the GrSurface in the
|
|
|
|
* cache and would like the pixel ref to unlock it in its destructor then transferCacheLock
|
|
|
|
* should be set to true.
|
|
|
|
*/
|
|
|
|
SkGrPixelRef(GrSurface* surface, bool transferCacheLock = false);
|
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
|
|
|
|
2012-03-28 20:47:01 +00:00
|
|
|
SK_DECLARE_UNFLATTENABLE_OBJECT()
|
|
|
|
|
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;
|
2012-12-07 19:14:45 +00:00
|
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, 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;
|
2012-08-28 15:07:11 +00:00
|
|
|
bool fUnlock; // if true the pixel ref owns a texture cache lock on 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
|