aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkLayerInfo.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-11-12 09:32:34 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-12 09:32:34 -0800
commit82365915476caedc130d0e36012a1ce0c007c4ae (patch)
tree09a36cd23f34cdd609b4279ecad52c0b0b3868ac /src/core/SkLayerInfo.h
parentac6a2f964ee9821df6a4a8f3c46796322a4c37b8 (diff)
Rename GrAccelData to SkLayerInfo and move it to src/core
Diffstat (limited to 'src/core/SkLayerInfo.h')
-rw-r--r--src/core/SkLayerInfo.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/core/SkLayerInfo.h b/src/core/SkLayerInfo.h
new file mode 100644
index 0000000000..dd0eaf032a
--- /dev/null
+++ b/src/core/SkLayerInfo.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkLayerInfo_DEFINED
+#define SkLayerInfo_DEFINED
+
+#include "SkPicture.h"
+#include "SkTArray.h"
+
+// This class stores information about the saveLayer/restore pairs found
+// within an SkPicture. It is used by Ganesh to perform layer hoisting.
+class SkLayerInfo : public SkPicture::AccelData {
+public:
+ // Information about a given saveLayer/restore block in an SkPicture
+ class BlockInfo {
+ public:
+ BlockInfo() : fPicture(NULL), fPaint(NULL) {}
+ ~BlockInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); }
+
+ // The picture owning the layer. If the owning picture is the top-most
+ // one (i.e., the picture for which this SkLayerInfo was created) then
+ // this pointer is NULL. If it is a nested picture then the pointer
+ // is non-NULL and owns a ref on the picture.
+ const SkPicture* fPicture;
+ // The device space bounds of this layer.
+ SkRect fBounds;
+ // The pre-matrix begins as the identity and accumulates the transforms
+ // of the containing SkPictures (if any). This matrix state has to be
+ // part of the initial matrix during replay so that it will be
+ // preserved across setMatrix calls.
+ SkMatrix fPreMat;
+ // The matrix state (in the leaf picture) in which this layer's draws
+ // must occur. It will/can be overridden by setMatrix calls in the
+ // layer itself. It does not include the translation needed to map the
+ // layer's top-left point to the origin (which must be part of the
+ // initial matrix).
+ SkMatrix fLocalMat;
+ // The paint to use on restore. Can be NULL since it is optional.
+ const SkPaint* fPaint;
+ // The index of this saveLayer in the picture.
+ size_t fSaveLayerOpID;
+ // The index of the matching restore in the picture.
+ size_t fRestoreOpID;
+ // True if this saveLayer has at least one other saveLayer nested within it.
+ // False otherwise.
+ bool fHasNestedLayers;
+ // True if this saveLayer is nested within another. False otherwise.
+ bool fIsNested;
+ };
+
+ SkLayerInfo(Key key) : INHERITED(key) { }
+
+ BlockInfo& addBlock() { return fBlocks.push_back(); }
+
+ int numBlocks() const { return fBlocks.count(); }
+
+ const BlockInfo& block(int index) const {
+ SkASSERT(index < fBlocks.count());
+
+ return fBlocks[index];
+ }
+
+ // We may, in the future, need to pass in the GPUDevice in order to
+ // incorporate the clip and matrix state into the key
+ static SkPicture::AccelData::Key ComputeKey();
+
+private:
+ SkTArray<BlockInfo, true> fBlocks;
+
+ typedef SkPicture::AccelData INHERITED;
+};
+
+#endif // SkLayerInfo_DEFINED