• 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 "RenderNodeDrawable.h"
20 
21 #include <SkCanvas.h>
22 #include <SkDrawable.h>
23 #include <utils/FatVector.h>
24 
25 namespace android {
26 namespace uirenderer {
27 namespace skiapipeline {
28 
29 class SkiaDisplayList;
30 class EndReorderBarrierDrawable;
31 
32 /**
33  * StartReorderBarrierDrawable and EndReorderBarrierDrawable work together to define
34  * a sub-list in a display list that need to be drawn out-of-order sorted instead by render
35  * node Z index.
36  * StartReorderBarrierDrawable will sort the entire range and it will draw
37  * render nodes in the range with negative Z index.
38  */
39 class StartReorderBarrierDrawable : public SkDrawable {
40 public:
41     explicit StartReorderBarrierDrawable(SkiaDisplayList* data);
42 
43 protected:
onGetBounds()44     virtual SkRect onGetBounds() override {
45         return SkRect::MakeLargest();
46     }
47     virtual void onDraw(SkCanvas* canvas) override;
48 
49 private:
50     int mEndChildIndex;
51     int mBeginChildIndex;
52     FatVector<RenderNodeDrawable*, 16> mChildren;
53     SkiaDisplayList* mDisplayList;
54 
55     friend class EndReorderBarrierDrawable;
56 };
57 
58 /**
59  * See StartReorderBarrierDrawable.
60  * EndReorderBarrierDrawable relies on StartReorderBarrierDrawable to host and sort the render
61  * nodes by Z index. When EndReorderBarrierDrawable is drawn it will draw all render nodes in the
62  * range with positive Z index. It is also responsible for drawing shadows for the nodes
63  * corresponding to their z-index.
64  */
65 class EndReorderBarrierDrawable : public SkDrawable {
66 public:
67     explicit EndReorderBarrierDrawable(StartReorderBarrierDrawable* startBarrier);
68 protected:
onGetBounds()69     virtual SkRect onGetBounds() override {
70         return SkRect::MakeLargest();
71     }
72     virtual void onDraw(SkCanvas* canvas) override;
73 private:
74     void drawShadow(SkCanvas* canvas, RenderNodeDrawable* caster);
75     StartReorderBarrierDrawable* mStartBarrier;
76 };
77 
78 }; // namespace skiapipeline
79 }; // namespace uirenderer
80 }; // namespace android
81