1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/gpu/SkGrPixelRef.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* 1.5 + * Copyright 2010 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkGrPixelRef_DEFINED 1.12 +#define SkGrPixelRef_DEFINED 1.13 + 1.14 +#include "SkBitmap.h" 1.15 +#include "SkPixelRef.h" 1.16 +#include "GrTexture.h" 1.17 +#include "GrRenderTarget.h" 1.18 + 1.19 + 1.20 +/** 1.21 + * Common baseclass that implements onLockPixels() by calling onReadPixels(). 1.22 + * Since it has a copy, it always returns false for onLockPixelsAreWritable(). 1.23 + */ 1.24 +class SK_API SkROLockPixelsPixelRef : public SkPixelRef { 1.25 +public: 1.26 + SK_DECLARE_INST_COUNT(SkROLockPixelsPixelRef) 1.27 + SkROLockPixelsPixelRef(const SkImageInfo&); 1.28 + virtual ~SkROLockPixelsPixelRef(); 1.29 + 1.30 +protected: 1.31 + virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; 1.32 + virtual void onUnlockPixels() SK_OVERRIDE; 1.33 + virtual bool onLockPixelsAreWritable() const SK_OVERRIDE; // return false; 1.34 + 1.35 +private: 1.36 + SkBitmap fBitmap; 1.37 + typedef SkPixelRef INHERITED; 1.38 +}; 1.39 + 1.40 +/** 1.41 + * PixelRef that wraps a GrSurface 1.42 + */ 1.43 +class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { 1.44 +public: 1.45 + SK_DECLARE_INST_COUNT(SkGrPixelRef) 1.46 + /** 1.47 + * Constructs a pixel ref around a GrSurface. If the caller has locked the GrSurface in the 1.48 + * cache and would like the pixel ref to unlock it in its destructor then transferCacheLock 1.49 + * should be set to true. 1.50 + */ 1.51 + SkGrPixelRef(const SkImageInfo&, GrSurface*, bool transferCacheLock = false); 1.52 + virtual ~SkGrPixelRef(); 1.53 + 1.54 + // override from SkPixelRef 1.55 + virtual GrTexture* getTexture() SK_OVERRIDE; 1.56 + 1.57 + SK_DECLARE_UNFLATTENABLE_OBJECT() 1.58 + 1.59 +protected: 1.60 + // overrides from SkPixelRef 1.61 + virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE; 1.62 + virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) SK_OVERRIDE; 1.63 + 1.64 +private: 1.65 + GrSurface* fSurface; 1.66 + bool fUnlock; // if true the pixel ref owns a texture cache lock on fSurface 1.67 + 1.68 + typedef SkROLockPixelsPixelRef INHERITED; 1.69 +}; 1.70 + 1.71 +#endif