aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-29 16:02:20 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-29 16:02:20 +0000
commit0ad336f8c6f6f0325eee309c9cd501ea432cc33e (patch)
tree5ce71598d388b28a6ea3d6f03528dc8bb2df88cf /samplecode
parent0bfffc59a0d4967a18cc3c4f429af3f706c18511 (diff)
add shape flatten so they work properly in pictures
add flatten/unflatten to matrix git-svn-id: http://skia.googlecode.com/svn/trunk@242 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleShapes.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/samplecode/SampleShapes.cpp b/samplecode/SampleShapes.cpp
index 81f6e4f6b1..95efd0fb48 100644
--- a/samplecode/SampleShapes.cpp
+++ b/samplecode/SampleShapes.cpp
@@ -2,6 +2,7 @@
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPicture.h"
+#include "SkStream.h"
#include "SkView.h"
#include "SkRectShape.h"
@@ -83,6 +84,20 @@ protected:
canvas->drawColor(0xFFDDDDDD);
}
+ void drawpicture(SkCanvas* canvas, SkPicture& pict) {
+#if 1
+ SkDynamicMemoryWStream ostream;
+ pict.serialize(&ostream);
+
+ SkMemoryStream istream(ostream.getStream(), ostream.getOffset());
+ SkPicture newPict(&istream);
+
+ canvas->drawPicture(newPict);
+#else
+ canvas->drawPicture(pict);
+#endif
+ }
+
int fAngle;
virtual void onDraw(SkCanvas* canvas) {
@@ -105,7 +120,7 @@ protected:
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
gs->appendShape(&fGroup, matrix);
-#if 0
+#if 0
canvas->drawShape(gs);
#else
SkPicture pict;
@@ -116,7 +131,8 @@ protected:
cv->scale(-SK_Scalar1, SK_Scalar1);
cv->drawShape(gs);
pict.endRecording();
- canvas->drawPicture(pict);
+
+ drawpicture(canvas, pict);
#endif
*fMatrixRefs[3] = saveM;