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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 | 285 |
286 if (pInfo != NULL) { | 286 if (pInfo != NULL) { |
287 *pInfo = info; | 287 *pInfo = info; |
288 } | 288 } |
289 return true; | 289 return true; |
290 } | 290 } |
291 | 291 |
292 bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo
) { | 292 bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo
) { |
293 // Check magic bytes. | 293 // Check magic bytes. |
294 char magic[sizeof(kMagic)]; | 294 char header[kHeaderSize]; |
295 | 295 |
296 if (!buffer.readByteArray(magic, sizeof(kMagic)) || | 296 if (!buffer.readByteArray(header, kHeaderSize) || |
297 (0 != memcmp(magic, kMagic, sizeof(kMagic)))) { | 297 (0 != memcmp(header, kMagic, sizeof(kMagic)))) { |
298 return false; | 298 return false; |
299 } | 299 } |
300 | 300 |
301 SkPictInfo info; | 301 SkPictInfo* info = reinterpret_cast<SkPictInfo*>(header + sizeof(kMagic)); |
302 if (!buffer.readByteArray(&info, sizeof(SkPictInfo))) { | |
303 return false; | |
304 } | |
305 | 302 |
306 if (info.fVersion < MIN_PICTURE_VERSION || info.fVersion > CURRENT_PICTURE_V
ERSION) { | 303 if (info->fVersion < MIN_PICTURE_VERSION || info->fVersion > CURRENT_PICTURE
_VERSION) { |
307 return false; | 304 return false; |
308 } | 305 } |
309 | 306 |
310 if (pInfo != NULL) { | 307 if (pInfo != NULL) { |
311 *pInfo = info; | 308 *pInfo = *info; |
312 } | 309 } |
313 return true; | 310 return true; |
314 } | 311 } |
315 | 312 |
316 SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height) | 313 SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height) |
317 : fPlayback(playback) | 314 : fPlayback(playback) |
318 , fRecord(NULL) | 315 , fRecord(NULL) |
319 , fWidth(width) | 316 , fWidth(width) |
320 , fHeight(height) {} | 317 , fHeight(height) {} |
321 | 318 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 427 } |
431 | 428 |
432 #ifdef SK_BUILD_FOR_ANDROID | 429 #ifdef SK_BUILD_FOR_ANDROID |
433 void SkPicture::abortPlayback() { | 430 void SkPicture::abortPlayback() { |
434 if (NULL == fPlayback) { | 431 if (NULL == fPlayback) { |
435 return; | 432 return; |
436 } | 433 } |
437 fPlayback->abort(); | 434 fPlayback->abort(); |
438 } | 435 } |
439 #endif | 436 #endif |
OLD | NEW |