Skia
2D Graphics Library
SkDocument Class Referenceabstract

High-level API for creating a document-based canvas. More...

#include <SkDocument.h>

Inheritance diagram for SkDocument:

Public Member Functions

SkCanvasbeginPage (SkScalar width, SkScalar height, const SkRect *content=nullptr)
 Begin a new page for the document, returning the canvas that will draw into the page. More...
 
void endPage ()
 Call endPage() when the content for the current page has been drawn (into the canvas returned by beginPage()). More...
 
void close ()
 Call close() when all pages have been drawn. More...
 
void abort ()
 Call abort() to stop producing the document immediately. More...
 
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  State { kBetweenPages_State , kInPage_State , kClosed_State }
 

Protected Member Functions

 SkDocument (SkWStream *)
 
 ~SkDocument () override
 
virtual SkCanvasonBeginPage (SkScalar width, SkScalar height)=0
 
virtual void onEndPage ()=0
 
virtual void onClose (SkWStream *)=0
 
virtual void onAbort ()=0
 
SkWStreamgetStream ()
 
State getState () const
 

Detailed Description

High-level API for creating a document-based canvas.

To use..

  1. Create a document, specifying a stream to store the output.
  2. For each "page" of content: a. canvas = doc->beginPage(...) b. draw_my_content(canvas); c. doc->endPage();
  3. Close the document with doc->close().

Member Enumeration Documentation

◆ State

enum SkDocument::State
protected
Enumerator
kBetweenPages_State 
kInPage_State 
kClosed_State 

Constructor & Destructor Documentation

◆ SkDocument()

SkDocument::SkDocument ( SkWStream )
protected

◆ ~SkDocument()

SkDocument::~SkDocument ( )
overrideprotected

Member Function Documentation

◆ abort()

void SkDocument::abort ( )

Call abort() to stop producing the document immediately.

The stream output must be ignored, and should not be trusted.

◆ beginPage()

SkCanvas* SkDocument::beginPage ( SkScalar  width,
SkScalar  height,
const SkRect content = nullptr 
)

Begin a new page for the document, returning the canvas that will draw into the page.

The document owns this canvas, and it will go out of scope when endPage() or close() is called, or the document is deleted.

◆ close()

void SkDocument::close ( )

Call close() when all pages have been drawn.

This will close the file or stream holding the document's contents. After close() the document can no longer add new pages. Deleting the document will automatically call close() if need be.

◆ endPage()

void SkDocument::endPage ( )

Call endPage() when the content for the current page has been drawn (into the canvas returned by beginPage()).

After this call the canvas returned by beginPage() will be out-of-scope.

◆ getState()

State SkDocument::getState ( ) const
inlineprotected

◆ getStream()

SkWStream* SkDocument::getStream ( )
inlineprotected

◆ onAbort()

virtual void SkDocument::onAbort ( )
protectedpure virtual

◆ onBeginPage()

virtual SkCanvas* SkDocument::onBeginPage ( SkScalar  width,
SkScalar  height 
)
protectedpure virtual

◆ onClose()

virtual void SkDocument::onClose ( SkWStream )
protectedpure virtual

◆ onEndPage()

virtual void SkDocument::onEndPage ( )
protectedpure virtual

◆ ref()

void SkRefCntBase::ref ( ) const
inlineinherited

Increment the reference count.

Must be balanced by a call to unref().

◆ unique()

bool SkRefCntBase::unique ( ) const
inlineinherited

May return true if the caller is the only owner.

Ensures that all previous owner's actions are complete.

◆ unref()

void SkRefCntBase::unref ( ) const
inlineinherited

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.


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