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>
This commit is contained in:
Mike Klein 2019-12-05 12:15:34 -06:00 committed by Skia Commit-Bot
parent ffbfd1bc78
commit d50cc95872

View File

@ -47,9 +47,9 @@ static SkRect bounds(const DrawTextBlob& op) {
template <typename T> template <typename T>
class SkMiniPicture final : public SkPicture { class SkMiniPicture final : public SkPicture {
public: public:
SkMiniPicture(const SkRect* cull, T* op) : fCull(cull ? *cull : bounds(*op)) { SkMiniPicture(const SkRect* cull, T&& op)
memcpy(&fOp, op, sizeof(fOp)); // We take ownership of op's guts. : fCull(cull ? *cull : bounds(op))
} , fOp(std::move(op)) {}
void playback(SkCanvas* c, AbortCallback*) const override { void playback(SkCanvas* c, AbortCallback*) const override {
SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp); SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp);
@ -96,10 +96,14 @@ bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c
sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) { sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) {
#define CASE(Type) \ #define CASE(T) \
case State::k##Type: \ case State::k##T: { \
fState = State::kEmpty; \ T* op = reinterpret_cast<T*>(fBuffer.get()); \
return sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get())) auto pic = sk_make_sp<SkMiniPicture<T>>(cull, std::move(*op)); \
op->~T(); \
fState = State::kEmpty; \
return pic; \
}
static SkOnce once; static SkOnce once;
static SkPicture* empty; static SkPicture* empty;
@ -108,9 +112,9 @@ sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) {
case State::kEmpty: case State::kEmpty:
once([]{ empty = new SkEmptyPicture; }); once([]{ empty = new SkEmptyPicture; });
return sk_ref_sp(empty); return sk_ref_sp(empty);
CASE(DrawPath); CASE(DrawPath)
CASE(DrawRect); CASE(DrawRect)
CASE(DrawTextBlob); CASE(DrawTextBlob)
} }
SkASSERT(false); SkASSERT(false);
return nullptr; return nullptr;