summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Snapshot.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/Snapshot.h')
-rw-r--r--libs/hwui/Snapshot.h96
1 files changed, 76 insertions, 20 deletions
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 038aea8..435736c 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -20,6 +20,7 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+#include <utils/LinearAllocator.h>
#include <utils/RefBase.h>
#include <ui/Region.h>
@@ -27,12 +28,40 @@
#include "Layer.h"
#include "Matrix.h"
+#include "Outline.h"
#include "Rect.h"
+#include "utils/Macros.h"
namespace android {
namespace uirenderer {
/**
+ * Temporary structure holding information for a single outline clip.
+ *
+ * These structures are treated as immutable once created, and only exist for a single frame, which
+ * is why they may only be allocated with a LinearAllocator.
+ */
+class RoundRectClipState {
+public:
+ /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/
+ static void* operator new(size_t size, LinearAllocator& allocator) {
+ return allocator.alloc(size);
+ }
+
+ bool areaRequiresRoundRectClip(const Rect& rect) const {
+ return rect.intersects(dangerRects[0])
+ || rect.intersects(dangerRects[1])
+ || rect.intersects(dangerRects[2])
+ || rect.intersects(dangerRects[3]);
+ }
+
+ Matrix4 matrix;
+ Rect dangerRects[4];
+ Rect outlineInnerRect;
+ float outlineRadius;
+};
+
+/**
* A snapshot holds information about the current state of the rendering
* surface. A snapshot is usually created whenever the user calls save()
* and discarded when the user calls restore(). Once a snapshot is created,
@@ -65,17 +94,16 @@ public:
* Indicates that this snapshot is a special type of layer
* backed by an FBO. This flag only makes sense when the
* flag kFlagIsLayer is also set.
+ *
+ * Viewport has been modified to fit the new Fbo, and must be
+ * restored when this snapshot is restored.
*/
kFlagIsFboLayer = 0x4,
/**
- * Indicates that this snapshot has changed the ortho matrix.
- */
- kFlagDirtyOrtho = 0x8,
- /**
* Indicates that this snapshot or an ancestor snapshot is
* an FBO layer.
*/
- kFlagFboTarget = 0x10
+ kFlagFboTarget = 0x8,
};
/**
@@ -125,6 +153,19 @@ public:
*/
void resetTransform(float x, float y, float z);
+ void initializeViewport(int width, int height) {
+ mViewportData.initialize(width, height);
+ }
+
+ int getViewportWidth() const { return mViewportData.mWidth; }
+ int getViewportHeight() const { return mViewportData.mHeight; }
+ const Matrix4& getOrthoMatrix() const { return mViewportData.mOrthoMatrix; }
+
+ /**
+ * Sets (and replaces) the current clipping outline
+ */
+ void setClippingOutline(LinearAllocator& allocator, const Outline* outline);
+
/**
* Indicates whether this snapshot should be ignored. A snapshot
* is typicalled ignored if its layer is invisible or empty.
@@ -173,21 +214,6 @@ public:
bool empty;
/**
- * Current viewport.
- */
- Rect viewport;
-
- /**
- * Height of the framebuffer the snapshot is rendering into.
- */
- int height;
-
- /**
- * Contains the previous ortho matrix.
- */
- mat4 orthoMatrix;
-
- /**
* Local transformation. Holds the current translation, scale and
* rotation values.
*
@@ -233,9 +259,38 @@ public:
*/
float alpha;
+ /**
+ * Current clipping round rect.
+ *
+ * Points to data not owned by the snapshot, and may only be replaced by subsequent RR clips,
+ * never modified.
+ */
+ const RoundRectClipState* roundRectClipState;
+
void dump() const;
private:
+ struct ViewportData {
+ ViewportData() : mWidth(0), mHeight() {}
+ void initialize(int width, int height) {
+ mWidth = width;
+ mHeight = height;
+ mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
+ }
+
+ /*
+ * Width and height of current viewport.
+ *
+ * The viewport is always defined to be (0, 0, width, height).
+ */
+ int mWidth;
+ int mHeight;
+ /**
+ * Contains the current orthographic, projection matrix.
+ */
+ mat4 mOrthoMatrix;
+ };
+
void ensureClipRegion();
void copyClipRectFromRegion();
@@ -246,6 +301,7 @@ private:
Rect mLocalClip; // don't use directly, call getLocalClip() which initializes this
SkRegion mClipRegionRoot;
+ ViewportData mViewportData;
}; // class Snapshot