diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-09 20:02:20 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-09 20:02:20 +0000 |
commit | 5cd3656ed3676730b296722812f5924d06d0cc98 (patch) | |
tree | 3f85384c19a0ed93ce8881da27d4d431ffae5e1b /src | |
parent | cc0c8e6084e140c962ae9a6885992bafea8ec048 (diff) |
Make SkPictures valid regardless of SK_SUPPORT_HINTING_SCALE_FACTOR.
When the build flag is not set, read/write dummy values
so that the creator of an SKP file need not have the same
support/lack of support of the feature as the reader.
Will separately update the checked in skps to the new version when checking in.
BUG=http://code.google.com/p/skia/issues/detail?id=922
Review URL: https://codereview.appspot.com/6642057
git-svn-id: http://skia.googlecode.com/svn/trunk@5869 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPaint.cpp | 22 | ||||
-rw-r--r-- | src/core/SkPicture.cpp | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index f611e6d847..58a8c1c407 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1897,18 +1897,14 @@ enum FlatFlags { }; // The size of a flat paint's POD fields +// Include an SkScalar for hinting scale factor whether it is +// supported or not so that an SKP is valid whether it was +// created with support or not. -#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR static const uint32_t kPODPaintSize = 6 * sizeof(SkScalar) + 1 * sizeof(SkColor) + 1 * sizeof(uint16_t) + 6 * sizeof(uint8_t); -#else -static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + - 1 * sizeof(SkColor) + - 1 * sizeof(uint16_t) + - 6 * sizeof(uint8_t); -#endif /* To save space/time, we analyze the paint, and write a truncated version of it if there are not tricky elements like shaders, etc. @@ -1940,6 +1936,9 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { ptr = write_scalar(ptr, this->getTextSkewX()); #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR ptr = write_scalar(ptr, this->getHintingScaleFactor()); +#else + // Dummy value. + ptr = write_scalar(ptr, SK_Scalar1); #endif ptr = write_scalar(ptr, this->getStrokeWidth()); ptr = write_scalar(ptr, this->getStrokeMiter()); @@ -1959,6 +1958,9 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { buffer.writeScalar(fTextSkewX); #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR buffer.writeScalar(fHintingScaleFactor); +#else + // Dummy value. + buffer.writeScalar(SK_Scalar1); #endif buffer.writeScalar(fWidth); buffer.writeScalar(fMiterLimit); @@ -2007,6 +2009,9 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { this->setTextSkewX(read_scalar(pod)); #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR this->setHintingScaleFactor(read_scalar(pod)); +#else + // Skip the hinting scalar factor, which is not supported. + read_scalar(pod); #endif this->setStrokeWidth(read_scalar(pod)); this->setStrokeMiter(read_scalar(pod)); @@ -2036,6 +2041,9 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { this->setTextSkewX(buffer.readScalar()); #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR this->setHintingScaleFactor(buffer.readScalar()); +#else + // Skip the hinting scalar factor, which is not supported. + buffer.readScalar(); #endif this->setStrokeWidth(buffer.readScalar()); this->setStrokeMiter(buffer.readScalar()); diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 3e356cedef..cc73bda5e4 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -243,8 +243,10 @@ void SkPicture::draw(SkCanvas* surface) { // V5 : don't read/write FunctionPtr on cross-process (we can detect that) // V6 : added serialization of SkPath's bounds (and packed its flags tighter) // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) -// V8 : PNG encode bitmaps -#define PICTURE_VERSION 8 +// V8 : Add an option for encoding bitmaps +// V9 : Allow the reader and writer of an SKP disagree on whether to support +// SK_SUPPORT_HINTING_SCALE_FACTOR +#define PICTURE_VERSION 9 SkPicture::SkPicture(SkStream* stream, bool* success, SkSerializationHelpers::DecodeBitmap decoder) : SkRefCnt() { if (success) { |