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

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

Issue 820903002: remove dead SK_LEGACY_ENCODE_BITMAP flag (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/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 * Copyright 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "SkPictureFlat.h" 9 #include "SkPictureFlat.h"
10 #include "SkPictureData.h" 10 #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. 446 // This for compatibility with serialization code only. This is not cheap.
447 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info, 447 SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info,
448 SkPicture const* const drawablePicts[], int d rawableCount) { 448 SkPicture const* const drawablePicts[], int d rawableCount) {
449 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/); 449 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/);
450 rec.beginRecording(); 450 rec.beginRecording();
451 SkRecordDraw(src, &rec, drawablePicts, NULL, drawableCount, NULL/*bbh*/, NULL/*callback*/); 451 SkRecordDraw(src, &rec, drawablePicts, NULL, drawableCount, NULL/*bbh*/, NULL/*callback*/);
452 rec.endRecording(); 452 rec.endRecording();
453 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/)); 453 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/));
454 } 454 }
455 455
456 #ifdef SK_LEGACY_ENCODE_BITMAP
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 bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; }
469
470 SkData* onEncodePixels(const SkImageInfo& info, const 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, const_cast<void*>(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 { 456 void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer) const {
491 SkPictInfo info; 457 SkPictInfo info;
492 this->createHeader(&info); 458 this->createHeader(&info);
493 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(), 459 SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePic ts(),
494 this->drawableCount())); 460 this->drawableCount()));
495 461
496 stream->write(&info, sizeof(info)); 462 stream->write(&info, sizeof(info));
497 if (data) { 463 if (data) {
498 stream->writeBool(true); 464 stream->writeBool(true);
499 data->serialize(stream, pixelSerializer); 465 data->serialize(stream, pixelSerializer);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 498
533 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts, 499 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr awablePicts,
534 SkBBoxHierarchy* bbh) 500 SkBBoxHierarchy* bbh)
535 : fUniqueID(next_picture_generation_id()) 501 : fUniqueID(next_picture_generation_id())
536 , fCullRect(cullRect) 502 , fCullRect(cullRect)
537 , fRecord(SkRef(record)) 503 , fRecord(SkRef(record))
538 , fBBH(SkSafeRef(bbh)) 504 , fBBH(SkSafeRef(bbh))
539 , fDrawablePicts(drawablePicts) // take ownership 505 , fDrawablePicts(drawablePicts) // take ownership
540 , fAnalysis(*fRecord) 506 , fAnalysis(*fRecord)
541 {} 507 {}
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