Debian Codegraph @

libs/hwui/pipeline/skia/FunctorDrawable.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * This drawable wraps a functor enabling it to be recorded into a list
33 * of Skia drawing commands.
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 } // namespace skiapipeline
63 } // namespace uirenderer
64 } // namespace android