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

Side by Side Diff: src/pdf/SkPDFDevice.cpp

Issue 23621005: Replace SkTScopedPtr with SkAutoTDelete in Skia. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: port class comment Created 7 years, 3 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 | « src/core/SkAdvancedTypefaceMetrics.cpp ('k') | tests/WArrayTest.cpp » ('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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 #include "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 SkMatrix initialTransform; 573 SkMatrix initialTransform;
574 initialTransform.reset(); 574 initialTransform.reset();
575 SkISize size = SkISize::Make(width, height); 575 SkISize size = SkISize::Make(width, height);
576 return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform)); 576 return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform));
577 } 577 }
578 578
579 579
580 struct ContentEntry { 580 struct ContentEntry {
581 GraphicStateEntry fState; 581 GraphicStateEntry fState;
582 SkDynamicMemoryWStream fContent; 582 SkDynamicMemoryWStream fContent;
583 SkTScopedPtr<ContentEntry> fNext; 583 SkAutoTDelete<ContentEntry> fNext;
584 584
585 // If the stack is too deep we could get Stack Overflow. 585 // If the stack is too deep we could get Stack Overflow.
586 // So we manually destruct the object. 586 // So we manually destruct the object.
587 ~ContentEntry() { 587 ~ContentEntry() {
588 ContentEntry* val = fNext.release(); 588 ContentEntry* val = fNext.detach();
589 while (val != NULL) { 589 while (val != NULL) {
590 ContentEntry* valNext = val->fNext.release(); 590 ContentEntry* valNext = val->fNext.detach();
591 // When the destructor is called, fNext is NULL and exits. 591 // When the destructor is called, fNext is NULL and exits.
592 delete val; 592 delete val;
593 val = valNext; 593 val = valNext;
594 } 594 }
595 } 595 }
596 }; 596 };
597 597
598 // A helper class to automatically finish a ContentEntry at the end of a 598 // A helper class to automatically finish a ContentEntry at the end of a
599 // drawing method and maintain the state needed between set up and finish. 599 // drawing method and maintain the state needed between set up and finish.
600 class ScopedContentEntry { 600 class ScopedContentEntry {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 this->init(); 708 this->init();
709 } 709 }
710 710
711 SkPDFDevice::~SkPDFDevice() { 711 SkPDFDevice::~SkPDFDevice() {
712 this->cleanUp(true); 712 this->cleanUp(true);
713 } 713 }
714 714
715 void SkPDFDevice::init() { 715 void SkPDFDevice::init() {
716 fAnnotations = NULL; 716 fAnnotations = NULL;
717 fResourceDict = NULL; 717 fResourceDict = NULL;
718 fContentEntries.reset(); 718 fContentEntries.free();
719 fLastContentEntry = NULL; 719 fLastContentEntry = NULL;
720 fMarginContentEntries.reset(); 720 fMarginContentEntries.free();
721 fLastMarginContentEntry = NULL; 721 fLastMarginContentEntry = NULL;
722 fDrawingArea = kContent_DrawingArea; 722 fDrawingArea = kContent_DrawingArea;
723 if (fFontGlyphUsage == NULL) { 723 if (fFontGlyphUsage.get() == NULL) {
724 fFontGlyphUsage.reset(new SkPDFGlyphSetMap()); 724 fFontGlyphUsage.reset(new SkPDFGlyphSetMap());
725 } 725 }
726 } 726 }
727 727
728 void SkPDFDevice::cleanUp(bool clearFontUsage) { 728 void SkPDFDevice::cleanUp(bool clearFontUsage) {
729 fGraphicStateResources.unrefAll(); 729 fGraphicStateResources.unrefAll();
730 fXObjectResources.unrefAll(); 730 fXObjectResources.unrefAll();
731 fFontResources.unrefAll(); 731 fFontResources.unrefAll();
732 fShaderResources.unrefAll(); 732 fShaderResources.unrefAll();
733 SkSafeUnref(fAnnotations); 733 SkSafeUnref(fAnnotations);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1197 }
1198 1198
1199 ContentEntry* SkPDFDevice::getLastContentEntry() { 1199 ContentEntry* SkPDFDevice::getLastContentEntry() {
1200 if (fDrawingArea == kContent_DrawingArea) { 1200 if (fDrawingArea == kContent_DrawingArea) {
1201 return fLastContentEntry; 1201 return fLastContentEntry;
1202 } else { 1202 } else {
1203 return fLastMarginContentEntry; 1203 return fLastMarginContentEntry;
1204 } 1204 }
1205 } 1205 }
1206 1206
1207 SkTScopedPtr<ContentEntry>* SkPDFDevice::getContentEntries() { 1207 SkAutoTDelete<ContentEntry>* SkPDFDevice::getContentEntries() {
1208 if (fDrawingArea == kContent_DrawingArea) { 1208 if (fDrawingArea == kContent_DrawingArea) {
1209 return &fContentEntries; 1209 return &fContentEntries;
1210 } else { 1210 } else {
1211 return &fMarginContentEntries; 1211 return &fMarginContentEntries;
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 void SkPDFDevice::setLastContentEntry(ContentEntry* contentEntry) { 1215 void SkPDFDevice::setLastContentEntry(ContentEntry* contentEntry) {
1216 if (fDrawingArea == kContent_DrawingArea) { 1216 if (fDrawingArea == kContent_DrawingArea) {
1217 fLastContentEntry = contentEntry; 1217 fLastContentEntry = contentEntry;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 // TODO(vandebo): Figure out how/if we can handle the following modes: 1643 // TODO(vandebo): Figure out how/if we can handle the following modes:
1644 // SrcAtop, DestAtop, Xor, Plus. 1644 // SrcAtop, DestAtop, Xor, Plus.
1645 1645
1646 // These xfer modes don't draw source at all. 1646 // These xfer modes don't draw source at all.
1647 if (xfermode == SkXfermode::kClear_Mode || 1647 if (xfermode == SkXfermode::kClear_Mode ||
1648 xfermode == SkXfermode::kDst_Mode) { 1648 xfermode == SkXfermode::kDst_Mode) {
1649 return NULL; 1649 return NULL;
1650 } 1650 }
1651 1651
1652 ContentEntry* entry; 1652 ContentEntry* entry;
1653 SkTScopedPtr<ContentEntry> newEntry; 1653 SkAutoTDelete<ContentEntry> newEntry;
1654 1654
1655 ContentEntry* lastContentEntry = getLastContentEntry(); 1655 ContentEntry* lastContentEntry = getLastContentEntry();
1656 if (lastContentEntry && lastContentEntry->fContent.getOffset() == 0) { 1656 if (lastContentEntry && lastContentEntry->fContent.getOffset() == 0) {
1657 entry = lastContentEntry; 1657 entry = lastContentEntry;
1658 } else { 1658 } else {
1659 newEntry.reset(new ContentEntry); 1659 newEntry.reset(new ContentEntry);
1660 entry = newEntry.get(); 1660 entry = newEntry.get();
1661 } 1661 }
1662 1662
1663 populateGraphicStateEntryFromPaint(matrix, *clipStack, clipRegion, paint, 1663 populateGraphicStateEntryFromPaint(matrix, *clipStack, clipRegion, paint,
1664 hasText, &entry->fState); 1664 hasText, &entry->fState);
1665 if (lastContentEntry && xfermode != SkXfermode::kDstOver_Mode && 1665 if (lastContentEntry && xfermode != SkXfermode::kDstOver_Mode &&
1666 entry->fState.compareInitialState(lastContentEntry->fState)) { 1666 entry->fState.compareInitialState(lastContentEntry->fState)) {
1667 return lastContentEntry; 1667 return lastContentEntry;
1668 } 1668 }
1669 1669
1670 SkTScopedPtr<ContentEntry>* contentEntries = getContentEntries(); 1670 SkAutoTDelete<ContentEntry>* contentEntries = getContentEntries();
1671 if (!lastContentEntry) { 1671 if (!lastContentEntry) {
1672 contentEntries->reset(entry); 1672 contentEntries->reset(entry);
1673 setLastContentEntry(entry); 1673 setLastContentEntry(entry);
1674 } else if (xfermode == SkXfermode::kDstOver_Mode) { 1674 } else if (xfermode == SkXfermode::kDstOver_Mode) {
1675 entry->fNext.reset(contentEntries->release()); 1675 entry->fNext.reset(contentEntries->detach());
1676 contentEntries->reset(entry); 1676 contentEntries->reset(entry);
1677 } else { 1677 } else {
1678 lastContentEntry->fNext.reset(entry); 1678 lastContentEntry->fNext.reset(entry);
1679 setLastContentEntry(entry); 1679 setLastContentEntry(entry);
1680 } 1680 }
1681 newEntry.release(); 1681 newEntry.detach();
1682 return entry; 1682 return entry;
1683 } 1683 }
1684 1684
1685 void SkPDFDevice::finishContentEntry(const SkXfermode::Mode xfermode, 1685 void SkPDFDevice::finishContentEntry(const SkXfermode::Mode xfermode,
1686 SkPDFFormXObject* dst) { 1686 SkPDFFormXObject* dst) {
1687 if (xfermode != SkXfermode::kSrcIn_Mode && 1687 if (xfermode != SkXfermode::kSrcIn_Mode &&
1688 xfermode != SkXfermode::kDstIn_Mode && 1688 xfermode != SkXfermode::kDstIn_Mode &&
1689 xfermode != SkXfermode::kSrcOut_Mode && 1689 xfermode != SkXfermode::kSrcOut_Mode &&
1690 xfermode != SkXfermode::kDstOut_Mode) { 1690 xfermode != SkXfermode::kDstOut_Mode) {
1691 SkASSERT(!dst); 1691 SkASSERT(!dst);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 } 1922 }
1923 1923
1924 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, 1924 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
1925 SkCanvas::Config8888) { 1925 SkCanvas::Config8888) {
1926 return false; 1926 return false;
1927 } 1927 }
1928 1928
1929 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { 1929 bool SkPDFDevice::allowImageFilter(SkImageFilter*) {
1930 return false; 1930 return false;
1931 } 1931 }
OLDNEW
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.cpp ('k') | tests/WArrayTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698