* 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 "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/SkNoncopyable.h"
#include "src/core/SkRecords.h"
class SkCanvas;
class SkMiniRecorder : SkNoncopyable {
public:
SkMiniRecorder();
~SkMiniRecorder();
bool drawPath(const SkPath&, const SkPaint&);
bool drawRect(const SkRect&, const SkPaint&);
bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&);
sk_sp<SkPicture> detachAsPicture(const SkRect* cull);
void flushAndReset(SkCanvas*);
private:
enum class State {
kEmpty,
kDrawPath,
kDrawRect,
kDrawTextBlob,
};
State fState;
template <size_t A, size_t B>
struct Max { static const size_t val = A > B ? A : B; };
static const size_t kInlineStorage =
Max<sizeof(SkRecords::DrawPath),
Max<sizeof(SkRecords::DrawRect),
sizeof(SkRecords::DrawTextBlob)>::val>::val;
SkAlignedSStorage<kInlineStorage> fBuffer;
};
#endif