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

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

Issue 787833002: Revert of Replace EncodeBitmap with an interface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | src/core/SkPictureData.h » ('j') | 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 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
3 * 4 *
4 * 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
5 * found in the LICENSE file. 6 * found in the LICENSE file.
6 */ 7 */
7 8
8 9
9 #include "SkPictureFlat.h" 10 #include "SkPictureFlat.h"
10 #include "SkPictureData.h" 11 #include "SkPictureData.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // This for compatibility with serialization code only. This is not cheap. 447 // This for compatibility with serialization code only. This is not cheap.
447 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info, 448 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info,
448 SkPicture const* const drawablePicts[], int d rawableCount) { 449 SkPicture const* const drawablePicts[], int d rawableCount) {
449 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/); 450 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/);
450 rec.beginRecording(); 451 rec.beginRecording();
451 SkRecordDraw(src, &rec, drawablePicts, NULL, drawableCount, NULL/*bbh*/, NULL/*callback*/); 452 SkRecordDraw(src, &rec, drawablePicts, NULL, drawableCount, NULL/*bbh*/, NULL/*callback*/);
452 rec.endRecording(); 453 rec.endRecording();
453 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/)); 454 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/));
454 } 455 }
455 456
456 #ifdef SK_LEGACY_ENCODE_BITMAP 457 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
457 // Helper to support the EncodeBitmap version of serialize.
458 // Mimics the old behavior of always accepting the encoded data, and encoding
459 // using EncodeBitmap if there was no encoded data.
460 class EncodeBitmapSerializer : public SkPixelSerializer {
461 public:
462 explicit EncodeBitmapSerializer(SkPicture::EncodeBitmap encoder)
463 : fEncoder(encoder)
464 {
465 SkASSERT(fEncoder);
466 }
467
468 virtual bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true ; }
469
470 virtual SkData* onEncodePixels(const SkImageInfo& info, void* pixels,
471 size_t rowBytes) SK_OVERRIDE {
472 // Required by signature of EncodeBitmap.
473 size_t unused;
474 SkBitmap bm;
475 bm.installPixels(info, pixels, rowBytes);
476 return fEncoder(&unused, bm);
477 }
478
479 private:
480 SkPicture::EncodeBitmap fEncoder;
481 };
482
483 void SkPicture::serialize(SkWStream* wStream, SkPicture::EncodeBitmap encoder) c onst {
484 EncodeBitmapSerializer serializer(encoder);
485 this->serialize(wStream, &serializer);
486 }
487
488 #endif
489
490 void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer) const {
491 SkPictInfo info; 458 SkPictInfo info;
492 this->createHeader(&info); 459 this->createHeader(&info);
493 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(), 460 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(),
494 this->drawableCount())); 461 this->drawableCount()));
495 462
496 stream->write(&info, sizeof(info)); 463 stream->write(&info, sizeof(info));
497 if (data) { 464 if (data) {
498 stream->writeBool(true); 465 stream->writeBool(true);
499 data->serialize(stream, pixelSerializer); 466 data->serialize(stream, encoder);
500 } else { 467 } else {
501 stream->writeBool(false); 468 stream->writeBool(false);
502 } 469 }
503 } 470 }
504 471
505 void SkPicture::flatten(SkWriteBuffer& buffer) const { 472 void SkPicture::flatten(SkWriteBuffer& buffer) const {
506 SkPictInfo info; 473 SkPictInfo info;
507 this->createHeader(&info); 474 this->createHeader(&info);
508 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(), 475 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(),
509 this->drawableCount())); 476 this->drawableCount()));
(...skipping 22 matching lines...) Expand all
532 499
533 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts, 500 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts,
534 SkBBoxHierarchy* bbh) 501 SkBBoxHierarchy* bbh)
535 : fUniqueID(next_picture_generation_id()) 502 : fUniqueID(next_picture_generation_id())
536 , fCullRect(cullRect) 503 , fCullRect(cullRect)
537 , fRecord(SkRef(record)) 504 , fRecord(SkRef(record))
538 , fBBH(SkSafeRef(bbh)) 505 , fBBH(SkSafeRef(bbh))
539 , fDrawablePicts(drawablePicts) // take ownership 506 , fDrawablePicts(drawablePicts) // take ownership
540 , fAnalysis(*fRecord) 507 , fAnalysis(*fRecord)
541 {} 508 {}
OLDNEW
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698