blob: cfc0f9b258da4079d371200e6f5be497479f6714 [file] [log] [blame]
Stan Iliev021693b2016-10-17 16:26:15 -04001/*
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"
Mike Reedf3338bd2018-10-09 11:54:39 -040020#include "SkiaUtils.h"
Stan Iliev021693b2016-10-17 16:26:15 -040021
22#include <SkCanvas.h>
23#include <SkDrawable.h>
24#include <utils/FatVector.h>
25
26namespace android {
27namespace uirenderer {
28namespace skiapipeline {
29
30class SkiaDisplayList;
31class EndReorderBarrierDrawable;
32
33/**
34 * StartReorderBarrierDrawable and EndReorderBarrierDrawable work together to define
35 * a sub-list in a display list that need to be drawn out-of-order sorted instead by render
36 * node Z index.
37 * StartReorderBarrierDrawable will sort the entire range and it will draw
38 * render nodes in the range with negative Z index.
39 */
40class StartReorderBarrierDrawable : public SkDrawable {
41public:
42 explicit StartReorderBarrierDrawable(SkiaDisplayList* data);
43
44protected:
Mike Reedf3338bd2018-10-09 11:54:39 -040045 virtual SkRect onGetBounds() override { return SkRectMakeLargest(); }
Stan Iliev021693b2016-10-17 16:26:15 -040046 virtual void onDraw(SkCanvas* canvas) override;
47
48private:
Stan Iliev347691f2016-12-01 12:25:07 -050049 int mEndChildIndex;
50 int mBeginChildIndex;
Stan Iliev021693b2016-10-17 16:26:15 -040051 FatVector<RenderNodeDrawable*, 16> mChildren;
52 SkiaDisplayList* mDisplayList;
53
54 friend class EndReorderBarrierDrawable;
55};
56
57/**
58 * See StartReorderBarrierDrawable.
59 * EndReorderBarrierDrawable relies on StartReorderBarrierDrawable to host and sort the render
60 * nodes by Z index. When EndReorderBarrierDrawable is drawn it will draw all render nodes in the
61 * range with positive Z index. It is also responsible for drawing shadows for the nodes
62 * corresponding to their z-index.
63 */
64class EndReorderBarrierDrawable : public SkDrawable {
65public:
66 explicit EndReorderBarrierDrawable(StartReorderBarrierDrawable* startBarrier);
John Reck1bcacfd2017-11-03 10:12:19 -070067
Stan Iliev021693b2016-10-17 16:26:15 -040068protected:
Mike Reedf3338bd2018-10-09 11:54:39 -040069 virtual SkRect onGetBounds() override { return SkRectMakeLargest(); }
Stan Iliev021693b2016-10-17 16:26:15 -040070 virtual void onDraw(SkCanvas* canvas) override;
John Reck1bcacfd2017-11-03 10:12:19 -070071
Stan Iliev021693b2016-10-17 16:26:15 -040072private:
73 void drawShadow(SkCanvas* canvas, RenderNodeDrawable* caster);
74 StartReorderBarrierDrawable* mStartBarrier;
75};
76
Chris Blume7b8a8082018-11-30 15:51:58 -080077} // namespace skiapipeline
78} // namespace uirenderer
79} // namespace android