OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 this->endRecording(); | 259 this->endRecording(); |
260 if (fPlayback) { | 260 if (fPlayback) { |
261 fPlayback->draw(*surface, callback); | 261 fPlayback->draw(*surface, callback); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 /////////////////////////////////////////////////////////////////////////////// | 265 /////////////////////////////////////////////////////////////////////////////// |
266 | 266 |
267 #include "SkStream.h" | 267 #include "SkStream.h" |
268 | 268 |
269 static const char kMagic[] = "skiapict"; | |
270 | |
269 bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) { | 271 bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) { |
270 if (NULL == stream) { | 272 if (NULL == stream) { |
271 return false; | 273 return false; |
272 } | 274 } |
273 | 275 |
276 // Check magic bytes. | |
277 uint8_t magic[SK_ARRAY_COUNT(kMagic)]; | |
reed1
2013/10/16 15:26:39
I think this returns 9...
| |
278 stream->read(magic, SK_ARRAY_COUNT(kMagic)); | |
279 if (0 != memcmp(magic, kMagic, SK_ARRAY_COUNT(kMagic))) { | |
280 return false; | |
281 } | |
282 | |
274 SkPictInfo info; | 283 SkPictInfo info; |
275 if (!stream->read(&info, sizeof(SkPictInfo))) { | 284 if (!stream->read(&info, sizeof(SkPictInfo))) { |
276 return false; | 285 return false; |
277 } | 286 } |
278 if (PICTURE_VERSION != info.fVersion | 287 if (PICTURE_VERSION != info.fVersion |
279 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TO O | 288 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TO O |
280 // V13 is backwards compatible with V12 | 289 // V13 is backwards compatible with V12 |
281 && PRIOR_PRIOR_PICTURE_VERSION != info.fVersion // TODO: remove when .s kps regenerated | 290 && PRIOR_PRIOR_PICTURE_VERSION != info.fVersion // TODO: remove when .s kps regenerated |
282 #endif | 291 #endif |
283 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O | 292 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 info.fWidth = fWidth; | 343 info.fWidth = fWidth; |
335 info.fHeight = fHeight; | 344 info.fHeight = fHeight; |
336 info.fFlags = SkPictInfo::kCrossProcess_Flag; | 345 info.fFlags = SkPictInfo::kCrossProcess_Flag; |
337 #ifdef SK_SCALAR_IS_FLOAT | 346 #ifdef SK_SCALAR_IS_FLOAT |
338 info.fFlags |= SkPictInfo::kScalarIsFloat_Flag; | 347 info.fFlags |= SkPictInfo::kScalarIsFloat_Flag; |
339 #endif | 348 #endif |
340 if (8 == sizeof(void*)) { | 349 if (8 == sizeof(void*)) { |
341 info.fFlags |= SkPictInfo::kPtrIs64Bit_Flag; | 350 info.fFlags |= SkPictInfo::kPtrIs64Bit_Flag; |
342 } | 351 } |
343 | 352 |
353 // Write 8 magic bytes to ID this file format. | |
354 stream->write(kMagic, SK_ARRAY_COUNT(kMagic)); | |
355 | |
344 stream->write(&info, sizeof(info)); | 356 stream->write(&info, sizeof(info)); |
345 if (playback) { | 357 if (playback) { |
346 stream->writeBool(true); | 358 stream->writeBool(true); |
347 playback->serialize(stream, encoder); | 359 playback->serialize(stream, encoder); |
348 // delete playback if it is a local version (i.e. cons'd up just now) | 360 // delete playback if it is a local version (i.e. cons'd up just now) |
349 if (playback != fPlayback) { | 361 if (playback != fPlayback) { |
350 SkDELETE(playback); | 362 SkDELETE(playback); |
351 } | 363 } |
352 } else { | 364 } else { |
353 stream->writeBool(false); | 365 stream->writeBool(false); |
354 } | 366 } |
355 } | 367 } |
356 | 368 |
357 #ifdef SK_BUILD_FOR_ANDROID | 369 #ifdef SK_BUILD_FOR_ANDROID |
358 void SkPicture::abortPlayback() { | 370 void SkPicture::abortPlayback() { |
359 if (NULL == fPlayback) { | 371 if (NULL == fPlayback) { |
360 return; | 372 return; |
361 } | 373 } |
362 fPlayback->abort(); | 374 fPlayback->abort(); |
363 } | 375 } |
364 #endif | 376 #endif |
OLD | NEW |