Chromium Code Reviews| Index: src/core/SkMiniRecorder.h |
| diff --git a/src/core/SkMiniRecorder.h b/src/core/SkMiniRecorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f98da4d93c231cb61a443322d5778cdd40988c4 |
| --- /dev/null |
| +++ b/src/core/SkMiniRecorder.h |
| @@ -0,0 +1,47 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkMiniRecorder_DEFINED |
| +#define SkMiniRecorder_DEFINED |
| + |
| +#include "SkScalar.h" |
| +#include "SkTypes.h" |
| +class SkCanvas; |
| +class SkPaint; |
| +class SkPath; |
| +class SkPicture; |
| +class SkTextBlob; |
| +struct SkRect; |
| + |
| +// Records small pictures, but only a limited subset of the canvas API, and may fail. |
| +class SkMiniRecorder : SkNoncopyable { |
| +public: |
| + SkMiniRecorder(); |
| + ~SkMiniRecorder(); |
| + |
| + // Try to record an op. Returns false on failure. |
| + bool drawRect(const SkRect&, const SkPaint&); |
| + bool drawPath(const SkPath&, const SkPaint&); |
| + bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&); |
| + |
| + // Detach anything we've recorded as a picture, resetting this SkMiniRecorder. |
| + SkPicture* detachAsPicture(const SkRect& cull); |
| + |
| + // Equivalent to |
| + // SkAutoTUnref<SkPicture> p(this->detachAsPicture()); |
| + // p->playback(canvas); |
| + // but may be more efficient. |
| + void flushToCanvas(SkCanvas*); |
|
reed1
2015/05/04 13:26:34
detachToCanvas?
detachAndPlayback?
detachAndDraw?
mtklein
2015/05/04 15:52:45
Removed the whole method for now, given that it's
|
| + |
| +private: |
| + enum class State { kEmpty, kDrawRect, kDrawPath, kDrawTextBlob }; |
| + |
| + State fState; |
| + char fBuffer[1024]; // TODO: size/align this carefully |
|
reed1
2015/05/04 13:26:34
do we already have an Aligned buffer helper templa
mtklein
2015/05/04 15:52:45
Yep, done.
|
| +}; |
| + |
| +#endif//SkMiniRecorder_DEFINED |