2010-12-23 00:39:39 +03:00
|
|
|
|
2011-07-28 18:26:00 +04: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-23 00:39:39 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-28 18:26:00 +04:00
|
|
|
|
2012-06-29 00:02:39 +04:00
|
|
|
#ifndef SkGrPixelRef_DEFINED
|
|
|
|
#define SkGrPixelRef_DEFINED
|
2010-12-23 00:39:39 +03:00
|
|
|
|
2011-07-07 17:42:37 +04:00
|
|
|
#include "SkBitmap.h"
|
2010-12-23 00:39:39 +03:00
|
|
|
#include "SkPixelRef.h"
|
2011-08-16 19:13:54 +04:00
|
|
|
#include "GrTexture.h"
|
|
|
|
#include "GrRenderTarget.h"
|
|
|
|
|
2010-12-23 00:39:39 +03:00
|
|
|
|
2011-07-07 17:42:37 +04:00
|
|
|
/**
|
|
|
|
* Common baseclass that implements onLockPixels() by calling onReadPixels().
|
|
|
|
* Since it has a copy, it always returns false for onLockPixelsAreWritable().
|
|
|
|
*/
|
2012-02-09 00:27:16 +04:00
|
|
|
class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
|
2011-07-07 17:42:37 +04: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-29 00:02:39 +04:00
|
|
|
* PixelRef that wraps a GrSurface
|
2011-07-07 17:42:37 +04:00
|
|
|
*/
|
2012-06-29 00:02:39 +04:00
|
|
|
class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef {
|
2010-12-23 00:39:39 +03:00
|
|
|
public:
|
2012-08-28 19:07:11 +04: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-29 00:02:39 +04:00
|
|
|
virtual ~SkGrPixelRef();
|
2010-12-23 00:39:39 +03:00
|
|
|
|
|
|
|
// override from SkPixelRef
|
2012-06-29 00:02:39 +04:00
|
|
|
virtual SkGpuTexture* getTexture() SK_OVERRIDE;
|
2010-12-23 00:39:39 +03:00
|
|
|
|
2012-03-29 00:47:01 +04:00
|
|
|
SK_DECLARE_UNFLATTENABLE_OBJECT()
|
|
|
|
|
2010-12-23 00:39:39 +03:00
|
|
|
protected:
|
2012-06-29 00:02:39 +04:00
|
|
|
// overrides from SkPixelRef
|
|
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
|
2011-12-02 23:11:17 +04:00
|
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
|
|
|
|
|
2011-04-05 21:08:27 +04:00
|
|
|
private:
|
2012-06-29 00:02:39 +04:00
|
|
|
GrSurface* fSurface;
|
2012-08-28 19:07:11 +04:00
|
|
|
bool fUnlock; // if true the pixel ref owns a texture cache lock on fSurface
|
|
|
|
|
2011-07-07 17:42:37 +04:00
|
|
|
typedef SkROLockPixelsPixelRef INHERITED;
|
2011-04-05 21:08:27 +04:00
|
|
|
};
|
|
|
|
|
2010-12-23 00:39:39 +03:00
|
|
|
#endif
|
|
|
|
|