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

Unified Diff: src/core/SkMiniRecorder.cpp

Issue 1144173002: More efficient SkRecorder::flushMiniRecorder() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: spelling 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/SkMiniRecorder.h ('k') | src/core/SkRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMiniRecorder.cpp
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index f851e1cac00196b9fb588d4f4d64215b0cedc80c..6707e863ac488013b341110428e2a126370e24de 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -86,12 +86,13 @@ bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c
}
#undef TRY_TO_STORE
+
+SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
#define CASE(Type) \
case State::k##Type: \
fState = State::kEmpty; \
return SkNEW_ARGS(SkMiniPicture<Type>, (cull, reinterpret_cast<Type*>(fBuffer.get())))
-SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
switch (fState) {
case State::kEmpty: return SkNEW(SkEmptyPicture);
CASE(DrawPath);
@@ -99,6 +100,25 @@ SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
CASE(DrawTextBlob);
}
SkASSERT(false);
- return NULL;
+ return nullptr;
+#undef CASE
}
+
+void SkMiniRecorder::flushAndReset(SkCanvas* canvas) {
+#define CASE(Type) \
+ case State::k##Type: { \
+ fState = State::kEmpty; \
+ Type* op = reinterpret_cast<Type*>(fBuffer.get()); \
+ SkRecords::Draw(canvas, nullptr, nullptr, 0, nullptr)(*op); \
+ op->~Type(); \
+ } return
+
+ switch (fState) {
+ case State::kEmpty: return;
+ CASE(DrawPath);
+ CASE(DrawRect);
+ CASE(DrawTextBlob);
+ }
+ SkASSERT(false);
#undef CASE
+}
« no previous file with comments | « src/core/SkMiniRecorder.h ('k') | src/core/SkRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698