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
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
#ifndef SkGrTexturePixelRef_DEFINED
|
|
|
|
#define SkGrTexturePixelRef_DEFINED
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PixelRef that wraps a GrTexture
|
|
|
|
*/
|
2012-02-08 20:27:16 +00:00
|
|
|
class SK_API SkGrTexturePixelRef : public SkROLockPixelsPixelRef {
|
2010-12-22 21:39:39 +00:00
|
|
|
public:
|
|
|
|
SkGrTexturePixelRef(GrTexture*);
|
|
|
|
virtual ~SkGrTexturePixelRef();
|
|
|
|
|
|
|
|
// override from SkPixelRef
|
2011-07-07 13:42:37 +00:00
|
|
|
virtual SkGpuTexture* getTexture();
|
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:
|
|
|
|
// override from SkPixelRef
|
2011-04-01 19:05:36 +00:00
|
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2011-12-02 19:11:17 +00:00
|
|
|
// override from SkPixelRef
|
|
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
private:
|
|
|
|
GrTexture* fTexture;
|
2011-07-07 13:42:37 +00:00
|
|
|
typedef SkROLockPixelsPixelRef INHERITED;
|
2010-12-22 21:39:39 +00:00
|
|
|
};
|
|
|
|
|
2011-07-07 13:42:37 +00:00
|
|
|
/**
|
|
|
|
* PixelRef that wraps a GrRenderTarget
|
|
|
|
*/
|
2012-02-08 20:27:16 +00:00
|
|
|
class SK_API SkGrRenderTargetPixelRef : public SkROLockPixelsPixelRef {
|
2011-04-05 17:08:27 +00:00
|
|
|
public:
|
|
|
|
SkGrRenderTargetPixelRef(GrRenderTarget* rt);
|
|
|
|
virtual ~SkGrRenderTargetPixelRef();
|
|
|
|
|
|
|
|
// override from SkPixelRef
|
|
|
|
virtual SkGpuTexture* getTexture();
|
|
|
|
|
2012-03-28 20:47:01 +00:00
|
|
|
SK_DECLARE_UNFLATTENABLE_OBJECT()
|
|
|
|
|
2011-04-05 17:08:27 +00:00
|
|
|
protected:
|
|
|
|
// override from SkPixelRef
|
|
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
|
|
|
|
|
2011-12-02 19:11:17 +00:00
|
|
|
// override from SkPixelRef
|
|
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
|
|
|
|
|
2011-04-05 17:08:27 +00:00
|
|
|
private:
|
|
|
|
GrRenderTarget* fRenderTarget;
|
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
|
|
|
|
|