| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
#include <SkCanvas.h> |
| 20 |
#include <SkDrawable.h> |
| 21 |
|
| 22 |
#include <WebViewFunctorManager.h> |
| 23 |
#include <utils/Functor.h> |
| 24 |
#include <variant> |
| 25 |
|
| 26 |
namespace android { |
| 27 |
namespace uirenderer { |
| 28 |
|
| 29 |
namespace skiapipeline { |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class FunctorDrawable : public SkDrawable { |
| 36 |
public: |
| 37 |
constexpr static const char* const TYPE_NAME = "FunctorDrawable"; |
| 38 |
|
| 39 |
FunctorDrawable(int functor, SkCanvas* canvas) |
| 40 |
: mBounds(canvas->getLocalClipBounds()) |
| 41 |
, mWebViewHandle(WebViewFunctorManager::instance().handleFor(functor)) {} |
| 42 |
|
| 43 |
virtual ~FunctorDrawable() {} |
| 44 |
|
| 45 |
virtual void syncFunctor(const WebViewSyncData& data) const { |
| 46 |
mWebViewHandle->sync(data); |
| 47 |
} |
| 48 |
|
| 49 |
virtual void onRemovedFromTree() { |
| 50 |
mWebViewHandle->onRemovedFromTree(); |
| 51 |
} |
| 52 |
|
| 53 |
const char* getTypeName() const override { return TYPE_NAME; } |
| 54 |
|
| 55 |
protected: |
| 56 |
virtual SkRect onGetBounds() override { return mBounds; } |
| 57 |
|
| 58 |
const SkRect mBounds; |
| 59 |
sp<WebViewFunctor::Handle> mWebViewHandle; |
| 60 |
}; |
| 61 |
|
| 62 |
} |
| 63 |
} |
| 64 |
} |