blob: a8205c854c148d37d959a1e5a6f36bff8ad96a1e [file] [log] [blame]
Chris Craik0776a602013-02-14 15:36:01 -08001/*
2 * Copyright (C) 2013 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
Chris Craik5e00c7c2016-07-06 16:10:09 -070017#pragma once
Chris Craik0776a602013-02-14 15:36:01 -080018
19#include <SkCamera.h>
20#include <SkMatrix.h>
21
Chris Craikff785832013-03-08 13:12:16 -080022#include <private/hwui/DrawGlInfo.h>
23
Chris Craikf57776b2013-10-25 18:30:17 -070024#include <utils/KeyedVector.h>
Chris Craikc1c5f082013-09-11 16:23:37 -070025#include <utils/LinearAllocator.h>
Chris Craik0776a602013-02-14 15:36:01 -080026#include <utils/RefBase.h>
27#include <utils/SortedVector.h>
28#include <utils/String8.h>
Romain Guye3b0a012013-06-26 15:45:41 -070029
Chris Craik0776a602013-02-14 15:36:01 -080030#include <cutils/compiler.h>
31
Romain Guye3b0a012013-06-26 15:45:41 -070032#include <androidfw/ResourceTypes.h>
33
Chris Craik0776a602013-02-14 15:36:01 -080034#include "Debug.h"
Tom Hudson2dc236b2014-10-15 15:46:42 -040035#include "CanvasProperty.h"
John Reckcd1c3eb2016-04-14 10:38:54 -070036#include "GlFunctorLifecycleListener.h"
Tom Hudson2dc236b2014-10-15 15:46:42 -040037#include "Matrix.h"
John Reckacb6f072014-03-12 16:11:23 -070038#include "RenderProperties.h"
Chris Craik0776a602013-02-14 15:36:01 -080039
John Reck272a6852015-07-29 16:48:58 -070040#include <vector>
41
Chris Craik0776a602013-02-14 15:36:01 -080042class SkBitmap;
43class SkPaint;
44class SkPath;
45class SkRegion;
46
47namespace android {
48namespace uirenderer {
49
Chris Craik0776a602013-02-14 15:36:01 -080050class Rect;
51class Layer;
Chris Craik0776a602013-02-14 15:36:01 -080052
Chris Craikb565df12015-10-05 13:00:52 -070053struct RecordedOp;
54struct RenderNodeOp;
Chris Craik10ed6922015-10-15 10:55:15 -070055
56typedef RecordedOp BaseOpType;
57typedef RenderNodeOp NodeOpType;
Chris Craikff785832013-03-08 13:12:16 -080058
Doris Liu67ce99b2016-05-17 16:50:31 -070059namespace VectorDrawable {
60class Tree;
61};
62typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot;
63
John Reckcd1c3eb2016-04-14 10:38:54 -070064struct FunctorContainer {
65 Functor* functor;
66 GlFunctorLifecycleListener* listener;
67};
68
Doris Liu1d8e1942016-03-02 15:16:28 -080069/**
John Reck44fd8d22014-02-26 11:00:11 -080070 * Data structure that holds the list of commands used in display list stream
Chris Craik0776a602013-02-14 15:36:01 -080071 */
Chris Craik003cc3d2015-10-16 10:24:55 -070072class DisplayList {
Chris Craikb565df12015-10-05 13:00:52 -070073 friend class RecordingCanvas;
Chris Craik0776a602013-02-14 15:36:01 -080074public:
Chris Craik8afd0f22014-08-21 17:41:57 -070075 struct Chunk {
Chris Craik003cc3d2015-10-16 10:24:55 -070076 // range of included ops in DisplayList::ops()
Chris Craik8afd0f22014-08-21 17:41:57 -070077 size_t beginOpIndex;
78 size_t endOpIndex;
79
Chris Craik003cc3d2015-10-16 10:24:55 -070080 // range of included children in DisplayList::children()
Chris Craik8afd0f22014-08-21 17:41:57 -070081 size_t beginChildIndex;
82 size_t endChildIndex;
83
84 // whether children with non-zero Z in the chunk should be reordered
85 bool reorderChildren;
Chris Craik5e00c7c2016-07-06 16:10:09 -070086
87 // clip at the beginning of a reorder section, applied to reordered children
Chris Craikd6456402016-04-11 12:24:23 -070088 const ClipBase* reorderClip;
Chris Craik8afd0f22014-08-21 17:41:57 -070089 };
90
Chris Craik003cc3d2015-10-16 10:24:55 -070091 DisplayList();
92 ~DisplayList();
John Reck44fd8d22014-02-26 11:00:11 -080093
Chris Craik8d1f2122015-11-24 16:40:09 -080094 // index of DisplayListOp restore, after which projected descendants should be drawn
Chris Craik1df26442014-02-05 16:50:41 -080095 int projectionReceiveIndex;
John Reck44fd8d22014-02-26 11:00:11 -080096
Chris Craikb36af872015-10-16 14:23:12 -070097 const LsaVector<Chunk>& getChunks() const { return chunks; }
98 const LsaVector<BaseOpType*>& getOps() const { return ops; }
John Reck44fd8d22014-02-26 11:00:11 -080099
Chris Craikb36af872015-10-16 14:23:12 -0700100 const LsaVector<NodeOpType*>& getChildren() const { return children; }
John Reck44fd8d22014-02-26 11:00:11 -0800101
Chris Craikb36af872015-10-16 14:23:12 -0700102 const LsaVector<const SkBitmap*>& getBitmapResources() const { return bitmapResources; }
John Reckcd1c3eb2016-04-14 10:38:54 -0700103 const LsaVector<FunctorContainer>& getFunctors() const { return functors; }
Doris Liu67ce99b2016-05-17 16:50:31 -0700104 const LsaVector<VectorDrawableRoot*>& getVectorDrawables() { return vectorDrawables; }
John Reck44fd8d22014-02-26 11:00:11 -0800105
Chris Craik10ed6922015-10-15 10:55:15 -0700106 size_t addChild(NodeOpType* childOp);
Chris Craikb36af872015-10-16 14:23:12 -0700107
John Reck087bc0c2014-04-04 16:20:08 -0700108
John Reck0e89e2b2014-10-31 14:49:06 -0700109 void ref(VirtualLightRefBase* prop) {
Chris Craikb36af872015-10-16 14:23:12 -0700110 referenceHolders.push_back(prop);
John Reck52244ff2014-05-01 21:27:37 -0700111 }
112
Chris Craik8afd0f22014-08-21 17:41:57 -0700113 size_t getUsedSize() {
114 return allocator.usedSize();
115 }
116 bool isEmpty() {
Chris Craik0b7e8242015-10-28 16:50:44 -0700117 return ops.empty();
Chris Craik8afd0f22014-08-21 17:41:57 -0700118 }
119
John Reck44fd8d22014-02-26 11:00:11 -0800120private:
Chris Craikb36af872015-10-16 14:23:12 -0700121 // allocator into which all ops and LsaVector arrays allocated
Chris Craik8afd0f22014-08-21 17:41:57 -0700122 LinearAllocator allocator;
Chris Craikb36af872015-10-16 14:23:12 -0700123 LinearStdAllocator<void*> stdAllocator;
124
125 LsaVector<Chunk> chunks;
126 LsaVector<BaseOpType*> ops;
127
128 // list of Ops referring to RenderNode children for quick, non-drawing traversal
129 LsaVector<NodeOpType*> children;
130
131 // Resources - Skia objects + 9 patches referred to by this DisplayList
132 LsaVector<const SkBitmap*> bitmapResources;
133 LsaVector<const SkPath*> pathResources;
134 LsaVector<const Res_png_9patch*> patchResources;
135 LsaVector<std::unique_ptr<const SkPaint>> paints;
136 LsaVector<std::unique_ptr<const SkRegion>> regions;
137 LsaVector< sp<VirtualLightRefBase> > referenceHolders;
138
139 // List of functors
John Reckcd1c3eb2016-04-14 10:38:54 -0700140 LsaVector<FunctorContainer> functors;
Chris Craikb36af872015-10-16 14:23:12 -0700141
Doris Liu67ce99b2016-05-17 16:50:31 -0700142 // List of VectorDrawables that need to be notified of pushStaging. Note that this list gets nothing
Doris Liu1d8e1942016-03-02 15:16:28 -0800143 // but a callback during sync DisplayList, unlike the list of functors defined above, which
144 // gets special treatment exclusive for webview.
Doris Liu67ce99b2016-05-17 16:50:31 -0700145 LsaVector<VectorDrawableRoot*> vectorDrawables;
Doris Liu1d8e1942016-03-02 15:16:28 -0800146
John Reck44fd8d22014-02-26 11:00:11 -0800147 void cleanupResources();
Chris Craik0776a602013-02-14 15:36:01 -0800148};
149
Chris Craik0776a602013-02-14 15:36:01 -0800150}; // namespace uirenderer
151}; // namespace android