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

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

Issue 732653004: option to return drawable from recording (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: plumb pictlist down to layer hoister Created 6 years 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
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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 /////////////////////////////////////////////////////////////////////////////// 307 ///////////////////////////////////////////////////////////////////////////////
308 308
309 void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) cons t { 309 void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) cons t {
310 SkASSERT(canvas); 310 SkASSERT(canvas);
311 311
312 // If the query contains the whole picture, don't bother with the BBH. 312 // If the query contains the whole picture, don't bother with the BBH.
313 SkRect clipBounds = { 0, 0, 0, 0 }; 313 SkRect clipBounds = { 0, 0, 0, 0 };
314 (void)canvas->getClipBounds(&clipBounds); 314 (void)canvas->getClipBounds(&clipBounds);
315 const bool useBBH = !clipBounds.contains(this->cullRect()); 315 const bool useBBH = !clipBounds.contains(this->cullRect());
316 316
317 SkRecordDraw(*fRecord, canvas, this->drawablePicts(), this->drawableCount(), 317 SkRecordDraw(*fRecord, canvas, this->drawablePicts(), NULL, this->drawableCo unt(),
318 useBBH ? fBBH.get() : NULL, callback); 318 useBBH ? fBBH.get() : NULL, callback);
319 } 319 }
320 320
321 /////////////////////////////////////////////////////////////////////////////// 321 ///////////////////////////////////////////////////////////////////////////////
322 322
323 #include "SkStream.h" 323 #include "SkStream.h"
324 324
325 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; 325 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' };
326 326
327 bool SkPicture::IsValidPictInfo(const SkPictInfo& info) { 327 bool SkPicture::IsValidPictInfo(const SkPictInfo& info) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 if (8 == sizeof(void*)) { 462 if (8 == sizeof(void*)) {
463 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag; 463 info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
464 } 464 }
465 } 465 }
466 466
467 // This for compatibility with serialization code only. This is not cheap. 467 // This for compatibility with serialization code only. This is not cheap.
468 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info, 468 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info,
469 SkPicture const* const drawablePicts[], int d rawableCount) { 469 SkPicture const* const drawablePicts[], int d rawableCount) {
470 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/); 470 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/);
471 rec.beginRecording(); 471 rec.beginRecording();
472 SkRecordDraw(src, &rec, drawablePicts, drawableCount, NULL/*bbh*/, NULL/ *callback*/); 472 SkRecordDraw(src, &rec, drawablePicts, NULL, drawableCount, NULL/*bbh*/, NULL/*callback*/);
473 rec.endRecording(); 473 rec.endRecording();
474 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/)); 474 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/));
475 } 475 }
476 476
477 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { 477 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
478 SkPictInfo info; 478 SkPictInfo info;
479 this->createHeader(&info); 479 this->createHeader(&info);
480 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(), 480 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(),
481 this->drawableCount())); 481 this->drawableCount()));
482 482
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 #endif 514 #endif
515 515
516 bool SkPicture::hasText() const { return fAnalysis.fHasText; } 516 bool SkPicture::hasText() const { return fAnalysis.fHasText; }
517 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; } 517 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm aps; }
518 int SkPicture::approximateOpCount() const { return fRecord->count(); } 518 int SkPicture::approximateOpCount() const { return fRecord->count(); }
519 519
520 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts, 520 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts,
521 SkBBoxHierarchy* bbh) 521 SkBBoxHierarchy* bbh)
522 : fUniqueID(next_picture_generation_id()) 522 : fUniqueID(next_picture_generation_id())
523 , fCullRect(cullRect) 523 , fCullRect(cullRect)
524 , fRecord(record) 524 , fRecord(SkRef(record))
525 , fBBH(SkSafeRef(bbh)) 525 , fBBH(SkSafeRef(bbh))
526 , fDrawablePicts(drawablePicts) 526 , fDrawablePicts(drawablePicts) // take ownership
527 , fAnalysis(*fRecord) 527 , fAnalysis(*fRecord)
528 {} 528 {}
529 529
530 // Note that we are assuming that this entry point will only be called from 530 // Note that we are assuming that this entry point will only be called from
531 // one thread. Currently the only client of this method is 531 // one thread. Currently the only client of this method is
532 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single 532 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single
533 // thread. 533 // thread.
534 void SkPicture::addDeletionListener(DeletionListener* listener) const { 534 void SkPicture::addDeletionListener(DeletionListener* listener) const {
535 SkASSERT(listener); 535 SkASSERT(listener);
536 536
537 *fDeletionListeners.append() = SkRef(listener); 537 *fDeletionListeners.append() = SkRef(listener);
538 } 538 }
539 539
540 void SkPicture::callDeletionListeners() { 540 void SkPicture::callDeletionListeners() {
541 for (int i = 0; i < fDeletionListeners.count(); ++i) { 541 for (int i = 0; i < fDeletionListeners.count(); ++i) {
542 fDeletionListeners[i]->onDeletion(this->uniqueID()); 542 fDeletionListeners[i]->onDeletion(this->uniqueID());
543 } 543 }
544 544
545 fDeletionListeners.unrefAll(); 545 fDeletionListeners.unrefAll();
546 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698