Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/core/SkMiniRecorder.h

Issue 1112523006: Sketch splitting SkPicture into an interface and SkBigPicture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: check on all ops Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkLayerInfo.cpp ('k') | src/core/SkMiniRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/core/SkLayerInfo.cpp ('k') | src/core/SkMiniRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698