upgrade SkMiniRecorder to c++11
It had been manually std::move()ing without actually
calling it by that name. GCC noticed.
Oh hey, let's call ~T().
Change-Id: Ie54b8906e3a4334f73e46ca9d31dc8542289f238
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258344
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index e75ecd0..76919a0 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -47,9 +47,9 @@
template <typename T>
class SkMiniPicture final : public SkPicture {
public:
- SkMiniPicture(const SkRect* cull, T* op) : fCull(cull ? *cull : bounds(*op)) {
- memcpy(&fOp, op, sizeof(fOp)); // We take ownership of op's guts.
- }
+ SkMiniPicture(const SkRect* cull, T&& op)
+ : fCull(cull ? *cull : bounds(op))
+ , fOp(std::move(op)) {}
void playback(SkCanvas* c, AbortCallback*) const override {
SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp);
@@ -96,10 +96,14 @@
sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) {
-#define CASE(Type) \
- case State::k##Type: \
- fState = State::kEmpty; \
- return sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get()))
+#define CASE(T) \
+ case State::k##T: { \
+ T* op = reinterpret_cast<T*>(fBuffer.get()); \
+ auto pic = sk_make_sp<SkMiniPicture<T>>(cull, std::move(*op)); \
+ op->~T(); \
+ fState = State::kEmpty; \
+ return pic; \
+ }
static SkOnce once;
static SkPicture* empty;
@@ -108,9 +112,9 @@
case State::kEmpty:
once([]{ empty = new SkEmptyPicture; });
return sk_ref_sp(empty);
- CASE(DrawPath);
- CASE(DrawRect);
- CASE(DrawTextBlob);
+ CASE(DrawPath)
+ CASE(DrawRect)
+ CASE(DrawTextBlob)
}
SkASSERT(false);
return nullptr;