5370cd969d
The flatten method on these functions can no longer be const as SkFlattenables declaration is not const and would result in the const methods only being called when the reference to the object was const. Review URL: https://codereview.appspot.com/5941043 git-svn-id: http://skia.googlecode.com/svn/trunk@3533 2bbb7eff-a529-9590-31e7-b0007b416f81
92 lines
2.1 KiB
C++
92 lines
2.1 KiB
C++
|
|
/*
|
|
* Copyright 2010 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkGrTexturePixelRef_DEFINED
|
|
#define SkGrTexturePixelRef_DEFINED
|
|
|
|
#include "SkBitmap.h"
|
|
#include "SkPixelRef.h"
|
|
#include "GrTexture.h"
|
|
#include "GrRenderTarget.h"
|
|
|
|
|
|
/**
|
|
* Common baseclass that implements onLockPixels() by calling onReadPixels().
|
|
* Since it has a copy, it always returns false for onLockPixelsAreWritable().
|
|
*/
|
|
class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
|
|
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
|
|
*/
|
|
class SK_API SkGrTexturePixelRef : public SkROLockPixelsPixelRef {
|
|
public:
|
|
SkGrTexturePixelRef(GrTexture*);
|
|
virtual ~SkGrTexturePixelRef();
|
|
|
|
// override from SkPixelRef
|
|
virtual SkGpuTexture* getTexture();
|
|
|
|
SK_DECLARE_UNFLATTENABLE_OBJECT()
|
|
|
|
protected:
|
|
// override from SkPixelRef
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
|
|
|
|
// override from SkPixelRef
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
|
|
|
|
private:
|
|
GrTexture* fTexture;
|
|
typedef SkROLockPixelsPixelRef INHERITED;
|
|
};
|
|
|
|
/**
|
|
* PixelRef that wraps a GrRenderTarget
|
|
*/
|
|
class SK_API SkGrRenderTargetPixelRef : public SkROLockPixelsPixelRef {
|
|
public:
|
|
SkGrRenderTargetPixelRef(GrRenderTarget* rt);
|
|
virtual ~SkGrRenderTargetPixelRef();
|
|
|
|
// override from SkPixelRef
|
|
virtual SkGpuTexture* getTexture();
|
|
|
|
SK_DECLARE_UNFLATTENABLE_OBJECT()
|
|
|
|
protected:
|
|
// override from SkPixelRef
|
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
|
|
|
|
// override from SkPixelRef
|
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
|
|
|
|
private:
|
|
GrRenderTarget* fRenderTarget;
|
|
typedef SkROLockPixelsPixelRef INHERITED;
|
|
};
|
|
|
|
#endif
|
|
|