Bump min picture version.
Chrome Stable is M39, which produces picture format v35: https://chromium.googlesource.com/skia/+/chrome/m39/include/core/SkPicture.h We don't need any code to deal with pictures older than v35. (When M40 goes stable, we can step up to v37, the current latest version.) BUG=skia: Review URL: https://codereview.chromium.org/770703002
This commit is contained in:
parent
bb25e44593
commit
88fd0fbccc
@ -251,7 +251,7 @@ private:
|
||||
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
|
||||
|
||||
// Only SKPs within the min/current picture version range (inclusive) can be read.
|
||||
static const uint32_t MIN_PICTURE_VERSION = 19;
|
||||
static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39.
|
||||
static const uint32_t CURRENT_PICTURE_VERSION = 37;
|
||||
|
||||
void createHeader(SkPictInfo* info) const;
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
bool SkFlattenable::NeedsDeepUnflatten(const SkReadBuffer& buffer) {
|
||||
return buffer.isVersionLT(SkReadBuffer::kFlattenCreateProc_Version);
|
||||
return false; // TODO: looks like all this can go away too now?
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -100,11 +100,7 @@ bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) {
|
||||
|
||||
uint32_t flags = buffer.readUInt();
|
||||
fCropRect = CropRect(rect, flags);
|
||||
if (buffer.isVersionLT(SkReadBuffer::kImageFilterUniqueID_Version)) {
|
||||
fUniqueID = next_image_filter_unique_id();
|
||||
} else {
|
||||
fUniqueID = buffer.readUInt();
|
||||
}
|
||||
fUniqueID = buffer.readUInt();
|
||||
return buffer.isValid();
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,6 @@
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) {
|
||||
buffer.readMatrix(&(INHERITED::fLocalMatrix));
|
||||
}
|
||||
fProxyShader.reset(buffer.readShader());
|
||||
if (NULL == fProxyShader.get()) {
|
||||
sk_throw();
|
||||
|
@ -1799,11 +1799,10 @@ static uint32_t pack_4(unsigned a, unsigned b, unsigned c, unsigned d) {
|
||||
#endif
|
||||
|
||||
enum FlatFlags {
|
||||
kHasTypeface_FlatFlag = 0x01,
|
||||
kHasEffects_FlatFlag = 0x02,
|
||||
kHasNonDefaultPaintOptionsAndroid_FlatFlag = 0x04,
|
||||
kHasTypeface_FlatFlag = 0x1,
|
||||
kHasEffects_FlatFlag = 0x2,
|
||||
|
||||
kFlatFlagMask = 0x7,
|
||||
kFlatFlagMask = 0x3,
|
||||
};
|
||||
|
||||
enum BitsPerField {
|
||||
@ -1839,37 +1838,6 @@ static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) {
|
||||
return (FlatFlags)(packed & kFlatFlagMask);
|
||||
}
|
||||
|
||||
// V22_COMPATIBILITY_CODE
|
||||
static FlatFlags unpack_paint_flags_v22(SkPaint* paint, uint32_t packed) {
|
||||
enum {
|
||||
kFilterBitmap_Flag = 0x02,
|
||||
kHighQualityFilterBitmap_Flag = 0x4000,
|
||||
|
||||
kAll_Flags = kFilterBitmap_Flag | kHighQualityFilterBitmap_Flag
|
||||
};
|
||||
|
||||
// previously flags:16, textAlign:8, flatFlags:8
|
||||
// now flags:16, hinting:4, textAlign:4, flatFlags:8
|
||||
unsigned flags = packed >> 16;
|
||||
int filter = 0;
|
||||
if (flags & kFilterBitmap_Flag) {
|
||||
filter |= 1;
|
||||
}
|
||||
if (flags & kHighQualityFilterBitmap_Flag) {
|
||||
filter |= 2;
|
||||
}
|
||||
paint->setFilterLevel((SkPaint::FilterLevel)filter);
|
||||
flags &= ~kAll_Flags; // remove these (now dead) bit flags
|
||||
|
||||
paint->setFlags(flags);
|
||||
|
||||
// hinting added later. 0 in this nibble means use the default.
|
||||
uint32_t hinting = (packed >> 12) & 0xF;
|
||||
paint->setHinting(0 == hinting ? SkPaint::kNormal_Hinting : static_cast<SkPaint::Hinting>(hinting-1));
|
||||
paint->setTextAlign(static_cast<SkPaint::Align>((packed >> 8) & 0xF));
|
||||
return (FlatFlags)(packed & kFlatFlagMask);
|
||||
}
|
||||
|
||||
// The size of a flat paint's POD fields
|
||||
static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) +
|
||||
1 * sizeof(SkColor) +
|
||||
@ -1948,12 +1916,7 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
this->setStrokeMiter(read_scalar(pod));
|
||||
this->setColor(*pod++);
|
||||
|
||||
unsigned flatFlags = 0;
|
||||
if (buffer.isVersionLT(SkReadBuffer::kFilterLevelIsEnum_Version)) {
|
||||
flatFlags = unpack_paint_flags_v22(this, *pod++);
|
||||
} else {
|
||||
flatFlags = unpack_paint_flags(this, *pod++);
|
||||
}
|
||||
unsigned flatFlags = unpack_paint_flags(this, *pod++);
|
||||
|
||||
uint32_t tmp = *pod++;
|
||||
this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
|
||||
@ -1990,14 +1953,6 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
this->setLooper(NULL);
|
||||
this->setImageFilter(NULL);
|
||||
}
|
||||
|
||||
if (buffer.isVersionLT(SkReadBuffer::kRemoveAndroidPaintOpts_Version) &&
|
||||
flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
|
||||
SkString tag;
|
||||
buffer.readUInt();
|
||||
buffer.readString(&tag);
|
||||
buffer.readBool();
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -356,22 +356,10 @@ bool SkPicture::InternalOnly_StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
|
||||
}
|
||||
|
||||
info.fVersion = stream->readU32();
|
||||
|
||||
#ifndef V35_COMPATIBILITY_CODE
|
||||
if (info.fVersion < 35) {
|
||||
info.fCullRect.fLeft = 0;
|
||||
info.fCullRect.fTop = 0;
|
||||
info.fCullRect.fRight = SkIntToScalar(stream->readU32());
|
||||
info.fCullRect.fBottom = SkIntToScalar(stream->readU32());
|
||||
} else {
|
||||
#endif
|
||||
info.fCullRect.fLeft = stream->readScalar();
|
||||
info.fCullRect.fTop = stream->readScalar();
|
||||
info.fCullRect.fRight = stream->readScalar();
|
||||
info.fCullRect.fBottom = stream->readScalar();
|
||||
#ifndef V35_COMPATIBILITY_CODE
|
||||
}
|
||||
#endif
|
||||
info.fCullRect.fLeft = stream->readScalar();
|
||||
info.fCullRect.fTop = stream->readScalar();
|
||||
info.fCullRect.fRight = stream->readScalar();
|
||||
info.fCullRect.fBottom = stream->readScalar();
|
||||
|
||||
info.fFlags = stream->readU32();
|
||||
|
||||
@ -395,20 +383,7 @@ bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer* buffer, SkPictInfo* pInfo
|
||||
}
|
||||
|
||||
info.fVersion = buffer->readUInt();
|
||||
|
||||
#ifndef V35_COMPATIBILITY_CODE
|
||||
if (info.fVersion < 35) {
|
||||
info.fCullRect.fLeft = 0;
|
||||
info.fCullRect.fTop = 0;
|
||||
info.fCullRect.fRight = SkIntToScalar(buffer->readUInt());
|
||||
info.fCullRect.fBottom = SkIntToScalar(buffer->readUInt());
|
||||
} else {
|
||||
#endif
|
||||
buffer->readRect(&info.fCullRect);
|
||||
#ifndef V35_COMPATIBILITY_CODE
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer->readRect(&info.fCullRect);
|
||||
info.fFlags = buffer->readUInt();
|
||||
|
||||
if (!IsValidPictInfo(info)) {
|
||||
|
@ -321,17 +321,7 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
|
||||
break;
|
||||
case SK_PICT_FACTORY_TAG: {
|
||||
SkASSERT(!haveBuffer);
|
||||
// Remove this code when v21 and below are no longer supported. At the
|
||||
// same time add a new 'count' variable and use it rather then reusing 'size'.
|
||||
#ifndef DISABLE_V21_COMPATIBILITY_CODE
|
||||
if (fInfo.fVersion >= 22) {
|
||||
// in v22 this tag's size represents the size of the chunk in bytes
|
||||
// and the number of factory strings is written out separately
|
||||
#endif
|
||||
size = stream->readU32();
|
||||
#ifndef DISABLE_V21_COMPATIBILITY_CODE
|
||||
}
|
||||
#endif
|
||||
size = stream->readU32();
|
||||
fFactoryPlayback = SkNEW_ARGS(SkFactoryPlayback, (size));
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
SkString str;
|
||||
|
@ -265,17 +265,8 @@ bool SkReadBuffer::readBitmap(SkBitmap* bitmap) {
|
||||
// larger deserialize.
|
||||
bitmap->setInfo(SkImageInfo::MakeUnknown(width, height));
|
||||
return true;
|
||||
} else {
|
||||
// A size of zero means the SkBitmap was simply flattened.
|
||||
if (this->isVersionLT(kNoMoreBitmapFlatten_Version)) {
|
||||
SkBitmap tmp;
|
||||
tmp.legacyUnflatten(*this);
|
||||
// just throw this guy away
|
||||
} else {
|
||||
if (SkBitmap::ReadRawPixels(this, bitmap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (SkBitmap::ReadRawPixels(this, bitmap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Could not read the SkBitmap. Use a placeholder bitmap.
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
virtual ~SkReadBuffer();
|
||||
|
||||
enum Version {
|
||||
/*
|
||||
kFilterLevelIsEnum_Version = 23,
|
||||
kGradientFlippedFlag_Version = 24,
|
||||
kDashWritesPhaseIntervals_Version = 25,
|
||||
@ -49,6 +50,7 @@ public:
|
||||
kImageFilterUniqueID_Version = 31,
|
||||
kRemoveAndroidPaintOpts_Version = 32,
|
||||
kFlattenCreateProc_Version = 33,
|
||||
*/
|
||||
kRemoveColorTableAlpha_Version = 36,
|
||||
kDropShadowMode_Version = 37,
|
||||
};
|
||||
@ -112,7 +114,7 @@ public:
|
||||
virtual void readIRect(SkIRect* rect);
|
||||
virtual void readRect(SkRect* rect);
|
||||
virtual void readRegion(SkRegion* region);
|
||||
|
||||
|
||||
virtual void readPath(SkPath* path);
|
||||
void readPaint(SkPaint* paint) { paint->unflatten(*this); }
|
||||
|
||||
|
@ -273,15 +273,6 @@ bool SkColorShader::isOpaque() const {
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) {
|
||||
// V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit the paint's
|
||||
// color. We don't support that any more.
|
||||
if (b.isVersionLT(SkReadBuffer::kColorShaderNoBool_Version)) {
|
||||
if (b.readBool()) {
|
||||
SkDEBUGFAIL("We shouldn't have pictures that recorded the inherited case.");
|
||||
fColor = SK_ColorWHITE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fColor = b.readColor();
|
||||
}
|
||||
#endif
|
||||
|
@ -28,11 +28,7 @@ SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kNoMoreBitmapFlatten_Version)) {
|
||||
fBitmap.legacyUnflatten(buffer);
|
||||
} else {
|
||||
buffer.readBitmap(&fBitmap);
|
||||
}
|
||||
buffer.readBitmap(&fBitmap);
|
||||
buffer.readRect(&fSrcRect);
|
||||
buffer.readRect(&fDstRect);
|
||||
buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect));
|
||||
|
@ -52,7 +52,7 @@ static void outset_for_stroke(SkRect* rect, const SkStrokeRec& rec) {
|
||||
rect->outset(radius, radius);
|
||||
}
|
||||
|
||||
// Attempt to trim the line to minimally cover the cull rect (currently
|
||||
// Attempt to trim the line to minimally cover the cull rect (currently
|
||||
// only works for horizontal and vertical lines).
|
||||
// Return true if processing should continue; false otherwise.
|
||||
static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
|
||||
@ -377,16 +377,7 @@ SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer)
|
||||
, fInitialDashLength(0)
|
||||
, fInitialDashIndex(0)
|
||||
, fIntervalLength(0) {
|
||||
bool useOldPic = buffer.isVersionLT(SkReadBuffer::kDashWritesPhaseIntervals_Version);
|
||||
if (useOldPic) {
|
||||
fInitialDashIndex = buffer.readInt();
|
||||
fInitialDashLength = buffer.readScalar();
|
||||
fIntervalLength = buffer.readScalar();
|
||||
buffer.readBool(); // Dummy for old ScalarToFit field
|
||||
} else {
|
||||
fPhase = buffer.readScalar();
|
||||
}
|
||||
|
||||
fPhase = buffer.readScalar();
|
||||
fCount = buffer.getArrayCount();
|
||||
size_t allocSize = sizeof(SkScalar) * fCount;
|
||||
if (buffer.validateAvailable(allocSize)) {
|
||||
@ -396,20 +387,10 @@ SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer)
|
||||
fIntervals = NULL;
|
||||
}
|
||||
|
||||
if (useOldPic) {
|
||||
fPhase = 0;
|
||||
if (fInitialDashLength != -1) { // Signal for bad dash interval
|
||||
for (int i = 0; i < fInitialDashIndex; ++i) {
|
||||
fPhase += fIntervals[i];
|
||||
}
|
||||
fPhase += fIntervals[fInitialDashIndex] - fInitialDashLength;
|
||||
}
|
||||
} else {
|
||||
// set the internal data members, fPhase should have been between 0 and intervalLength
|
||||
// when written to buffer so no need to adjust it
|
||||
SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount,
|
||||
&fInitialDashLength, &fInitialDashIndex, &fIntervalLength);
|
||||
}
|
||||
// set the internal data members, fPhase should have been between 0 and intervalLength
|
||||
// when written to buffer so no need to adjust it
|
||||
SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount,
|
||||
&fInitialDashLength, &fInitialDashIndex, &fIntervalLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -209,11 +209,6 @@ static uint32_t unpack_flags(uint32_t packed) {
|
||||
}
|
||||
|
||||
SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kNoUnitMappers_Version)) {
|
||||
// skip the old SkUnitMapper slot
|
||||
buffer.skipFlattenable();
|
||||
}
|
||||
|
||||
int colorCount = fColorCount = buffer.getArrayCount();
|
||||
if (colorCount > kColorStorageCount) {
|
||||
size_t allocSize = (sizeof(SkColor) + sizeof(SkScalar) + sizeof(Rec)) * colorCount;
|
||||
@ -318,10 +313,6 @@ void SkGradientShaderBase::FlipGradientColors(SkColor* colorDst, Rec* recDst,
|
||||
memcpy(colorDst, colorsTemp.get(), count * sizeof(SkColor));
|
||||
}
|
||||
|
||||
void SkGradientShaderBase::flipGradientColors() {
|
||||
FlipGradientColors(fOrigColors, fRecs, fOrigColors, fRecs, fColorCount);
|
||||
}
|
||||
|
||||
bool SkGradientShaderBase::isOpaque() const {
|
||||
return fColorsAreOpaque;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
class DescriptorScope : public Descriptor {
|
||||
public:
|
||||
DescriptorScope() {}
|
||||
|
||||
|
||||
bool unflatten(SkReadBuffer&);
|
||||
|
||||
// fColors and fPos always point into local memory, so they can be safely mutated
|
||||
@ -250,11 +250,6 @@ protected:
|
||||
SkColor* colorSrc, Rec* recSrc,
|
||||
int count);
|
||||
|
||||
// V23_COMPATIBILITY_CODE
|
||||
// Used for 2-pt conical gradients since we sort start/end cirlces by radius
|
||||
// Assumes space has already been allocated for fOrigColors
|
||||
void flipGradientColors();
|
||||
|
||||
private:
|
||||
enum {
|
||||
kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space
|
||||
|
@ -346,27 +346,14 @@ SkShader::GradientType SkTwoPointConicalGradient::asAGradient(
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkTwoPointConicalGradient::SkTwoPointConicalGradient(
|
||||
SkReadBuffer& buffer)
|
||||
: INHERITED(buffer),
|
||||
fCenter1(buffer.readPoint()),
|
||||
fCenter2(buffer.readPoint()),
|
||||
fRadius1(buffer.readScalar()),
|
||||
fRadius2(buffer.readScalar()) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kGradientFlippedFlag_Version)) {
|
||||
// V23_COMPATIBILITY_CODE
|
||||
// Sort gradient by radius size for old pictures
|
||||
if (fRadius2 < fRadius1) {
|
||||
SkTSwap(fCenter1, fCenter2);
|
||||
SkTSwap(fRadius1, fRadius2);
|
||||
this->flipGradientColors();
|
||||
fFlippedGrad = true;
|
||||
} else {
|
||||
fFlippedGrad = false;
|
||||
}
|
||||
} else {
|
||||
fFlippedGrad = buffer.readBool();
|
||||
}
|
||||
: INHERITED(buffer)
|
||||
, fCenter1(buffer.readPoint())
|
||||
, fCenter2(buffer.readPoint())
|
||||
, fRadius1(buffer.readScalar())
|
||||
, fRadius2(buffer.readScalar())
|
||||
, fFlippedGrad(buffer.readBool()) {
|
||||
this->init();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) {
|
||||
|
@ -59,8 +59,8 @@ int tool_main(int argc, char** argv) {
|
||||
SkDebugf("Version: %d\n", info.fVersion);
|
||||
}
|
||||
if (FLAGS_cullRect && !FLAGS_quiet) {
|
||||
SkDebugf("Cull Rect: %f,%f,%f,%f\n",
|
||||
info.fCullRect.fLeft, info.fCullRect.fTop,
|
||||
SkDebugf("Cull Rect: %f,%f,%f,%f\n",
|
||||
info.fCullRect.fLeft, info.fCullRect.fTop,
|
||||
info.fCullRect.fRight, info.fCullRect.fBottom);
|
||||
}
|
||||
if (FLAGS_flags && !FLAGS_quiet) {
|
||||
@ -106,15 +106,6 @@ int tool_main(int argc, char** argv) {
|
||||
if (FLAGS_tags && !FLAGS_quiet) {
|
||||
SkDebugf("SK_PICT_FACTORY_TAG %d\n", chunkSize);
|
||||
}
|
||||
// Remove this code when v21 and below are no longer supported
|
||||
#ifndef DISABLE_V21_COMPATIBILITY_CODE
|
||||
if (info.fVersion < 22) {
|
||||
if (!FLAGS_quiet) {
|
||||
SkDebugf("Exiting early due to format limitations\n");
|
||||
}
|
||||
return kSuccess; // TODO: need to store size in bytes
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case SK_PICT_TYPEFACE_TAG:
|
||||
if (FLAGS_tags && !FLAGS_quiet) {
|
||||
|
Loading…
Reference in New Issue
Block a user