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:
parent
ffbfd1bc78
commit
d50cc95872
@ -47,9 +47,9 @@ static SkRect bounds(const DrawTextBlob& op) {
|
||||
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 @@ bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c
|
||||
|
||||
|
||||
sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) {
|
||||
#define CASE(Type) \
|
||||
case State::k##Type: \
|
||||
#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 sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get()))
|
||||
return pic; \
|
||||
}
|
||||
|
||||
static SkOnce once;
|
||||
static SkPicture* empty;
|
||||
@ -108,9 +112,9 @@ sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect* cull) {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user