aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 19:46:58 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 19:46:58 +0000
commit11e055518a0cbe5329232a55fe2cd177e83836d8 (patch)
treeb3edebfa12a9ad252c11cbea29482c22bdcc6541
parentf8cb184095946ebf8f183d253e27bd544a19f23c (diff)
Code cleanup following recapture of skps
-rw-r--r--include/core/SkPath.h11
-rw-r--r--include/core/SkPicture.h8
-rw-r--r--src/core/SkPath.cpp7
-rw-r--r--src/core/SkPicture.cpp11
-rw-r--r--src/core/SkPicturePlayback.cpp13
-rw-r--r--src/effects/SkBlurMaskFilter.cpp16
-rw-r--r--src/effects/SkEmbossMaskFilter.cpp16
7 files changed, 17 insertions, 65 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 0388739cff..0b2ea61b96 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -932,16 +932,11 @@ public:
private:
enum SerializationOffsets {
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
- kNewFormat2_SerializationShift = 29, // requires 1 bit
-#endif
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- kNewFormat_SerializationShift = 28, // requires 1 bit
+ kNewFormat_SerializationShift = 29, // requires 1 bit
#endif
+ kUnused1_SerializationShift = 28, // 1 free bit
kDirection_SerializationShift = 26, // requires 2 bits
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- // rename to kUnused_SerializationShift
- kOldIsFinite_SerializationShift = 25, // 1 bit
-#endif
+ kUnused2_SerializationShift = 25, // 1 free bit
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
kOldIsOval_SerializationShift = 24, // requires 1 bit
#endif
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 552a1f9ad5..bce343ec04 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -220,14 +220,8 @@ protected:
// V14: Add flags word to PathRef serialization
// V15: Remove A1 bitmpa config (and renumber remaining configs)
// V16: Move SkPath's isOval flag to SkPathRef
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- static const uint32_t PRIOR_PRIOR_PICTURE_VERSION = 12; // TODO: remove when .skps regenerated
-#endif
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- static const uint32_t PRIOR_PICTURE_VERSION2 = 13; // TODO: remove when .skps regenerated
-#endif
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
- static const uint32_t PRIOR_PICTURE_VERSION3 = 15; // TODO: remove when .skps regenerated
+ static const uint32_t PRIOR_PICTURE_VERSION = 15; // TODO: remove when .skps regenerated
#endif
static const uint32_t PICTURE_VERSION = 16;
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 571452a7d9..6c48e56b5f 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2049,11 +2049,8 @@ size_t SkPath::writeToMemory(void* storage) const {
(fFillType << kFillType_SerializationShift) |
(fSegmentMask << kSegmentMask_SerializationShift) |
(fDirection << kDirection_SerializationShift)
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- | (0x1 << kNewFormat_SerializationShift)
-#endif
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
- | (0x1 << kNewFormat2_SerializationShift)
+ | (0x1 << kNewFormat_SerializationShift)
#endif
;
@@ -2078,7 +2075,7 @@ size_t SkPath::readFromMemory(const void* storage, size_t length) {
fSegmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF;
fDirection = (packed >> kDirection_SerializationShift) & 0x3;
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
- bool newFormat = (packed >> kNewFormat2_SerializationShift) & 1;
+ bool newFormat = (packed >> kNewFormat_SerializationShift) & 1;
#endif
SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index a5faf4d0a0..9531d189ef 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -284,18 +284,11 @@ bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
if (!stream->read(&info, sizeof(SkPictInfo))) {
return false;
}
+
if (PICTURE_VERSION != info.fVersion
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- // V13 is backwards compatible with V12
- && PRIOR_PRIOR_PICTURE_VERSION != info.fVersion // TODO: remove when .skps regenerated
-#endif
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- // V14 is backwards compatible with V13
- && PRIOR_PICTURE_VERSION2 != info.fVersion // TODO: remove when .skps regenerated
-#endif
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
// V16 is backwards compatible with V15
- && PRIOR_PICTURE_VERSION3 != info.fVersion // TODO: remove when .skps regenerated
+ && PRIOR_PICTURE_VERSION != info.fVersion // TODO: remove when .skps regenerated
#endif
) {
return false;
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 5a016d48d6..82c7a03bcd 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -882,18 +882,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
const SkRect* src = this->getRectPtr(reader); // may be null
const SkRect& dst = reader.skipT<SkRect>(); // required
SkCanvas::DrawBitmapRectFlags flags;
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- flags = SkCanvas::kNone_DrawBitmapRectFlag;
- // TODO: remove this backwards compatibility code once the .skps are
- // regenerated
- SkASSERT(32 == size || 48 == size || // old sizes
- 36 == size || 52 == size); // new sizes
- if (36 == size || 52 == size) {
-#endif
- flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt();
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- }
-#endif
+ flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt();
canvas.drawBitmapRectToRect(bitmap, src, dst, paint, flags);
} break;
case DRAW_BITMAP_MATRIX: {
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 9ed6d0c0bb..d2c43d719b 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -483,18 +483,10 @@ void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src,
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkFlattenableReadBuffer& buffer)
: SkMaskFilter(buffer) {
- fSigma = buffer.readScalar();
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- // Fixing this must be done in two stages. When the skps are recaptured in V13,
- // remove the ConvertRadiusToSigma but retain the absolute value.
- // At the same time, switch the code in flatten to write a positive value.
- // When the skps are captured in V14 the absolute value can be removed.
- if (fSigma > 0) {
- fSigma = SkBlurMask::ConvertRadiusToSigma(fSigma);
- } else {
- fSigma = -fSigma;
- }
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
+ // TODO: when the skps are recaptured at > v15 the SkScalarAbs can be removed
#endif
+ fSigma = SkScalarAbs(buffer.readScalar());
fBlurStyle = (SkBlurMaskFilter::BlurStyle)buffer.readInt();
fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag;
SkASSERT(fSigma >= 0);
@@ -503,7 +495,7 @@ SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkFlattenableReadBuffer& buffer)
void SkBlurMaskFilterImpl::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- buffer.writeScalar(-fSigma);
+ buffer.writeScalar(fSigma);
buffer.writeInt(fBlurStyle);
buffer.writeUInt(fBlurFlags);
}
diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp
index 2d3125000c..905cfab941 100644
--- a/src/effects/SkEmbossMaskFilter.cpp
+++ b/src/effects/SkEmbossMaskFilter.cpp
@@ -134,18 +134,10 @@ SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer)
SkASSERT(buffer.getArrayCount() == sizeof(Light));
buffer.readByteArray(&fLight, sizeof(Light));
SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean
- fBlurSigma = buffer.readScalar();
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- // Fixing this must be done in two stages. When the skps are recaptured in V13,
- // remove the ConvertRadiusToSigma but retain the absolute value.
- // At the same time, switch the code in flatten to write a positive value.
- // When the skps are captured in V14 the absolute value can be removed.
- if (fBlurSigma > 0) {
- fBlurSigma = SkBlurMask::ConvertRadiusToSigma(fBlurSigma);
- } else {
- fBlurSigma = -fBlurSigma;
- }
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
+ // TODO: Once skps are recaptured in > v15 this SkScalarAbs can be removed
#endif
+ fBlurSigma = SkScalarAbs(buffer.readScalar());
}
void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
@@ -154,7 +146,7 @@ void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
Light tmpLight = fLight;
tmpLight.fPad = 0; // for the font-cache lookup to be clean
buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
- buffer.writeScalar(-fBlurSigma);
+ buffer.writeScalar(fBlurSigma);
}
#ifdef SK_DEVELOPER