aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/pipe
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-03 21:26:46 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-03 21:26:46 +0000
commitacd471f47ccfb97cf2f2f00dc01cd1fd45bc1ef2 (patch)
tree6dbfad7a3b3af1d6bb0cef11f6987ddcad43c7a6 /include/pipe
parent1e1c36f4f89ad39e1d248edb745919e493242c68 (diff)
updated pipe
git-svn-id: http://skia.googlecode.com/svn/trunk@1231 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/pipe')
-rw-r--r--include/pipe/SkGPipe.h51
1 files changed, 24 insertions, 27 deletions
diff --git a/include/pipe/SkGPipe.h b/include/pipe/SkGPipe.h
index d6210ac8c8..e9f850260e 100644
--- a/include/pipe/SkGPipe.h
+++ b/include/pipe/SkGPipe.h
@@ -33,6 +33,8 @@ public:
kError_Status //!< encountered error
};
+ // data must be 4-byte aligned
+ // length must be a multiple of 4
Status playback(const void* data, size_t length);
private:
@@ -42,34 +44,28 @@ private:
///////////////////////////////////////////////////////////////////////////////
-class SkGPipeControler {
+class SkGPipeController {
public:
- struct Block {
- void* fAddr;
- size_t fSize;
- };
-
- enum Status {
- kSuccess_Status,
- kFailure_Status
- };
-
/**
- * To record drawing commands, we request blocks from the controller for
- * subsequent writes, and we want to send/flush blocks of commands we have
- * already written.
+ * Called periodically by the writer, to get a working buffer of RAM to
+ * write into. The actual size of the block is also returned, and must be
+ * actual >= minRequest. If NULL is returned, then actual is ignored and
+ * writing will stop.
*
- * For each call to handleBlock, the send block will contain the block
- * (previously returned in a request parameter) that we have written, and
- * if there is more to be recorded, the request block will receive the
- * new block of memory to write into. When the writer detects that there
- * are no more drawing commands expected, it will call handleBlock with
- * NULL for the request parameter.
+ * The returned block must be 4-byte aligned, and actual must be a
+ * multiple of 4.
+ * minRequest will always be a multiple of 4.
+ */
+ virtual void* requestBlock(size_t minRequest, size_t* actual) = 0;
+
+ /**
+ * This is called each time some atomic portion of the data has been
+ * written to the block (most recently returned by requestBlock()).
+ * If bytes == 0, then the writer has finished.
*
- * If handleBlock ever returns kFailure_Status, the writer will cease to
- * call handleBlock.
+ * bytes will always be a multiple of 4.
*/
- virtual Status handleBlock(const Block& send, Block* request) = 0;
+ virtual void notifyWritten(size_t bytes) = 0;
};
class SkGPipeWriter {
@@ -78,14 +74,15 @@ public:
~SkGPipeWriter();
bool isRecording() const { return NULL != fCanvas; }
- SkCanvas* startRecording(SkGPipeControler*);
- void endRecording();
+ SkCanvas* startRecording(SkGPipeController*);
- size_t flatten(void* buffer);
+ // called in destructor, but can be called sooner once you know there
+ // should be no more drawing calls made into the recording canvas.
+ void endRecording();
private:
class SkGPipeCanvas* fCanvas;
- SkGPipeControler* fControler;
+ SkGPipeController* fController;
SkWriter32 fWriter;
};