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..5a63eab64067712b5f34f84c16602ef1e71ee08f |
| --- /dev/null |
| +++ b/src/core/SkMiniRecorder.h |
| @@ -0,0 +1,40 @@ |
| +/* |
| + * 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 "SkRecords.h" |
| +#include "SkScalar.h" |
| +#include "SkTypes.h" |
| +class SkCanvas; |
| + |
| +// 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); |
| + |
| +private: |
| + enum class State { kEmpty, kDrawRect, kDrawPath, kDrawTextBlob }; |
| + |
| + State fState; |
| + SkAlignedSStorage<sizeof(SkRecords::DrawPath)> fBuffer; |
|
jbroman
2015/05/07 19:38:25
Lacking constexpr std::max, maybe a trick like thi
|
| + |
| + static_assert(sizeof(SkRecords::DrawRect) <= sizeof(SkRecords::DrawPath), ""); |
| + static_assert(sizeof(SkRecords::DrawTextBlob) <= sizeof(SkRecords::DrawPath), ""); |
| +}; |
| + |
| +#endif//SkMiniRecorder_DEFINED |