Chromium Code Reviews| 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[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; | |
| 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:34:41
could be sizeof or SK_ARRAY_COUNT. I find the form
| |
| 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 SkASSERT(SK_ARRAY_COUNT(kMagic) == 8); | |
| 355 stream->write(kMagic, SK_ARRAY_COUNT(kMagic)); | |
| 356 | |
| 344 stream->write(&info, sizeof(info)); | 357 stream->write(&info, sizeof(info)); |
| 345 if (playback) { | 358 if (playback) { |
| 346 stream->writeBool(true); | 359 stream->writeBool(true); |
| 347 playback->serialize(stream, encoder); | 360 playback->serialize(stream, encoder); |
| 348 // delete playback if it is a local version (i.e. cons'd up just now) | 361 // delete playback if it is a local version (i.e. cons'd up just now) |
| 349 if (playback != fPlayback) { | 362 if (playback != fPlayback) { |
| 350 SkDELETE(playback); | 363 SkDELETE(playback); |
| 351 } | 364 } |
| 352 } else { | 365 } else { |
| 353 stream->writeBool(false); | 366 stream->writeBool(false); |
| 354 } | 367 } |
| 355 } | 368 } |
| 356 | 369 |
| 357 #ifdef SK_BUILD_FOR_ANDROID | 370 #ifdef SK_BUILD_FOR_ANDROID |
| 358 void SkPicture::abortPlayback() { | 371 void SkPicture::abortPlayback() { |
| 359 if (NULL == fPlayback) { | 372 if (NULL == fPlayback) { |
| 360 return; | 373 return; |
| 361 } | 374 } |
| 362 fPlayback->abort(); | 375 fPlayback->abort(); |
| 363 } | 376 } |
| 364 #endif | 377 #endif |
| OLD | NEW |