This allows us to also constify the argument of
SkFlattenableWriteBuffer::writeFlattenable() - which I've recently found
myself const-casting for no apparent good reason.
R=bungeman@google.com, mtklein@google.com, reed@google.com
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/
29143005
git-svn-id: http://skia.googlecode.com/svn/trunk@11862
2bbb7eff-a529-9590-31e7-
b0007b416f81
}
#define SK_DECLARE_UNFLATTENABLE_OBJECT() \
- virtual Factory getFactory() SK_OVERRIDE { return NULL; }
+ virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
- virtual Factory getFactory() SK_OVERRIDE { return CreateProc; } \
+ virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { \
return SkNEW_ARGS(flattenable, (buffer)); \
}
to recreate your class given a buffer (previously written to by your
override of flatten().
*/
- virtual Factory getFactory() = 0;
+ virtual Factory getFactory() const = 0;
static Factory NameToFactory(const char name[]);
static const char* FactoryToName(Factory);
SkPaint::TextEncoding encoding) = 0;
// common data structures
- virtual void writeFlattenable(SkFlattenable* flattenable) = 0;
+ virtual void writeFlattenable(const SkFlattenable* flattenable) = 0;
virtual void writeColor(const SkColor& color) = 0;
virtual void writeColorArray(const SkColor* color, uint32_t count) = 0;
virtual void writePoint(const SkPoint& point) = 0;
protected:
// A helper function so that each subclass does not have to be a friend of SkFlattenable
- void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
+ void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
uint32_t fFlags;
};
const SkStrokeRec&, const SkMatrix&,
const SkRect*) const SK_OVERRIDE;
- virtual Factory getFactory() SK_OVERRIDE;
+ virtual Factory getFactory() const SK_OVERRIDE;
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
paint.flatten(*this);
}
-void SkFlattenableWriteBuffer::flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer) {
+void SkFlattenableWriteBuffer::flattenObject(const SkFlattenable* obj,
+ SkFlattenableWriteBuffer& buffer) {
obj->flatten(buffer);
}
}
}
-void SkOrderedWriteBuffer::writeFlattenable(SkFlattenable* flattenable) {
+void SkOrderedWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) {
/*
* If we have a factoryset, then the first 32bits tell us...
* 0: failure to write the flattenable
virtual void writeEncodedString(const void* value, size_t byteLength,
SkPaint::TextEncoding encoding) SK_OVERRIDE;
- virtual void writeFlattenable(SkFlattenable* flattenable) SK_OVERRIDE;
+ virtual void writeFlattenable(const SkFlattenable* flattenable) SK_OVERRIDE;
virtual void writeColor(const SkColor& color) SK_OVERRIDE;
virtual void writeColorArray(const SkColor* color, uint32_t count) SK_OVERRIDE;
virtual void writePoint(const SkPoint& point) SK_OVERRIDE;
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {}
- virtual Factory getFactory() {
+ virtual Factory getFactory() const {
return CreateProc;
}
return true;
}
-SkFlattenable::Factory SkDashPathEffect::getFactory() {
+SkFlattenable::Factory SkDashPathEffect::getFactory() const {
return fInitialDashLength < 0 ? NULL : CreateProc;
}