| Index: skia/ext/SkFutureDrawable.h
|
| diff --git a/skia/ext/SkFutureDrawable.h b/skia/ext/SkFutureDrawable.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e002d4522caeec0da9c48e217507b8a6a71fd422
|
| --- /dev/null
|
| +++ b/skia/ext/SkFutureDrawable.h
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef SKIA_EXT_SK_FUTURE_DRAWABLE_H_
|
| +#define SKIA_EXT_SK_FUTURE_DRAWABLE_H_
|
| +
|
| +#include <memory>
|
| +#include <unordered_map>
|
| +
|
| +#include "third_party/skia/include/core/SkDrawable.h"
|
| +#include "third_party/skia/include/core/SkPicture.h"
|
| +#include "third_party/skia/include/core/SkScalar.h"
|
| +
|
| +class SK_API SkFutureDrawable : public SkDrawable {
|
| + public:
|
| + static const char kTypeName[];
|
| +
|
| + SkFutureDrawable(const SkRect& bounds)
|
| + : fBounds(bounds), fDrawableRef(nullptr) {}
|
| + SkFutureDrawable(const SkRect& bounds, int id)
|
| + : fBounds(bounds), id(id), fDrawableRef(nullptr) {}
|
| +
|
| + void flatten(SkWriteBuffer& buffer) const override;
|
| +
|
| + Factory getFactory() const override { return CreateProc; }
|
| +
|
| + int Id() const { return id; }
|
| +
|
| + void setDrawableRef(SkDrawable* ref) { fDrawableRef = ref; }
|
| +
|
| + static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
|
| +
|
| + static void addDrawableRef(int id, std::unique_ptr<SkDrawable> ref) {
|
| + fDrawableRefMap[id] = std::move(ref);
|
| + }
|
| +
|
| + static void resetDrawableRef() { fDrawableRefMap.clear(); }
|
| +
|
| + protected:
|
| + SkRect onGetBounds() override { return fBounds; }
|
| +
|
| + void onDraw(SkCanvas* canvas) override;
|
| +
|
| + SkPicture* onNewPictureSnapshot() override;
|
| +
|
| + const char* getTypeName() const override { return kTypeName; }
|
| +
|
| + private:
|
| + const SkRect fBounds;
|
| + int id;
|
| + SkDrawable* fDrawableRef;
|
| +
|
| + static std::unordered_map<int, std::unique_ptr<SkDrawable>> fDrawableRefMap;
|
| +};
|
| +
|
| +#endif // SKIA_EXT_SK_FUTURE_DRAWABLE_H_
|
|
|