Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrSurface Class Reference
Inheritance diagram for GrSurface:
GrGpuResource GrIORef< GrGpuResource > GrRenderTarget GrTexture

Public Types

typedef void * ReleaseCtx
 
typedef void(* ReleaseProc )(ReleaseCtx)
 

Public Member Functions

int width () const
 Retrieves the width of the surface.
 
int height () const
 Retrieves the height of the surface.
 
void getBoundsRect (SkRect *rect) const
 Helper that gets the width and height of the surface as a bounding rectangle.
 
GrSurfaceOrigin origin () const
 
GrPixelConfig config () const
 Retrieves the pixel config specified when the surface was created. More...
 
const GrSurfaceDescdesc () const
 Return the descriptor describing the surface.
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
virtual GrRenderTargetasRenderTarget ()
 
virtual const GrRenderTargetasRenderTarget () const
 
bool readPixels (int left, int top, int width, int height, GrPixelConfig config, void *buffer, size_t rowBytes=0, uint32_t pixelOpsFlags=0)
 Reads a rectangle of pixels from the surface. More...
 
bool writePixels (int left, int top, int width, int height, GrPixelConfig config, const void *buffer, size_t rowBytes=0, uint32_t pixelOpsFlags=0)
 Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified rectangle. More...
 
void flushWrites ()
 After this returns any pending writes to the surface will be issued to the backend 3D API.
 
GrSurfacePriv surfacePriv ()
 Access methods that are only to be used within Skia code. More...
 
const GrSurfacePriv surfacePriv () const
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 Tests whether a object has been abandoned or released. More...
 
const GrContextgetContext () const
 Retrieves the context that owns the object. More...
 
GrContextgetContext ()
 
size_t gpuMemorySize () const
 Retrieves the amount of GPU memory used by this resource in bytes. More...
 
uint32_t getUniqueID () const
 Gets an id that is unique for this GrGpuResource object. More...
 
const GrUniqueKeygetUniqueKey () const
 Returns the current unique key for the resource. More...
 
const SkDatasetCustomData (const SkData *data)
 Attach a custom data object to this resource. More...
 
const SkDatagetCustomData () const
 Returns the custom data object that was attached to this resource by calling setCustomData.
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
void abandon ()
 Removes references to objects in the underlying 3D API without freeing them. More...
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 Dumps memory usage information for this GrGpuResource to traceMemoryDump. More...
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
void ref () const
 
void unref () const
 
void validate () const
 

Static Public Member Functions

static size_t WorstCaseSize (const GrSurfaceDesc &desc)
 

Protected Member Functions

bool savePixels (const char *filename)
 
bool hasPendingRead () const
 
bool hasPendingWrite () const
 
bool hasPendingIO () const
 
 GrSurface (GrGpu *gpu, const GrSurfaceDesc &desc)
 
void onRelease () override
 Overridden to free GPU resources in the backend API. More...
 
void onAbandon () override
 Overridden to abandon any internal handles, ptrs, etc to backend API resources. More...
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (SkBudgeted)
 
void registerWithCacheWrapped ()
 
 GrGpuResource (GrGpu *)
 
GrGpu * getGpu () const
 
void didChangeGpuMemorySize () const
 This entry point should be called whenever gpuMemorySize() should report a different size. More...
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 Allows subclasses to add additional backing information to the SkTraceMemoryDump. More...
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
bool isPurgeable () const
 
bool internalHasPendingRead () const
 
bool internalHasPendingWrite () const
 
bool internalHasPendingIO () const
 
bool internalHasRef () const
 

Protected Attributes

GrSurfaceDesc fDesc
 

Private Types

typedef GrGpuResource INHERITED
 

Private Member Functions

void invokeReleaseProc ()
 

Private Attributes

ReleaseProc fReleaseProc
 
ReleaseCtx fReleaseCtx
 

Friends

class GrSurfacePriv
 

Additional Inherited Members

- Protected Types inherited from GrIORef< GrGpuResource >
enum  CntType
 

Member Function Documentation

virtual GrRenderTarget* GrSurface::asRenderTarget ( )
inlinevirtual
Returns
the render target underlying this surface, may be NULL.

Reimplemented in GrRenderTarget.

virtual GrTexture* GrSurface::asTexture ( )
inlinevirtual
Returns
the texture associated with the surface, may be NULL.

Reimplemented in GrTexture.

GrPixelConfig GrSurface::config ( ) const
inline

Retrieves the pixel config specified when the surface was created.

For render targets this can be kUnknown_GrPixelConfig if client asked us to render to a target that has a pixel config that isn't equivalent with one of our configs.

void GrSurface::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources.

This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrGpuResource.

void GrSurface::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

bool GrSurface::readPixels ( int  left,
int  top,
int  width,
int  height,
GrPixelConfig  config,
void *  buffer,
size_t  rowBytes = 0,
uint32_t  pixelOpsFlags = 0 
)

Reads a rectangle of pixels from the surface.

Parameters
leftleft edge of the rectangle to read (inclusive)
toptop edge of the rectangle to read (inclusive)
widthwidth of rectangle to read in pixels.
heightheight of rectangle to read in pixels.
configthe pixel config of the destination buffer
buffermemory to read the rectangle into.
rowBytesnumber of bytes between consecutive rows. Zero means rows are tightly packed.
pixelOpsFlagsSee the GrContext::PixelOpsFlags enum.
Returns
true if the read succeeded, false if not. The read can fail because of an unsupported pixel config.
GrSurfacePriv GrSurface::surfacePriv ( )
inline

Access methods that are only to be used within Skia code.

bool GrSurface::writePixels ( int  left,
int  top,
int  width,
int  height,
GrPixelConfig  config,
const void *  buffer,
size_t  rowBytes = 0,
uint32_t  pixelOpsFlags = 0 
)

Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified rectangle.

Parameters
leftleft edge of the rectangle to write (inclusive)
toptop edge of the rectangle to write (inclusive)
widthwidth of rectangle to write in pixels.
heightheight of rectangle to write in pixels.
configthe pixel config of the source buffer
buffermemory to read the rectangle from.
rowBytesnumber of bytes between consecutive rows. Zero means rows are tightly packed.
pixelOpsFlagsSee the GrContext::PixelOpsFlags enum.
Returns
true if the write succeeded, false if not. The write can fail because of an unsupported pixel config.

The documentation for this class was generated from the following file: