DisplayList.h revision 5e00c7ce063116c11315639f0035aca8ad73e8cc
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 17#pragma once 18 19#include <SkCamera.h> 20#include <SkMatrix.h> 21 22#include <private/hwui/DrawGlInfo.h> 23 24#include <utils/KeyedVector.h> 25#include <utils/LinearAllocator.h> 26#include <utils/RefBase.h> 27#include <utils/SortedVector.h> 28#include <utils/String8.h> 29 30#include <cutils/compiler.h> 31 32#include <androidfw/ResourceTypes.h> 33 34#include "Debug.h" 35#include "CanvasProperty.h" 36#include "GlFunctorLifecycleListener.h" 37#include "Matrix.h" 38#include "RenderProperties.h" 39 40#include <vector> 41 42class SkBitmap; 43class SkPaint; 44class SkPath; 45class SkRegion; 46 47namespace android { 48namespace uirenderer { 49 50class Rect; 51class Layer; 52 53struct RecordedOp; 54struct RenderNodeOp; 55 56typedef RecordedOp BaseOpType; 57typedef RenderNodeOp NodeOpType; 58 59namespace VectorDrawable { 60class Tree; 61}; 62typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot; 63 64struct FunctorContainer { 65 Functor* functor; 66 GlFunctorLifecycleListener* listener; 67}; 68 69/** 70 * Data structure that holds the list of commands used in display list stream 71 */ 72class DisplayList { 73 friend class RecordingCanvas; 74public: 75 struct Chunk { 76 // range of included ops in DisplayList::ops() 77 size_t beginOpIndex; 78 size_t endOpIndex; 79 80 // range of included children in DisplayList::children() 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; 86 87 // clip at the beginning of a reorder section, applied to reordered children 88 const ClipBase* reorderClip; 89 }; 90 91 DisplayList(); 92 ~DisplayList(); 93 94 // index of DisplayListOp restore, after which projected descendants should be drawn 95 int projectionReceiveIndex; 96 97 const LsaVector<Chunk>& getChunks() const { return chunks; } 98 const LsaVector<BaseOpType*>& getOps() const { return ops; } 99 100 const LsaVector<NodeOpType*>& getChildren() const { return children; } 101 102 const LsaVector<const SkBitmap*>& getBitmapResources() const { return bitmapResources; } 103 const LsaVector<FunctorContainer>& getFunctors() const { return functors; } 104 const LsaVector<VectorDrawableRoot*>& getVectorDrawables() { return vectorDrawables; } 105 106 size_t addChild(NodeOpType* childOp); 107 108 109 void ref(VirtualLightRefBase* prop) { 110 referenceHolders.push_back(prop); 111 } 112 113 size_t getUsedSize() { 114 return allocator.usedSize(); 115 } 116 bool isEmpty() { 117 return ops.empty(); 118 } 119 120private: 121 // allocator into which all ops and LsaVector arrays allocated 122 LinearAllocator allocator; 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 140 LsaVector<FunctorContainer> functors; 141 142 // List of VectorDrawables that need to be notified of pushStaging. Note that this list gets nothing 143 // but a callback during sync DisplayList, unlike the list of functors defined above, which 144 // gets special treatment exclusive for webview. 145 LsaVector<VectorDrawableRoot*> vectorDrawables; 146 147 void cleanupResources(); 148}; 149 150}; // namespace uirenderer 151}; // namespace android 152