summaryrefslogtreecommitdiff
path: root/libs/hwui/OpenGLRenderer.h
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2010-06-22 18:56:38 -0700
committer Romain Guy <romainguy@google.com> 2010-06-23 12:36:03 -0700
commitbb9524b6bdddc7ac77d8628daa8b366b8a7be4a4 (patch)
treeb38978e88e8434e0a4bd8ac8e5c70bf2af26b3ea /libs/hwui/OpenGLRenderer.h
parent03f0292744094ec107ffce71301c394503a31ded (diff)
Add implementations for clipRect(), save() and restore().
The current implementation of clipRect() does not apply local transformations before setting the new clip. Change-Id: I5997871bb638dfcd1a8ef96354846af52427e445
Diffstat (limited to 'libs/hwui/OpenGLRenderer.h')
-rw-r--r--libs/hwui/OpenGLRenderer.h46
1 files changed, 45 insertions, 1 deletions
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 12363360b65f..8a541fcf3a81 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -19,8 +19,32 @@
#include <SkXfermode.h>
+#include <utils/RefBase.h>
+
+#include "Rect.h"
+
namespace android {
+class Snapshot: public LightRefBase<Snapshot> {
+public:
+ Snapshot() { }
+
+ Snapshot(const sp<Snapshot> s): clipRect(s->clipRect), flags(0), previous(s) { }
+
+ enum Flags {
+ kFlagClipSet = 0x1,
+ };
+
+ // Clipping rectangle at the time of this snapshot
+ Rect clipRect;
+
+ // Dirty flags
+ int flags;
+
+ // Previous snapshot in the frames stack
+ sp<Snapshot> previous;
+}; // struct Snapshot
+
class OpenGLRenderer {
public:
OpenGLRenderer();
@@ -29,12 +53,32 @@ public:
void setViewport(int width, int height);
void prepare();
+ int getSaveCount() const;
+ int save(int flags);
+ void restore();
+ void restoreToCount(int saveCount);
+
+ bool clipRect(float left, float top, float right, float bottom);
+
void drawColor(int color, SkXfermode::Mode mode);
private:
+ int saveSnapshot();
+ bool restoreSnapshot();
+
+ void setScissorFromClip();
+
+ // Dimensions of the drawing surface
+ int mWidth, mHeight;
+
// Matrix used for ortho projection in shaders
float mOrthoMatrix[16];
-};
+
+ // Number of saved states
+ int mSaveCount;
+ // Current state
+ sp<Snapshot> mSnapshot;
+}; // class OpenGLRenderer
}; // namespace android