9 #ifndef GrSurface_DEFINED
10 #define GrSurface_DEFINED
13 #include "GrGpuResource.h"
14 #include "SkImageInfo.h"
26 int width()
const {
return fDesc.fWidth; }
31 int height()
const {
return fDesc.fHeight; }
37 SkIntToScalar(this->height())); }
39 GrSurfaceOrigin origin()
const {
40 SkASSERT(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin || kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin);
50 GrPixelConfig
config()
const {
return fDesc.fConfig; }
61 virtual const GrTexture* asTexture()
const {
return NULL; }
67 virtual const GrRenderTarget* asRenderTarget()
const {
return NULL; }
84 bool readPixels(
int left,
int top,
int width,
int height,
88 uint32_t pixelOpsFlags = 0);
106 bool writePixels(
int left,
int top,
int width,
int height,
107 GrPixelConfig config,
110 uint32_t pixelOpsFlags = 0);
118 inline GrSurfacePriv surfacePriv();
119 inline const GrSurfacePriv surfacePriv()
const;
121 typedef void* ReleaseCtx;
122 typedef void (*ReleaseProc)(ReleaseCtx);
124 void setRelease(ReleaseProc proc, ReleaseCtx ctx) {
133 bool savePixels(
const char* filename);
134 bool hasPendingRead()
const;
135 bool hasPendingWrite()
const;
136 bool hasPendingIO()
const;
139 friend class GrSurfacePriv;
150 SkASSERT(NULL == fReleaseProc);
159 void invokeReleaseProc() {
161 fReleaseProc(fReleaseCtx);
166 ReleaseProc fReleaseProc;
167 ReleaseCtx fReleaseCtx;
Base class for objects that can be kept in the GrResourceCache.
Definition: GrGpuResource.h:140
virtual void onAbandon()
Overridden to abandon any internal handles, ptrs, etc to backend API resources.
Definition: GrGpuResource.h:255
Describes a surface to be created.
Definition: GrTypes.h:467
virtual void onRelease()
Overridden to free GPU resources in the backend API.
Definition: GrGpuResource.h:251
virtual GrRenderTarget * asRenderTarget()
Definition: GrSurface.h:66
virtual GrTexture * asTexture()
Definition: GrSurface.h:60
Definition: GrSurface.h:21
int width() const
Retrieves the width of the surface.
Definition: GrSurface.h:26
void getBoundsRect(SkRect *rect) const
Helper that gets the width and height of the surface as a bounding rectangle.
Definition: GrSurface.h:36
int height() const
Retrieves the height of the surface.
Definition: GrSurface.h:31
const GrSurfaceDesc & desc() const
Return the descriptor describing the surface.
Definition: GrSurface.h:55
GrPixelConfig config() const
Retrieves the pixel config specified when the surface was created.
Definition: GrSurface.h:50
GrRenderTarget represents a 2D buffer of pixels that can be rendered to.
Definition: GrRenderTarget.h:26
Definition: GrTexture.h:19