2013-02-14 15:36:01 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-07-06 16:10:09 -07:00
|
|
|
#pragma once
|
2013-02-14 15:36:01 -08:00
|
|
|
|
|
|
|
#include <SkCamera.h>
|
|
|
|
#include <SkMatrix.h>
|
|
|
|
|
2013-03-08 13:12:16 -08:00
|
|
|
#include <private/hwui/DrawGlInfo.h>
|
|
|
|
|
2013-10-25 18:30:17 -07:00
|
|
|
#include <utils/KeyedVector.h>
|
2013-09-11 16:23:37 -07:00
|
|
|
#include <utils/LinearAllocator.h>
|
2013-02-14 15:36:01 -08:00
|
|
|
#include <utils/RefBase.h>
|
|
|
|
#include <utils/SortedVector.h>
|
|
|
|
#include <utils/String8.h>
|
2013-06-26 15:45:41 -07:00
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
#include <cutils/compiler.h>
|
|
|
|
|
2013-06-26 15:45:41 -07:00
|
|
|
#include <androidfw/ResourceTypes.h>
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
#include "Debug.h"
|
2014-10-15 15:46:42 -04:00
|
|
|
#include "CanvasProperty.h"
|
2016-04-14 10:38:54 -07:00
|
|
|
#include "GlFunctorLifecycleListener.h"
|
2014-10-15 15:46:42 -04:00
|
|
|
#include "Matrix.h"
|
2014-03-12 16:11:23 -07:00
|
|
|
#include "RenderProperties.h"
|
2013-02-14 15:36:01 -08:00
|
|
|
|
2015-07-29 16:48:58 -07:00
|
|
|
#include <vector>
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
class SkBitmap;
|
|
|
|
class SkPaint;
|
|
|
|
class SkPath;
|
|
|
|
class SkRegion;
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
|
|
|
class Rect;
|
|
|
|
class Layer;
|
|
|
|
|
2015-10-05 13:00:52 -07:00
|
|
|
struct RecordedOp;
|
|
|
|
struct RenderNodeOp;
|
2015-10-15 10:55:15 -07:00
|
|
|
|
|
|
|
typedef RecordedOp BaseOpType;
|
|
|
|
typedef RenderNodeOp NodeOpType;
|
2013-03-08 13:12:16 -08:00
|
|
|
|
2016-05-17 16:50:31 -07:00
|
|
|
namespace VectorDrawable {
|
|
|
|
class Tree;
|
|
|
|
};
|
|
|
|
typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot;
|
|
|
|
|
2016-04-14 10:38:54 -07:00
|
|
|
struct FunctorContainer {
|
|
|
|
Functor* functor;
|
|
|
|
GlFunctorLifecycleListener* listener;
|
|
|
|
};
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
/**
|
2014-02-26 11:00:11 -08:00
|
|
|
* Data structure that holds the list of commands used in display list stream
|
2013-02-14 15:36:01 -08:00
|
|
|
*/
|
2015-10-16 10:24:55 -07:00
|
|
|
class DisplayList {
|
2015-10-05 13:00:52 -07:00
|
|
|
friend class RecordingCanvas;
|
2013-02-14 15:36:01 -08:00
|
|
|
public:
|
2014-08-21 17:41:57 -07:00
|
|
|
struct Chunk {
|
2015-10-16 10:24:55 -07:00
|
|
|
// range of included ops in DisplayList::ops()
|
2014-08-21 17:41:57 -07:00
|
|
|
size_t beginOpIndex;
|
|
|
|
size_t endOpIndex;
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
// range of included children in DisplayList::children()
|
2014-08-21 17:41:57 -07:00
|
|
|
size_t beginChildIndex;
|
|
|
|
size_t endChildIndex;
|
|
|
|
|
|
|
|
// whether children with non-zero Z in the chunk should be reordered
|
|
|
|
bool reorderChildren;
|
2016-07-06 16:10:09 -07:00
|
|
|
|
|
|
|
// clip at the beginning of a reorder section, applied to reordered children
|
2016-04-11 12:24:23 -07:00
|
|
|
const ClipBase* reorderClip;
|
2014-08-21 17:41:57 -07:00
|
|
|
};
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
DisplayList();
|
|
|
|
~DisplayList();
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-11-24 16:40:09 -08:00
|
|
|
// index of DisplayListOp restore, after which projected descendants should be drawn
|
2014-02-05 16:50:41 -08:00
|
|
|
int projectionReceiveIndex;
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
const LsaVector<Chunk>& getChunks() const { return chunks; }
|
|
|
|
const LsaVector<BaseOpType*>& getOps() const { return ops; }
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
const LsaVector<NodeOpType*>& getChildren() const { return children; }
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
const LsaVector<const SkBitmap*>& getBitmapResources() const { return bitmapResources; }
|
2016-04-14 10:38:54 -07:00
|
|
|
const LsaVector<FunctorContainer>& getFunctors() const { return functors; }
|
2016-08-02 17:28:30 -07:00
|
|
|
const LsaVector<VectorDrawableRoot*>& getVectorDrawables() const { return vectorDrawables; }
|
2014-02-26 11:00:11 -08:00
|
|
|
|
2015-10-15 10:55:15 -07:00
|
|
|
size_t addChild(NodeOpType* childOp);
|
2015-10-16 14:23:12 -07:00
|
|
|
|
2014-04-04 16:20:08 -07:00
|
|
|
|
2014-10-31 14:49:06 -07:00
|
|
|
void ref(VirtualLightRefBase* prop) {
|
2015-10-16 14:23:12 -07:00
|
|
|
referenceHolders.push_back(prop);
|
2014-05-01 21:27:37 -07:00
|
|
|
}
|
|
|
|
|
2014-08-21 17:41:57 -07:00
|
|
|
size_t getUsedSize() {
|
|
|
|
return allocator.usedSize();
|
|
|
|
}
|
|
|
|
bool isEmpty() {
|
2015-10-28 16:50:44 -07:00
|
|
|
return ops.empty();
|
2014-08-21 17:41:57 -07:00
|
|
|
}
|
|
|
|
|
2014-02-26 11:00:11 -08:00
|
|
|
private:
|
2015-10-16 14:23:12 -07:00
|
|
|
// allocator into which all ops and LsaVector arrays allocated
|
|
|
|
LinearAllocator allocator;
|
|
|
|
LinearStdAllocator<void*> stdAllocator;
|
2015-10-05 13:00:52 -07:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
LsaVector<Chunk> chunks;
|
|
|
|
LsaVector<BaseOpType*> ops;
|
2014-04-04 16:20:08 -07:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
// list of Ops referring to RenderNode children for quick, non-drawing traversal
|
|
|
|
LsaVector<NodeOpType*> children;
|
2014-04-04 16:20:08 -07:00
|
|
|
|
2015-10-16 14:23:12 -07:00
|
|
|
// Resources - Skia objects + 9 patches referred to by this DisplayList
|
|
|
|
LsaVector<const SkBitmap*> bitmapResources;
|
|
|
|
LsaVector<const SkPath*> pathResources;
|
|
|
|
LsaVector<const Res_png_9patch*> patchResources;
|
|
|
|
LsaVector<std::unique_ptr<const SkPaint>> paints;
|
|
|
|
LsaVector<std::unique_ptr<const SkRegion>> regions;
|
|
|
|
LsaVector< sp<VirtualLightRefBase> > referenceHolders;
|
|
|
|
|
|
|
|
// List of functors
|
2016-04-14 10:38:54 -07:00
|
|
|
LsaVector<FunctorContainer> functors;
|
2014-08-21 17:41:57 -07:00
|
|
|
|
2016-05-17 16:50:31 -07:00
|
|
|
// List of VectorDrawables that need to be notified of pushStaging. Note that this list gets nothing
|
2016-03-02 15:16:28 -08:00
|
|
|
// but a callback during sync DisplayList, unlike the list of functors defined above, which
|
|
|
|
// gets special treatment exclusive for webview.
|
2016-05-17 16:50:31 -07:00
|
|
|
LsaVector<VectorDrawableRoot*> vectorDrawables;
|
2016-03-02 15:16:28 -08:00
|
|
|
|
2014-02-26 11:00:11 -08:00
|
|
|
void cleanupResources();
|
2013-02-14 15:36:01 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|