Update SkFlattenable buffers to be more modular.
This CL is an effort to stage the conversion to named
parameters for all SkFlattenable commands. This particular
stage only does the following two things...
1. Move flattenable buffers from SkFlattenable.h into
their own header.
2. Update and Add new read write methods for better clarity
and convenience.
BUG=
Review URL: https://codereview.appspot.com/6448095
git-svn-id: http://skia.googlecode.com/svn/trunk@4980 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index c1bb705..537601f 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -9,6 +9,7 @@
#include "SkDashPathEffect.h"
#include "SkBuffer.h"
+#include "SkFlattenableBuffers.h"
#include "SkPathMeasure.h"
static inline int is_even(int x) {
@@ -235,27 +236,26 @@
SkASSERT(fInitialDashLength >= 0);
this->INHERITED::flatten(buffer);
- buffer.write32(fCount);
- buffer.write32(fInitialDashIndex);
+ buffer.writeInt(fInitialDashIndex);
buffer.writeScalar(fInitialDashLength);
buffer.writeScalar(fIntervalLength);
- buffer.write32(fScaleToFit);
- buffer.writeMul4(fIntervals, fCount * sizeof(fIntervals[0]));
+ buffer.writeBool(fScaleToFit);
+ buffer.writeScalarArray(fIntervals, fCount);
}
SkFlattenable* SkDashPathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkDashPathEffect, (buffer));
}
-SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) {
- fCount = buffer.readS32();
- fInitialDashIndex = buffer.readS32();
+SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
+ fInitialDashIndex = buffer.readInt();
fInitialDashLength = buffer.readScalar();
fIntervalLength = buffer.readScalar();
- fScaleToFit = (buffer.readS32() != 0);
+ fScaleToFit = buffer.readBool();
+ fCount = buffer.getArrayCount();
fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount);
- buffer.read(fIntervals, fCount * sizeof(fIntervals[0]));
+ buffer.readScalarArray(fIntervals);
}
///////////////////////////////////////////////////////////////////////////////