• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 <utils/RefBase.h>
23 #include <utils/Functor.h>
24 
25 namespace android {
26 namespace uirenderer {
27 
28 class GlFunctorLifecycleListener;
29 
30 namespace skiapipeline {
31 
32 /**
33  * This drawable wraps a OpenGL functor enabling it to be recorded into a list
34  * of Skia drawing commands.
35  */
36 class GLFunctorDrawable : public SkDrawable {
37 public:
GLFunctorDrawable(Functor * functor,GlFunctorLifecycleListener * listener,SkCanvas * canvas)38     GLFunctorDrawable(Functor* functor, GlFunctorLifecycleListener* listener, SkCanvas* canvas)
39             : mFunctor(functor)
40             , mListener(listener)
41             , mBounds(canvas->getLocalClipBounds())
42     {}
43     virtual ~GLFunctorDrawable();
44 
45     void syncFunctor() const;
46 
47  protected:
onGetBounds()48     virtual SkRect onGetBounds() override { return mBounds; }
49     virtual void onDraw(SkCanvas* canvas) override;
50 
51  private:
52      Functor* mFunctor;
53      sp<GlFunctorLifecycleListener> mListener;
54      const SkRect mBounds;
55 };
56 
57 }; // namespace skiapipeline
58 }; // namespace uirenderer
59 }; // namespace android
60