gfx/skia/trunk/include/gpu/SkGrPixelRef.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /*
     2  * Copyright 2010 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef SkGrPixelRef_DEFINED
     9 #define SkGrPixelRef_DEFINED
    11 #include "SkBitmap.h"
    12 #include "SkPixelRef.h"
    13 #include "GrTexture.h"
    14 #include "GrRenderTarget.h"
    17 /**
    18  *  Common baseclass that implements onLockPixels() by calling onReadPixels().
    19  *  Since it has a copy, it always returns false for onLockPixelsAreWritable().
    20  */
    21 class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
    22 public:
    23     SK_DECLARE_INST_COUNT(SkROLockPixelsPixelRef)
    24     SkROLockPixelsPixelRef(const SkImageInfo&);
    25     virtual ~SkROLockPixelsPixelRef();
    27 protected:
    28     virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
    29     virtual void onUnlockPixels() SK_OVERRIDE;
    30     virtual bool onLockPixelsAreWritable() const SK_OVERRIDE;   // return false;
    32 private:
    33     SkBitmap    fBitmap;
    34     typedef SkPixelRef INHERITED;
    35 };
    37 /**
    38  *  PixelRef that wraps a GrSurface
    39  */
    40 class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef {
    41 public:
    42     SK_DECLARE_INST_COUNT(SkGrPixelRef)
    43     /**
    44      * Constructs a pixel ref around a GrSurface. If the caller has locked the GrSurface in the
    45      * cache and would like the pixel ref to unlock it in its destructor then transferCacheLock
    46      * should be set to true.
    47      */
    48     SkGrPixelRef(const SkImageInfo&, GrSurface*, bool transferCacheLock = false);
    49     virtual ~SkGrPixelRef();
    51     // override from SkPixelRef
    52     virtual GrTexture* getTexture() SK_OVERRIDE;
    54     SK_DECLARE_UNFLATTENABLE_OBJECT()
    56 protected:
    57     // overrides from SkPixelRef
    58     virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
    59     virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) SK_OVERRIDE;
    61 private:
    62     GrSurface*  fSurface;
    63     bool        fUnlock;   // if true the pixel ref owns a texture cache lock on fSurface
    65     typedef SkROLockPixelsPixelRef INHERITED;
    66 };
    68 #endif

mercurial