Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkBaseDevice Class Referenceabstract
Inheritance diagram for SkBaseDevice:
SkRefCnt SkRefCntBase SkBitmapDevice

Classes

struct  CreateInfo
 
struct  TextFlags
 

Public Member Functions

 SkBaseDevice (const SkImageInfo &, const SkSurfaceProps &)
 Construct a new device.
 
SkMetaDatagetMetaData ()
 
const SkImageInfoimageInfo () const
 Return ImageInfo for this device. More...
 
const SkSurfacePropssurfaceProps () const
 Return SurfaceProps for this device.
 
void getGlobalBounds (SkIRect *bounds) const
 Return the bounds of the device in the coordinate space of the root canvas. More...
 
SkIRect getGlobalBounds () const
 
int width () const
 
int height () const
 
bool isOpaque () const
 
bool writePixels (const SkImageInfo &, const void *, size_t rowBytes, int x, int y)
 
bool accessPixels (SkPixmap *pmap)
 Try to get write-access to the pixels behind the device. More...
 
bool peekPixels (SkPixmap *)
 Try to get read-only-access to the pixels behind the device. More...
 
const SkIPointgetOrigin () const
 Return the device's origin: its offset in device coordinates from the default origin in its canvas' matrix/clip.
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 Default construct, initializing the reference count to 1.
 
virtual ~SkRefCntBase ()
 Destruct, asserting that the reference count is 1.
 
int32_t getRefCnt () const
 Return the reference count. More...
 
void validate () const
 
bool unique () const
 May return true if the caller is the only owner. More...
 
void ref () const
 Increment the reference count. More...
 
void unref () const
 Decrement the reference count. More...
 

Protected Types

enum  TileUsage { kPossible_TileUsage, kNever_TileUsage }
 

Protected Member Functions

