Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: src/core/SkPicture.cpp

Issue 178383003: Split picture version into min & max supported versions (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Set min picture version to 19 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkPicture.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (!stream->read(magic, sizeof(kMagic)) || 266 if (!stream->read(magic, sizeof(kMagic)) ||
267 (0 != memcmp(magic, kMagic, sizeof(kMagic)))) { 267 (0 != memcmp(magic, kMagic, sizeof(kMagic)))) {
268 return false; 268 return false;
269 } 269 }
270 270
271 SkPictInfo info; 271 SkPictInfo info;
272 if (!stream->read(&info, sizeof(SkPictInfo))) { 272 if (!stream->read(&info, sizeof(SkPictInfo))) {
273 return false; 273 return false;
274 } 274 }
275 275
276 if (PICTURE_VERSION != info.fVersion) { 276 if (info.fVersion < MIN_PICTURE_VERSION || info.fVersion > CURRENT_PICTURE_V ERSION) {
277 return false; 277 return false;
278 } 278 }
279 279
280 if (pInfo != NULL) { 280 if (pInfo != NULL) {
281 *pInfo = info; 281 *pInfo = info;
282 } 282 }
283 return true; 283 return true;
284 } 284 }
285 285
286 bool SkPicture::BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo) { 286 bool SkPicture::BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo) {
287 // Check magic bytes. 287 // Check magic bytes.
288 char magic[sizeof(kMagic)]; 288 char magic[sizeof(kMagic)];
289 289
290 if (!buffer.readByteArray(magic, sizeof(kMagic)) || 290 if (!buffer.readByteArray(magic, sizeof(kMagic)) ||
291 (0 != memcmp(magic, kMagic, sizeof(kMagic)))) { 291 (0 != memcmp(magic, kMagic, sizeof(kMagic)))) {
292 return false; 292 return false;
293 } 293 }
294 294
295 SkPictInfo info; 295 SkPictInfo info;
296 if (!buffer.readByteArray(&info, sizeof(SkPictInfo))) { 296 if (!buffer.readByteArray(&info, sizeof(SkPictInfo))) {
297 return false; 297 return false;
298 } 298 }
299 299
300 if (PICTURE_VERSION != info.fVersion) { 300 if (info.fVersion < MIN_PICTURE_VERSION || info.fVersion > CURRENT_PICTURE_V ERSION) {
301 return false; 301 return false;
302 } 302 }
303 303
304 if (pInfo != NULL) { 304 if (pInfo != NULL) {
305 *pInfo = info; 305 *pInfo = info;
306 } 306 }
307 return true; 307 return true;
308 } 308 }
309 309
310 SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height) 310 SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight)); 355 return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight));
356 } 356 }
357 357
358 void SkPicture::createHeader(void* header) const { 358 void SkPicture::createHeader(void* header) const {
359 // Copy magic bytes at the beginning of the header 359 // Copy magic bytes at the beginning of the header
360 SkASSERT(sizeof(kMagic) == 8); 360 SkASSERT(sizeof(kMagic) == 8);
361 memcpy(header, kMagic, sizeof(kMagic)); 361 memcpy(header, kMagic, sizeof(kMagic));
362 362
363 // Set piture info after magic bytes in the header 363 // Set piture info after magic bytes in the header
364 SkPictInfo* info = (SkPictInfo*)(((char*)header) + sizeof(kMagic)); 364 SkPictInfo* info = (SkPictInfo*)(((char*)header) + sizeof(kMagic));
365 info->fVersion = PICTURE_VERSION; 365 info->fVersion = CURRENT_PICTURE_VERSION;
366 info->fWidth = fWidth; 366 info->fWidth = fWidth;
367 info->fHeight = fHeight; 367 info->fHeight = fHeight;
368 info->fFlags = SkPictInfo::kCrossProcess_Flag; 368 info->fFlags = SkPictInfo::kCrossProcess_Flag;
369 // TODO: remove this flag, since we're always float (now) 369 // TODO: remove this flag, since we're always float (now)
370 info->fFlags |= SkPictInfo::kScalarIsFloat_Flag; 370 info->fFlags |= SkPictInfo::kScalarIsFloat_Flag;
371 371
372 if (8 == sizeof(void*)) { 372 if (8 == sizeof(void*)) {
373 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag; 373 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
374 } 374 }
375 } 375 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 #ifdef SK_BUILD_FOR_ANDROID 426 #ifdef SK_BUILD_FOR_ANDROID
427 void SkPicture::abortPlayback() { 427 void SkPicture::abortPlayback() {
428 if (NULL == fPlayback) { 428 if (NULL == fPlayback) {
429 return; 429 return;
430 } 430 }
431 fPlayback->abort(); 431 fPlayback->abort();
432 } 432 }
433 #endif 433 #endif
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698