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

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

Issue 176863004: Add new skpinfo tool (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review comments Created 6 years, 9 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
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 353 }
354 354
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 picture 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 = CURRENT_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 }
376 376
377 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { 377 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
378 SkPicturePlayback* playback = fPlayback; 378 SkPicturePlayback* playback = fPlayback;
379 379
380 if (NULL == playback && fRecord) { 380 if (NULL == playback && fRecord) {
381 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); 381 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
382 } 382 }
383 383
384 char header[kHeaderSize]; 384 char header[kHeaderSize];
385 createHeader(&header); 385 this->createHeader(&header);
386 stream->write(header, kHeaderSize); 386 stream->write(header, kHeaderSize);
387 if (playback) { 387 if (playback) {
388 stream->writeBool(true); 388 stream->writeBool(true);
389 playback->serialize(stream, encoder); 389 playback->serialize(stream, encoder);
390 // delete playback if it is a local version (i.e. cons'd up just now) 390 // delete playback if it is a local version (i.e. cons'd up just now)
391 if (playback != fPlayback) { 391 if (playback != fPlayback) {
392 SkDELETE(playback); 392 SkDELETE(playback);
393 } 393 }
394 } else { 394 } else {
395 stream->writeBool(false); 395 stream->writeBool(false);
396 } 396 }
397 } 397 }
398 398
399 void SkPicture::flatten(SkWriteBuffer& buffer) const { 399 void SkPicture::flatten(SkWriteBuffer& buffer) const {
400 SkPicturePlayback* playback = fPlayback; 400 SkPicturePlayback* playback = fPlayback;
401 401
402 if (NULL == playback && fRecord) { 402 if (NULL == playback && fRecord) {
403 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); 403 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
404 } 404 }
405 405
406 char header[kHeaderSize]; 406 char header[kHeaderSize];
407 createHeader(&header); 407 this->createHeader(&header);
408 buffer.writeByteArray(header, kHeaderSize); 408 buffer.writeByteArray(header, kHeaderSize);
409 if (playback) { 409 if (playback) {
410 buffer.writeBool(true); 410 buffer.writeBool(true);
411 playback->flatten(buffer); 411 playback->flatten(buffer);
412 // delete playback if it is a local version (i.e. cons'd up just now) 412 // delete playback if it is a local version (i.e. cons'd up just now)
413 if (playback != fPlayback) { 413 if (playback != fPlayback) {
414 SkDELETE(playback); 414 SkDELETE(playback);
415 } 415 }
416 } else { 416 } else {
417 buffer.writeBool(false); 417 buffer.writeBool(false);
418 } 418 }
419 } 419 }
420 420
421 bool SkPicture::willPlayBackBitmaps() const { 421 bool SkPicture::willPlayBackBitmaps() const {
422 if (!fPlayback) return false; 422 if (!fPlayback) return false;
423 return fPlayback->containsBitmaps(); 423 return fPlayback->containsBitmaps();
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

Powered by Google App Engine
This is Rietveld 408576698