Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 1 | /* |
| 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 Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame^] | 17 | #pragma once |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 18 | |
| 19 | #include <SkCamera.h> |
| 20 | #include <SkMatrix.h> |
| 21 | |
Chris Craik | ff78583 | 2013-03-08 13:12:16 -0800 | [diff] [blame] | 22 | #include <private/hwui/DrawGlInfo.h> |
| 23 | |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 24 | #include <utils/KeyedVector.h> |
Chris Craik | c1c5f08 | 2013-09-11 16:23:37 -0700 | [diff] [blame] | 25 | #include <utils/LinearAllocator.h> |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 26 | #include <utils/RefBase.h> |
| 27 | #include <utils/SortedVector.h> |
| 28 | #include <utils/String8.h> |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 29 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 30 | #include <cutils/compiler.h> |
| 31 | |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 32 | #include <androidfw/ResourceTypes.h> |
| 33 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 34 | #include "Debug.h" |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 35 | #include "CanvasProperty.h" |
John Reck | cd1c3eb | 2016-04-14 10:38:54 -0700 | [diff] [blame] | 36 | #include "GlFunctorLifecycleListener.h" |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 37 | #include "Matrix.h" |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 38 | #include "RenderProperties.h" |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 39 | |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 40 | #include <vector> |
| 41 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 42 | class SkBitmap; |
| 43 | class SkPaint; |
| 44 | class SkPath; |
| 45 | class SkRegion; |
| 46 | |
| 47 | namespace android { |
| 48 | namespace uirenderer { |
| 49 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 50 | class Rect; |
| 51 | class Layer; |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 52 | |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 53 | struct RecordedOp; |
| 54 | struct RenderNodeOp; |
Chris Craik | 10ed692 | 2015-10-15 10:55:15 -0700 | [diff] [blame] | 55 | |
| 56 | typedef RecordedOp BaseOpType; |
| 57 | typedef RenderNodeOp NodeOpType; |
Chris Craik | ff78583 | 2013-03-08 13:12:16 -0800 | [diff] [blame] | 58 | |
Doris Liu | 67ce99b | 2016-05-17 16:50:31 -0700 | [diff] [blame] | 59 | namespace VectorDrawable { |
| 60 | class Tree; |
| 61 | }; |
| 62 | typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot; |
| 63 | |
John Reck | cd1c3eb | 2016-04-14 10:38:54 -0700 | [diff] [blame] | 64 | struct FunctorContainer { |
| 65 | Functor* functor; |
| 66 | GlFunctorLifecycleListener* listener; |
| 67 | }; |
| 68 | |
Doris Liu | 1d8e194 | 2016-03-02 15:16:28 -0800 | [diff] [blame] | 69 | /** |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 70 | * Data structure that holds the list of commands used in display list stream |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 71 | */ |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 72 | class DisplayList { |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 73 | friend class RecordingCanvas; |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 74 | public: |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 75 | struct Chunk { |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 76 | // range of included ops in DisplayList::ops() |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 77 | size_t beginOpIndex; |
| 78 | size_t endOpIndex; |
| 79 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 80 | // range of included children in DisplayList::children() |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 81 | 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 Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame^] | 86 | |
| 87 | // clip at the beginning of a reorder section, applied to reordered children |
Chris Craik | d645640 | 2016-04-11 12:24:23 -0700 | [diff] [blame] | 88 | const ClipBase* reorderClip; |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 91 | DisplayList(); |
| 92 | ~DisplayList(); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 93 | |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 94 | // index of DisplayListOp restore, after which projected descendants should be drawn |
Chris Craik | 1df2644 | 2014-02-05 16:50:41 -0800 | [diff] [blame] | 95 | int projectionReceiveIndex; |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 96 | |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 97 | const LsaVector<Chunk>& getChunks() const { return chunks; } |
| 98 | const LsaVector<BaseOpType*>& getOps() const { return ops; } |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 99 | |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 100 | const LsaVector<NodeOpType*>& getChildren() const { return children; } |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 101 | |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 102 | const LsaVector<const SkBitmap*>& getBitmapResources() const { return bitmapResources; } |
John Reck | cd1c3eb | 2016-04-14 10:38:54 -0700 | [diff] [blame] | 103 | const LsaVector<FunctorContainer>& getFunctors() const { return functors; } |
Doris Liu | 67ce99b | 2016-05-17 16:50:31 -0700 | [diff] [blame] | 104 | const LsaVector<VectorDrawableRoot*>& getVectorDrawables() { return vectorDrawables; } |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 105 | |
Chris Craik | 10ed692 | 2015-10-15 10:55:15 -0700 | [diff] [blame] | 106 | size_t addChild(NodeOpType* childOp); |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 107 | |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 108 | |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 109 | void ref(VirtualLightRefBase* prop) { |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 110 | referenceHolders.push_back(prop); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 113 | size_t getUsedSize() { |
| 114 | return allocator.usedSize(); |
| 115 | } |
| 116 | bool isEmpty() { |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 117 | return ops.empty(); |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 118 | } |
| 119 | |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 120 | private: |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 121 | // allocator into which all ops and LsaVector arrays allocated |
Chris Craik | 8afd0f2 | 2014-08-21 17:41:57 -0700 | [diff] [blame] | 122 | LinearAllocator allocator; |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 123 | 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 Reck | cd1c3eb | 2016-04-14 10:38:54 -0700 | [diff] [blame] | 140 | LsaVector<FunctorContainer> functors; |
Chris Craik | b36af87 | 2015-10-16 14:23:12 -0700 | [diff] [blame] | 141 | |
Doris Liu | 67ce99b | 2016-05-17 16:50:31 -0700 | [diff] [blame] | 142 | // List of VectorDrawables that need to be notified of pushStaging. Note that this list gets nothing |
Doris Liu | 1d8e194 | 2016-03-02 15:16:28 -0800 | [diff] [blame] | 143 | // but a callback during sync DisplayList, unlike the list of functors defined above, which |
| 144 | // gets special treatment exclusive for webview. |
Doris Liu | 67ce99b | 2016-05-17 16:50:31 -0700 | [diff] [blame] | 145 | LsaVector<VectorDrawableRoot*> vectorDrawables; |
Doris Liu | 1d8e194 | 2016-03-02 15:16:28 -0800 | [diff] [blame] | 146 | |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 147 | void cleanupResources(); |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 148 | }; |
| 149 | |
Chris Craik | 0776a60 | 2013-02-14 15:36:01 -0800 | [diff] [blame] | 150 | }; // namespace uirenderer |
| 151 | }; // namespace android |