uint32_t filterTextFlags (const SkPaint &) const
 Returns the text-related flags, possibly modified based on the state of the device (e.g. More...
 
virtual bool onShouldDisableLCD (const SkPaint &) const
 
virtual void setMatrixClip (const SkMatrix &, const SkRegion &, const SkClipStack &)
 DEPRECATED: This will be removed in a future change. More...
 
virtual void drawPaint (const SkDraw &, const SkPaint &paint)=0
 These are called inside the per-device-layer loop for each draw call. More...
 
virtual void drawPoints (const SkDraw &, SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint)=0
 
virtual void drawRect (const SkDraw &, const SkRect &r, const SkPaint &paint)=0
 
virtual void drawOval (const SkDraw &, const SkRect &oval, const SkPaint &paint)=0
 
virtual void drawArc (const SkDraw &, const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
 By the time this is called we know that abs(sweepAngle) is in the range [0, 360). More...
 
virtual void drawRRect (const SkDraw &, const SkRRect &rr, const SkPaint &paint)=0
 
virtual void drawDRRect (const SkDraw &, const SkRRect &outer, const SkRRect &inner, const SkPaint &)
 
virtual void drawPath (const SkDraw &, const SkPath &path, const SkPaint &paint, const SkMatrix *prePathMatrix=NULL, bool pathIsMutable=false)=0
 If pathIsMutable, then the implementation is allowed to cast path to a non-const pointer and modify it in place (as an optimization). More...
 
virtual void drawBitmap (const SkDraw &, const SkBitmap &bitmap, const SkMatrix &matrix, const SkPaint &paint)=0
 
virtual void drawSprite (const SkDraw &, const SkBitmap &bitmap, int x, int y, const SkPaint &paint)=0
 
virtual void drawBitmapRect (const SkDraw &, const SkBitmap &, const SkRect *srcOrNull, const SkRect &dst, const SkPaint &paint, SkCanvas::SrcRectConstraint)=0
 The default impl. More...
 
virtual void drawBitmapNine (const SkDraw &, const SkBitmap &, const SkIRect &center, const SkRect &dst, const SkPaint &)
 
virtual void drawBitmapLattice (const SkDraw &, const SkBitmap &, const SkCanvas::Lattice &, const SkRect &dst, const SkPaint &)
 
virtual void drawImage (const SkDraw &, const SkImage *, SkScalar x, SkScalar y, const SkPaint &)
 
virtual void drawImageRect (const SkDraw &, const SkImage *, const SkRect *src, const SkRect &dst, const SkPaint &, SkCanvas::SrcRectConstraint)
 
virtual void drawImageNine (const SkDraw &, const SkImage *, const SkIRect &center, const SkRect &dst, const SkPaint &)
 
virtual void drawImageLattice (const SkDraw &, const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, const SkPaint &)
 
virtual void drawText (const SkDraw &, const void *text, size_t len, SkScalar x, SkScalar y, const SkPaint &paint)=0
 Does not handle text decoration. More...
 
virtual void drawPosText (const SkDraw &, const void *text, size_t len, const SkScalar pos[], int scalarsPerPos, const SkPoint &offset, const SkPaint &paint)=0
 
virtual void drawVertices (const SkDraw &, SkCanvas::VertexMode, int vertexCount, const SkPoint verts[], const SkPoint texs[], const SkColor colors[], SkXfermode *xmode, const uint16_t indices[], int indexCount, const SkPaint &paint)=0
 
virtual void drawTextBlob (const SkDraw &, const SkTextBlob *, SkScalar x, SkScalar y, const SkPaint &paint, SkDrawFilter *drawFilter)
 
virtual void drawPatch (const SkDraw &, const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkXfermode *xmode, const SkPaint &paint)
 
virtual void drawAtlas (const SkDraw &, const SkImage *atlas, const SkRSXform[], const SkRect[], const SkColor[], int count, SkXfermode::Mode, const SkPaint &)
 
virtual void drawAnnotation (const SkDraw &, const SkRect &, const char[], SkData *)
 
virtual void drawDevice (const SkDraw &, SkBaseDevice *, int x, int y, const SkPaint &)=0
 The SkDevice passed will be an SkDevice which was returned by a call to onCreateDevice on this device with kNeverTile_TileExpectation.
 
virtual void drawTextOnPath (const SkDraw &, const void *text, size_t len, const SkPath &, const SkMatrix *, const SkPaint &)
 
virtual void drawTextRSXform (const SkDraw &, const void *text, size_t len, const SkRSXform[], const SkPaint &)
 
virtual void drawSpecial (const SkDraw &, SkSpecialImage *, int x, int y, const SkPaint &)
 
virtual sk_sp< SkSpecialImage > makeSpecial (const SkBitmap &)
 
virtual sk_sp< SkSpecialImage > makeSpecial (const SkImage *)
 
virtual sk_sp< SkSpecialImage > snapSpecial ()
 
bool readPixels (const SkImageInfo &, void *dst, size_t rowBytes, int x, int y)
 
virtual GrContextcontext () const
 
virtual sk_sp< SkSurfacemakeSurface (const SkImageInfo &, const SkSurfaceProps &)
 
virtual bool onPeekPixels (SkPixmap *)
 
virtual bool onReadPixels (const SkImageInfo &, void *, size_t, int x, int y)
 The caller is responsible for "pre-clipping" the dst. More...
 
virtual bool onWritePixels (const SkImageInfo &, const void *, size_t, int x, int y)
 The caller is responsible for "pre-clipping" the src. More...
 
virtual bool onAccessPixels (SkPixmap *)
 
virtual SkBaseDeviceonCreateDevice (const CreateInfo &, const SkPaint *)
 Create a new device based on CreateInfo. More...
 
- Protected Member Functions inherited from SkRefCntBase
void internal_dispose_restore_refcnt_to_1 () const
 Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called or if they choose not to call the destructor (e.g. More...
 

Static Protected Member Functions

static void LogDrawScaleFactor (const SkMatrix &, SkFilterQuality)
 

Private Types

typedef SkRefCnt INHERITED
 

Private Member Functions

virtual void replaceBitmapBackendForRasterSurface (const SkBitmap &)
 
virtual bool forceConservativeRasterClip () const
 
virtual GrDrawContextaccessDrawContext ()
 Don't call this!
 
void setOrigin (int x, int y)
 
virtual void flush ()
 Causes any deferred drawing to the device to be completed.
 
virtual SkImageFilterCache * getImageFilterCache ()
 
void privateResize (int w, int h)
 

Private Attributes

SkIPoint fOrigin
 
SkMetaDatafMetaData
 
const SkImageInfo fInfo
 
const SkSurfaceProps fSurfaceProps
 

Friends

class SkCanvas
 
struct DeviceCM
 
class SkDraw
 
class SkDrawIter
 
class SkDeviceFilteredPaint
 
class SkNoPixelsBitmapDevice
 
class SkSurface_Raster
 
class DeviceTestingAccess
 
class SkBitmapDevice
 

Member Enumeration Documentation

enum SkBaseDevice::TileUsage
protected
Enumerator
kPossible_TileUsage 

the created device may be drawn tiled

kNever_TileUsage 

the created device will never be drawn tiled

Member Function Documentation

bool SkBaseDevice::accessPixels ( SkPixmap pmap)

Try to get write-access to the pixels behind the device.

If successful, this returns true and fills-out the pixmap parameter. On success it also bumps the genID of the underlying bitmap.

On failure, returns false and ignores the pixmap parameter.

virtual void SkBaseDevice::drawArc ( const SkDraw ,
const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle,
bool  useCenter,
const SkPaint paint 
)
protectedvirtual

By the time this is called we know that abs(sweepAngle) is in the range [0, 360).

virtual void SkBaseDevice::drawBitmapRect ( const SkDraw ,
const SkBitmap ,
const SkRect srcOrNull,
const SkRect dst,
const SkPaint paint,
SkCanvas::SrcRectConstraint   
)
protectedpure virtual

The default impl.

will create a bitmap-shader from the bitmap, and call drawRect with it.

Implemented in SkBitmapDevice.

virtual void SkBaseDevice::drawPaint ( const SkDraw ,
const SkPaint paint 
)
protectedpure virtual

These are called inside the per-device-layer loop for each draw call.

When these are called, we have already applied any saveLayer operations, and are handling any looping from the paint, and any effects from the DrawFilter.

Implemented in SkBitmapDevice.

virtual void SkBaseDevice::drawPath ( const SkDraw ,
const SkPath path,
const SkPaint paint,
const SkMatrix prePathMatrix = NULL,
bool  pathIsMutable = false 
)
protectedpure virtual

If pathIsMutable, then the implementation is allowed to cast path to a non-const pointer and modify it in place (as an optimization).

Canvas may do this to implement helpers such as drawOval, by placing a temp path on the stack to hold the representation of the oval.

If prePathMatrix is not null, it should logically be applied before any stroking or other effects. If there are no effects on the paint that affect the geometry/rasterization, then the pre matrix can just be pre-concated with the current matrix.

Implemented in SkBitmapDevice.

virtual void SkBaseDevice::drawText ( const SkDraw ,
const void *  text,
size_t  len,
SkScalar  x,
SkScalar  y,
const SkPaint paint 
)
protectedpure virtual

Does not handle text decoration.

Decorations (underline and stike-thru) will be handled by SkCanvas.

Implemented in SkBitmapDevice.

uint32_t SkBaseDevice::filterTextFlags ( const SkPaint ) const
protected

Returns the text-related flags, possibly modified based on the state of the device (e.g.

support for LCD).

void SkBaseDevice::getGlobalBounds ( SkIRect bounds) const
inline

Return the bounds of the device in the coordinate space of the root canvas.

The root device will have its top-left at 0,0, but other devices such as those associated with saveLayer may have a non-zero origin.

const SkImageInfo& SkBaseDevice::imageInfo ( ) const
inline

Return ImageInfo for this device.

If the canvas is not backed by pixels (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.

virtual SkBaseDevice* SkBaseDevice::onCreateDevice ( const CreateInfo ,
const SkPaint  
)
inlineprotectedvirtual

Create a new device based on CreateInfo.

If the paint is not null, then it represents a preview of how the new device will be composed with its creator device (this).

The subclass may be handed this device in drawDevice(), so it must always return a device that it knows how to draw, and that it knows how to identify if it is not of the same subclass (since drawDevice is passed a SkBaseDevice*). If the subclass cannot fulfill that contract (e.g. PDF cannot support some settings on the paint) it should return NULL, and the caller may then decide to explicitly create a bitmapdevice, knowing that later it could not call drawDevice with it (but it could call drawSprite or drawBitmap).

Reimplemented in SkBitmapDevice.

virtual bool SkBaseDevice::onReadPixels ( const SkImageInfo ,
void *  ,
size_t  ,
int  x,
int  y 
)
protectedvirtual

The caller is responsible for "pre-clipping" the dst.

The impl can assume that the dst image at the specified x,y offset will fit within the device's bounds.

This is explicitly asserted in readPixels(), the public way to call this.

Reimplemented in SkBitmapDevice.

virtual bool SkBaseDevice::onWritePixels ( const SkImageInfo ,
const void *  ,
size_t  ,
int  x,
int  y 
)
protectedvirtual

The caller is responsible for "pre-clipping" the src.

The impl can assume that the src image at the specified x,y offset will fit within the device's bounds.

This is explicitly asserted in writePixelsDirect(), the public way to call this.

Reimplemented in SkBitmapDevice.

bool SkBaseDevice::peekPixels ( SkPixmap )

Try to get read-only-access to the pixels behind the device.

If successful, this returns true and fills-out the pixmap parameter.

On failure, returns false and ignores the pixmap parameter.

virtual void SkBaseDevice::setMatrixClip ( const SkMatrix ,
const SkRegion ,
const SkClipStack  
)
inlineprotectedvirtual

DEPRECATED: This will be removed in a future change.

Device subclasses should use the matrix and clip from the SkDraw passed to draw functions.

Called with the correct matrix and clip before this device is drawn to using those settings. If your subclass overrides this, be sure to call through to the base class as well.

The clipstack is another view of the clip. It records the actual geometry that went into building the region. It is present for devices that want to parse it, but is not required: the region is a complete picture of the current clip. (i.e. if you regionize all of the geometry in the clipstack, you will arrive at an equivalent region to the one passed in).


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